Skip to content

ScripTag is a comprehensive medication management platform that leverages NFC technology to help users track and manage their medications. The platform consists of a React Native mobile application, a Go-based GraphQL API, notification services, and cloud infrastructure.

Notifications You must be signed in to change notification settings

joshuamyers-dev/scriptag-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ScripTag Platform

ScripTag is a comprehensive medication management platform that leverages NFC technology to help users track and manage their medications. The platform consists of a React Native mobile application, a Go-based GraphQL API, notification services, and cloud infrastructure.

πŸ”’ Security Notice

IMPORTANT: This repository contains sensitive credentials that must be properly secured before contributing or deploying.

Never commit:

  • .env files
  • service-account-key.json or firebase-service-account-key.json
  • GoogleService-Info.plist
  • Any files containing API keys, secrets, or credentials

All sensitive files have .example templates in this repository. Copy them and fill in your actual credentials locally.

πŸ—οΈ Architecture

This is a monorepo containing the following components:

Mobile Application

  • React Native App (apps/react-native-app/) - Cross-platform mobile application for iOS and Android
    • NFC tag scanning and writing
    • Medication tracking and scheduling
    • Push notifications via Firebase Cloud Messaging
    • User authentication (Google Sign-In, Apple Sign-In)
    • Apollo GraphQL client integration

Backend Services

  • Go GraphQL API (services/go-api/) - Main backend API service

    • GraphQL API built with gqlgen
    • PostgreSQL database with GORM ORM
    • JWT-based authentication
    • Firebase Admin SDK integration
    • Atlas for database migrations
    • River for background job processing
  • Notification Dispatcher (jobs/notification-dispatcher/) - Cloud Run service for medication reminders

    • Scheduled medication reminder notifications
    • Firebase Cloud Messaging integration
    • Batch processing (100 notifications at a time)
    • Automatic invalid token cleanup

Shared Resources

  • Shared Models (shared/) - Common Go models and types shared across services
    • Medication models
    • User models
    • Notification models
    • User medication schedules

Infrastructure

  • GCP Infrastructure (infra/gcp/) - Google Cloud Platform infrastructure as code
    • Pulumi-based infrastructure definitions
    • Cloud Run deployments
    • Storage configuration

Tools

  • Bootstrap API (tools/bootstrap-api/) - API initialization tools
  • ChatGPT Extractor (tools/chatgpt-extractor/) - Medication data extraction utilities
  • Style Dictionary (tools/style-dictionary/) - Design token management

πŸš€ Getting Started

Prerequisites

  • Node.js >= 18
  • Go 1.24+
  • PostgreSQL database
  • Firebase project with Cloud Messaging enabled
  • React Native development environment (Xcode for iOS, Android Studio for Android)

πŸ” Credentials Setup

CRITICAL: Complete this section before running the application.

1. Firebase Setup

  1. Go to Firebase Console
  2. Create or select your project
  3. Download configuration files:
    • For iOS: Download GoogleService-Info.plist
      • Go to Project Settings β†’ iOS App
      • Place in apps/react-native-app/ios/
    • For Android: Download google-services.json
      • Go to Project Settings β†’ Android App
      • Place in apps/react-native-app/android/app/
    • For Backend: Download Service Account Key
      • Go to Project Settings β†’ Service Accounts
      • Click "Generate New Private Key"
      • Save as services/go-api/firebase-service-account-key.json
      • Save as jobs/notification-dispatcher/service-account-key.json

⚠️ These files are gitignored and will NOT be committed

2. Environment Variables

Create .env files from the provided examples:

# Go API
cp services/go-api/.env.example services/go-api/.env
# Edit services/go-api/.env with your credentials

# React Native App
cp apps/react-native-app/.env.example apps/react-native-app/.env
# Edit apps/react-native-app/.env with your API URL

# Notification Dispatcher
cp jobs/notification-dispatcher/.env.example jobs/notification-dispatcher/.env
# Edit jobs/notification-dispatcher/.env with your database URL

Required Configuration:

services/go-api/.env:

DB_CONN_STR="host=localhost user=postgres password=YOUR_PASSWORD dbname=scriptag port=5432 sslmode=disable TimeZone=UTC"
SECRET_KEY=$(openssl rand -hex 32)  # Generate a secure random key
ENVIRONMENT=development
PORT=8080

apps/react-native-app/.env:

# For iOS Simulator
API_URL=http://localhost:8080/query

# For Android Emulator
# API_URL=http://10.0.2.2:8080/query

# For physical device (replace with your computer's IP)
# API_URL=http://192.168.1.XXX:8080/query

3. Database Setup

Create the PostgreSQL database:

createdb scriptag
# Or using psql
psql -U postgres -c "CREATE DATABASE scriptag;"

Environment Setup

  1. Clone the repository:
git clone https://github.com/joshnissenbaum/scriptag-platform.git
cd scriptag-platform
  1. Install dependencies for the React Native app:
cd apps/react-native-app
npm install
cd ios && pod install && cd ..
  1. Set up environment variables for the Go API:
cd services/go-api
cp .env.example .env
# Edit .env with your database credentials and Firebase config
  1. Initialize the Go workspace:
# From project root
go work sync

Running the Development Environment

1. Start the Go API Server

cd services/go-api
ENVIRONMENT=development go run server.go

Or use the VS Code task: Go API - Start Server

2. Start the React Native App

First, start Metro bundler:

cd apps/react-native-app
npm run start --reset-cache

Or use the VS Code task: React Native App - Start Metro

Then run the app:

# iOS
npm run ios

# Android
npm run android

Code Generation

The project uses code generation for GraphQL schemas and types:

