Skip to content

Revagentic/firebase-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

191 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FitCopilot

FitCopilot is a fitness platform that connects gym members with personalized workouts, class schedules, and health tracking — while giving gym owners and coaches the tools to manage trainers, classes, members, and revenue.

What's in this repo

Component Directory Tech Description
Member App flutter_app/ Flutter/Dart Mobile app for gym members — sign up, connect to a gym, generate workouts & plans, track health data
Cockpit cockpit/ Next.js Gym owner/coach dashboard — member management, class schedules, analytics, announcements
Portal portal/ Vite/React Member-facing web portal — billing, subscription management, gym onboarding, workout sharing
Admin Dashboard admin/ Next.js System admin panel for platform-wide management
Cloud Functions functions/ TypeScript/Node Firebase Cloud Functions — AI workout generation, billing, exercise search, analytics, email
Infrastructure infra/ Terraform GCP/Firebase infrastructure — APIs, secrets, hosting, Cloud Run, Artifact Registry
Exercise Scraper scraper/ TypeScript/Node Scrapes and processes exercise data from multiple sources into a searchable library
Shared Types shared/ TypeScript Shared types and utilities across workspaces

Architecture

┌─────────────────┐     ┌─────────────────┐     ┌─────────────────┐
│   Flutter App    │     │    Cockpit      │     │     Portal      │
│  (iOS/Android)   │     │ (Next.js SSR)   │     │   (Vite SPA)    │
└────────┬─────────┘     └────────┬────────┘     └────────┬────────┘
         │                        │                       │
         └────────────────────────┼───────────────────────┘
                                  │
                    ┌─────────────▼──────────────┐
                    │    Firebase Cloud Functions  │
                    │  (Gemini AI, Stripe, TTS)   │
                    └─────────────┬───────────────┘
                                  │
              ┌───────────────────┼───────────────────┐
              │                   │                   │
     ┌────────▼───────┐ ┌────────▼───────┐ ┌────────▼───────┐
     │   Firestore    │ │ Cloud Storage  │ │  Firebase Auth │
     └────────────────┘ └────────────────┘ └────────────────┘

Firebase project: revagentic GCP region: us-central1

Prerequisites

  • Node.js 22 (required by Cloud Functions)
    • Homebrew: brew install node@22
    • Or use fnm, nvm, or volta
  • npm 10+ (ships with Node 22)
  • Firebase CLI: npm install -g firebase-tools
  • Flutter SDK (for the member app — use fvm flutter if using FVM)
  • Terraform 1.5+ (for infrastructure changes)
  • gcloud CLI (for GCP operations)
  • Xcode (macOS, for iOS simulator)
  • Android Studio + SDK (for Android emulator)

Quick Start

# 1. Clone and install dependencies
git clone <repo-url>
cd copilot
npm install

# 2. Authenticate with Firebase and GCP
firebase login
gcloud auth login
gcloud auth application-default login
gcloud config set account charles@revagentic.ai
gcloud config set project revagentic

# 3. Set up environment files
# Portal (Vite SPA)
cp portal/.env.example portal/.env        # Edit with Firebase config

# Cockpit and Admin use App Hosting env vars (set in Firebase Console)
# For local dev, create .env.local files:
cp cockpit/.env.local.example cockpit/.env.local
cp admin/.env.local.example admin/.env.local

# 4. Start dev servers
npm run dev:cockpit   # Gym admin dashboard — http://localhost:3000
npm run dev:portal    # Member portal
npm run dev:admin     # System admin

Environment Variables

All web apps need these Firebase config values (public, safe to expose):

NEXT_PUBLIC_FIREBASE_API_KEY=...
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=revagentic.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=revagentic
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=revagentic.firebasestorage.app
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=8845963427
NEXT_PUBLIC_FIREBASE_APP_ID=...
NEXT_PUBLIC_GOOGLE_PLACES_API_KEY=...   # From: cd infra && terraform output -raw places_api_key

Get the API key and App ID from Firebase Console → Project Settings → Your apps.

Cloud Functions secrets are managed in GCP Secret Manager via Terraform:

Secret Source
STRIPE_SECRET_KEY Stripe Dashboard → API keys
OPENAI_API_KEY platform.openai.com
GOOGLE_AI_API_KEY Auto-set by Terraform from managed API key
RESEND_API_KEY resend.com

Cloud Functions env (functions/.env):

Key Source
GA4_PROPERTY_ID Firebase Console → Project Settings → Integrations → Google Analytics
RC_STRIPE_PUBLIC_KEY RevenueCat Dashboard → Integrations → Stripe

Deployment

Web Apps

App Method How to deploy
Cockpit Firebase App Hosting (SSR) Auto-deploys on push to main
Admin Firebase App Hosting (SSR) Auto-deploys on push to main
Portal Firebase Hosting (static) npm run deploy:portal

Other Services

npm run deploy:functions    # Cloud Functions
npm run deploy:firestore    # Firestore rules + indexes
npm run deploy:storage      # Storage rules

