How charliehanson/marathon-nutrition-app works
Project Type and Purpose
• This is a full-stack, AI-driven meal-planning web application (“Alimenta”) tailored for marathon runners and athletes. It combines a Next.js/React frontend, Vercel serverless Node API endpoints, a separate Flask ML validation service, OpenAI GPT-3.5 for meal generation, and a Supabase (PostgreSQL + Auth) backend.
File Structure Analysis
• Top-level directories:
• api/ – Vercel serverless functions (Node.js)
• ml-service/ – Flask REST API with separate subfolders per meal type and archived code
• pages/ & src/ – Next.js pages and React components/hooks/services
• public/ – static assets
• tests/ & ml-service/tests – Frontend (Vitest) and ML (pytest) test suites
• Config files: next.config.js, tailwind.config.js, vercel.json, .github/workflows/ci-cd.yml
• Key patterns:
• Frontend (React+Next) follows component, hooks, context, services structure
• Backend micro-services style: Node serverless functions (stateless endpoints) and a separate Flask ML microservice
• CI/CD via GitHub Actions deploying to Vercel (frontend + Node API) and Railway (Flask API)
README Insights
• Tech stack: Next.js/React + Tailwind, Vercel Node API, Flask REST on Railway, Supabase, OpenAI GPT-3.5, scikit-learn models
• Database schema: four Supabase tables with Row-Level Security
• CI/CD, testing, and deployment details for both services
• React Frontend (Next.js 14 pages, components, hooks, context)
• Vercel Serverless Layer (Node.js functions under api/)
• OpenAI GPT-3.5 (external AI service)
• ML Validation Service (Flask API on Railway, per-meal models)
• Database/Auth (Supabase PostgreSQL + Auth)
• (Optional) CI/CD Pipeline (GitHub Actions), Testing
1. User → React Frontend
2. Frontend → Vercel Functions (generate-meals, get-recipe, regenerate-meal, generate-grocery-list, rate-meal, get-personalized-preferences)
3. Vercel Functions → OpenAI GPT-3.5 (meal descriptions)
4. Vercel Functions → ML Validation Service (Flask endpoints)
5. Vercel Functions → Supabase (CRUD on user_profiles, food_preferences, training_plans, meal_plans)
6. Frontend ↔ Supabase Auth (login, token refresh)
c. Architectural Patterns & Principles:
• Micro-services / serverless separation: Node API vs. Flask ML service
• API gateway style: Vercel functions act as thin orchestration layer
• Single-Page Application for UI with SSR/SSG via Next.js
• Modular ML pipeline: Separate models per meal type for specialization
• Security: Supabase row-level policies, JWT based auth
• CI/CD best practices: automated test suites, model validation, zero-downtime deploys
d. Key Technologies & Libraries:
• Next.js, React Hooks, Tailwind CSS
• Vercel Serverless (Node.js)
• Flask, scikit-learn, TF-IDF, joblib, pandas, NumPy
• OpenAI API (GPT-3.5 Turbo)
• Supabase (PostgreSQL, Auth)
• GitHub Actions, Railway, Vercel