How mrtaz77/brain-train works
Project Type and Purpose
• Geeky Chef is a full‐stack web application providing AI‐driven meal planning, recipe discovery, nutrition analysis, and food image recognition.
• The backend is a modular Node + Express API; the frontend is a Vite‐built React application.
File Structure
• Top‐level:
• backend/ – Express app, subdivided into domain “apps” (ai-assistance, mealplan, search, favourite, trending, user, signin, signup), each with routes, controllers, DB connectors, middleware, tests, and utils.
• backend/libraries/ – shared Mongoose models and external service wrappers (Spoonacular, Firebase, Gemini, Clarifai), using factory patterns.
• backend/config/ – server config, CORS, middleware, Swagger, Jest setup.
• frontend/ – React src/ folder organized by components (per feature), pages, services (API call abstractions), config, assets, theme.
• CI/CD & infra configs: .github/workflows, vercel.json, sonar‐project.properties.
• erd/ERD.md – entity relationship definitions for MongoDB collections.
README for Insights
• Modules described:
• Recipe Discovery (search/filter history)
• Meal Planning (weekly plans + shopping lists)
• Nutritional Analysis (AI nutrition breakdown)
• Food Recognition (image upload → Clarifai/Gemini)
• User Management (Firebase Auth, profiles)
• Analytics & Insights (dashboards)
• Tech stack: Node, Express, MongoDB/Mongoose, Firebase, Spoonacular, Gemini, Clarifai; React, Chakra UI, Framer Motion; Jest tests; GitHub Actions; Vercel deploy; SonarCloud & Snyk security.
Main Components & Their Interactions
a. Frontend (React App)
– UI pages & feature‐specific components call REST endpoints via API abstraction (frontend/src/services/APIcall.js).
b. API Gateway (Express server)
– Single Node process (server.js) loads multiple domain routers (backend/apps/**/routes.js), applies global middleware (backend/config/middleware.js) and CORS (backend/config/cors.js).
c. Domain Modules
– Each “apps” folder encapsulates its own routes → controllers → DB layer (via Mongoose models in libraries/models/*.js) → utilities and middleware for validation, file uploads, etc.
d. Database
– MongoDB accessed through Mongoose. Collections modeled under backend/libraries/models.
e. External Services
– Firebase (Auth + image storage)
– Spoonacular API (recipe & nutrition data)
– Gemini & Clarifai (vision and chat AI services via service‐factory patterns)
f. Testing & CI
– Jest tests alongside each app.
– GitHub Actions → runs CI, SonarCloud analysis, deploys frontend to Vercel, backend serverless (vercel.json).
Architectural Patterns & Design Principles
• Modular monolith backend: domain‐centric apps with clear API boundaries.
• MVC‐style within each module: routes → controllers → services → data models.
• Factory pattern for pluggable AI services (chatFactory, visionFactory).
• Shared libraries to avoid duplication (models, common services).
• Component‐based frontend with separation of concerns (UI, data‐fetching, state).