Generate Go GraphQL Code

cd services/go-api
go run github.com/99designs/gqlgen generate

Or use the VS Code task: Go GraphQL - Codegen

Generate React Native GraphQL Types

cd apps/react-native-app
npm run generate

Or use the VS Code task: React Native App - Codegen

πŸ“± Features

Core Functionality

  • NFC Tag Management - Write medication information to NFC tags and scan them to log consumption
  • Medication Tracking - Add, manage, and track multiple medications
  • Smart Scheduling - Configure medication schedules (daily, intervals, specific days, as needed)
  • Push Notifications - Receive timely medication reminders via Firebase Cloud Messaging
  • Consumption History - View and track medication intake history
  • User Authentication - Secure authentication with Google and Apple Sign-In

Mobile App Technologies

  • React Native 0.79.2
  • Apollo Client for GraphQL
  • React Navigation for routing
  • Zustand for state management
  • React Native NFC Manager for NFC functionality
  • Firebase Cloud Messaging for notifications
  • React Native Reanimated for animations
  • MMKV for efficient local storage

Backend Technologies

  • Go 1.24
  • GraphQL (gqlgen)
  • GORM for database operations
  • PostgreSQL database
  • JWT authentication
  • Firebase Admin SDK
  • River for background jobs
  • Atlas for migrations

πŸ—‚οΈ Project Structure

scriptag/
β”œβ”€β”€ apps/
β”‚   └── react-native-app/       # Mobile application
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ components/     # Reusable UI components
β”‚       β”‚   β”œβ”€β”€ features/       # Feature-based modules
β”‚       β”‚   β”œβ”€β”€ graphql/        # GraphQL queries and mutations
β”‚       β”‚   β”œβ”€β”€ hooks/          # Custom React hooks
β”‚       β”‚   β”œβ”€β”€ navigators/     # Navigation configuration
β”‚       β”‚   └── utils/          # Utility functions
β”‚       β”œβ”€β”€ android/            # Android native code
β”‚       └── ios/                # iOS native code
β”‚
β”œβ”€β”€ services/
β”‚   └── go-api/                 # Main backend API
β”‚       β”œβ”€β”€ adapters/           # Data adapters and repositories
β”‚       β”œβ”€β”€ auth/               # Authentication logic
β”‚       β”œβ”€β”€ config/             # Configuration (DB, Firebase)
β”‚       β”œβ”€β”€ core/               # Business logic ports/interfaces
β”‚       β”œβ”€β”€ db/                 # Database models and queries
β”‚       β”œβ”€β”€ graph/              # GraphQL resolvers and schema
β”‚       β”œβ”€β”€ migrations/         # Database migrations
β”‚       β”œβ”€β”€ service/            # Business logic implementations
β”‚       └── workers/            # Background job workers
β”‚
β”œβ”€β”€ jobs/
β”‚   └── notification-dispatcher/ # Cloud Run notification service
β”‚
β”œβ”€β”€ shared/                     # Shared Go models
β”‚   └── models/                 # Common data models
β”‚
β”œβ”€β”€ infra/
β”‚   └── gcp/                    # Google Cloud Platform infrastructure
β”‚
└── tools/                      # Development and utility tools

πŸ”§ Database Migrations

The project uses Atlas for database migrations:

cd services/go-api

# Generate a new migration
atlas migrate diff --env local

# Apply migrations
atlas migrate apply --env local

🚒 Deployment

Deploying the API (Cloud Run)

cd services/go-api
gcloud run deploy go-api \
  --source . \
  --region us-central1 \
  --set-env-vars "DATABASE_URL=[YOUR_DATABASE_URL]"

Deploying the Notification Dispatcher

cd jobs/notification-dispatcher
gcloud run deploy notification-dispatcher \
  --source . \
  --region us-central1 \
  --set-env-vars "DATABASE_URL=[YOUR_DATABASE_URL]"

Building the Mobile App

iOS

cd apps/react-native-app
npm run ios --configuration Release

Android

cd apps/react-native-app
npm run android --variant=release

πŸ§ͺ Testing

Run Tests

cd apps/react-native-app
npm test

πŸ“ API Documentation

The GraphQL API includes an interactive playground available at:

http://localhost:8080/

Key GraphQL Operations

  • medications - Query available medications with pagination
  • myMedications - Get user's medication list
  • addMyMedication - Add a medication to user's list
  • createMedicationSchedule - Set up medication schedule
  • logConsumption - Record medication intake

πŸ” Authentication

The platform uses Firebase Authentication with support for:

  • Google Sign-In
  • Apple Sign-In
  • JWT tokens for API authentication

πŸ“± NFC Integration

The app uses NFC tags to:

  1. Link physical medication containers to digital records
  2. Quick-log medication consumption by tapping the tag
  3. Provide a seamless user experience for medication tracking

NFC tags are written with medication-specific data and can be attached to medication bottles or packaging.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is proprietary software. All rights reserved.

πŸ‘₯ Team

Developed by Josh Nissenbaum

πŸ› Known Issues

  • NFC functionality requires physical NFC tags from ScripTag
  • iOS requires specific entitlements for NFC tag reading/writing
  • Android requires NFC permissions in the manifest

πŸ“ž Support

For issues, questions, or feature requests, please contact the development team or open an issue in the repository.


Note: This is a monorepo managed with Go workspaces. Make sure to run go work sync after pulling changes that affect Go modules.

About

ScripTag is a comprehensive medication management platform that leverages NFC technology to help users track and manage their medications. The platform consists of a React Native mobile application, a Go-based GraphQL API, notification services, and cloud infrastructure.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published