Skip to main content

Architecture Overview

FitAiid is a full-stack SaaS fitness platform that uses a modern, cloud-native architecture:

Technology Stack

Backend

Node.js + Express
  • Node.js v20 LTS
  • Express.js v4.21.2
  • JWT Authentication
  • Rate Limiting (100 req/15min)

Frontend

HTML5 + CSS3 + Vanilla JS
  • Progressive Web App (PWA)
  • Service Workers
  • Offline-first architecture
  • Firebase OAuth

Database

MongoDB Atlas
  • NoSQL cloud database
  • Mongoose ODM v8.18.2
  • Auto-scaling clusters

APIs & Services

External Integrations
  • OpenAI API (workout generation)
  • Stripe (payments)
  • Firebase Admin (authentication)
  • Web Push (notifications)

Deployment Platforms

Railway

Deploy your Node.js backend API with automatic builds and zero-config infrastructure.

Vercel

Deploy your frontend PWA with global CDN and instant rollbacks.

Deployment Process

The complete deployment takes approximately 30 minutes and follows these steps:
1

Prepare Repository

Push your code to GitHub and ensure all tests pass (17/17 tests).
2

Deploy Backend to Railway

Configure environment variables and deploy the Express API.
3

Deploy Frontend to Vercel

Connect your repository and deploy the PWA with service workers.
4

Verify Deployment

Test authentication, API endpoints, and integrations.

Key Features

Security

  • Helmet - Secure HTTP headers
  • bcryptjs - Password hashing (10 rounds)
  • JWT - Secure token-based authentication
  • express-rate-limit - DDoS protection
  • express-mongo-sanitize - NoSQL injection prevention
  • xss-clean - XSS attack prevention

Monitoring & Logging

  • Winston - Structured logging
  • winston-daily-rotate-file - Daily log rotation
  • Morgan - HTTP request logging

API Documentation

  • Swagger - Interactive API documentation
  • Auto-generated from JSDoc comments

Database Collections

The FitAiid database contains the following collections:
  • users - User authentication and profiles
  • workoutProgress - Training session data
  • orders - Stripe payment records
  • products - Subscription catalog
  • pushSubscriptions - Web push notification subscriptions
  • customSchemas - Dynamic user data

Prerequisites

Before starting the deployment process, ensure you have:
  • Node.js v20+ installed
  • Git installed and configured
  • GitHub account
  • Railway account
  • Vercel account
  • MongoDB Atlas cluster created
  • All API keys obtained (OpenAI, Stripe, Firebase)

Environment Requirements

Production Requirements:
  • 0 npm vulnerabilities
  • All tests passing (17/17)
  • Environment variables configured
  • MongoDB Atlas IP whitelist configured (0.0.0.0/0 for Railway)
  • Firebase Admin SDK credentials
  • VAPID keys generated for push notifications

Quick Start

Ready to deploy? Follow these guides in order:
  1. Backend Deployment - Deploy Express API to Railway
  2. Frontend Deployment - Deploy PWA to Vercel
  3. Environment Variables - Configure all secrets

Estimated Costs

Free Tier Availability:
  • Railway: $5 credit/month (sufficient for staging)
  • Vercel: Unlimited deployments (Hobby plan)
  • MongoDB Atlas: 512MB free forever (M0 cluster)
  • Firebase: 50K reads/day free

Production URLs

After deployment, your application will be accessible at:
# Frontend (Vercel)
https://fitaiid.vercel.app

# Backend API (Railway)
https://fitaiid-api.railway.app

# Admin Login
https://fitaiid.vercel.app/pages/login.html

Support

If you encounter issues during deployment:

Railway Logs

Check deployment logs in Railway Dashboard → Deployments → View Logs

Vercel Logs

Review build logs in Vercel Dashboard → Deployments → View Details

Browser DevTools

Press F12 → Console for JavaScript errors and Network tab for API issues

Next Steps

Configure Backend

Start by deploying your Express backend to Railway with MongoDB Atlas connection.

Build docs developers (and LLMs) love