Scraper

cd scraper
./deploy.sh                 # Build, push Docker image, update Cloud Run job
npm run deploy:execute      # Run the scraper job

Flutter App

cd flutter_app
fvm flutter build ios       # iOS build
fvm flutter build appbundle # Android build

Infrastructure

cd infra
terraform plan -var-file="production.secret.tfvars"
terraform apply -var-file="production.secret.tfvars"

Infrastructure (Terraform)

All GCP infrastructure is managed in infra/. Terraform controls:

  • 21 GCP APIs — Firebase, Firestore, Cloud Functions, Cloud Run, Vertex AI, Secret Manager, etc.
  • Firebase apps — iOS, Android, Web
  • Firebase Hosting sites — portal, admin, cockpit
  • Secrets — Stripe, OpenAI, Gemini, Resend (containers + values via production.secret.tfvars)
  • API keys — Gemini (restricted to Generative Language API), Places (restricted to Places API)
  • Cloud Run — Workout scraper job
  • Artifact Registry — Docker image repository
  • GCS — Scraper data bucket

State is stored remotely in gs://revagentic-terraform-state.

All resources are labeled:

company     = revagentic
product     = fitcopilot
environment = production
managed_by  = terraform

First-time Terraform setup

cd infra
terraform init                                          # Initialize with GCS backend
terraform plan -var-file="production.secret.tfvars"     # Preview changes
terraform apply -var-file="production.secret.tfvars"    # Apply

# Get API keys
terraform output -raw gemini_api_key
terraform output -raw places_api_key

Secrets management

Copy the example and fill in your keys:

cp infra/production.secret.tfvars.example infra/production.secret.tfvars

This file is gitignored. It sets secret values in GCP Secret Manager without needing firebase functions:secrets:set.

Firebase Auth — Authorized Domains

When adding new hosting domains (App Hosting, custom domains), you must manually add them to:

Firebase Console → Authentication → Settings → Authorized domains

App Hosting domains are NOT auto-added. Current authorized domains include:

  • localhost
  • revagentic.firebaseapp.com
  • revagentic.web.app
  • App Hosting domains (*--revagentic.us-east4.hosted.app)
  • Any custom domains you configure

Project Structure

copilot/
├── admin/           # System admin dashboard (Next.js, App Hosting)
├── cockpit/         # Gym owner/coach dashboard (Next.js, App Hosting)
├── portal/          # Member billing/onboarding portal (Vite SPA, Firebase Hosting)
├── flutter_app/     # Flutter mobile app (iOS/Android)
├── functions/       # Firebase Cloud Functions
├── infra/           # Terraform infrastructure
│   ├── apis.tf              # GCP API enablement
│   ├── api-keys.tf          # Gemini + Places API keys
│   ├── firebase.tf          # Firebase project, apps, hosting sites
│   ├── secrets.tf           # Secret Manager secrets
│   ├── cloud-run.tf         # Scraper Cloud Run job
│   ├── gcs.tf               # Storage buckets
│   ├── artifact-registry.tf # Docker image repo
│   ├── provider.tf          # Terraform + Google provider config
│   ├── variables.tf         # Variables + labels
│   └── terraform.tfvars     # Non-secret variable values
├── scraper/         # Exercise data scraper (Cloud Run job)
├── shared/          # Shared TypeScript types
├── firebase.json    # Firebase config (hosting, functions, firestore, storage)
├── firestore.rules  # Firestore security rules
├── storage.rules    # Cloud Storage security rules
└── CLAUDE.md        # Coding conventions and design system tokens

Running Individual Services

Service Command URL
Cockpit npm run dev:cockpit http://localhost:3000
Portal npm run dev:portal http://localhost:5173
Admin npm run dev:admin http://localhost:3001
Firebase Emulators firebase emulators:start http://localhost:4000

Firebase Emulator Ports

Service Port
Emulator UI 4000
Firestore 8080
Auth 9099
Functions 5001
Storage 9199

Testing

  • Cockpit/Admin: Vitest with jsdom
  • Flutter app: Flutter test
  • Test location: Co-located in __tests__/ directories next to source files
npm run test --workspace=cockpit   # Cockpit tests
npm run test --workspace=admin     # Admin tests
cd flutter_app && fvm flutter test # Flutter tests

External Services

Service Purpose Dashboard
Firebase/GCP Auth, Firestore, Storage, Functions, Hosting console.firebase.google.com
Stripe Payment processing dashboard.stripe.com
RevenueCat Mobile subscription management app.revenuecat.com
Resend Transactional email resend.com
OpenAI Real-time voice transcription platform.openai.com
Google AI (Gemini) Workout generation, image gen, TTS Managed via GCP
Google Analytics (GA4) App analytics analytics.google.com

Code Conventions

See CLAUDE.md for the full coding standards including:

  • Import ordering and naming conventions
  • Feature-based file organization
  • Component and styling patterns
  • Design tokens (colors, spacing, typography)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors