# manthann07/msu-footprint architecture

> Architecture diagram of the GitHub repository manthann07/msu-footprint, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manthann07/msu-footprint
- Repository: https://github.com/manthann07/msu-footprint

## Overview

##### Project type and purpose
- This is a full-stack “Meal Planner Platform” composed of a React/Tailwind frontend and a Node/Express backend.
- Purpose: provide personalized meal plans, BMI calculation, and an AI assistant (via Gemini API) to suggest meals and nutritional information.

##### File structure
- Top level splits into two directories:
- nutrition-planner-frontend (Vite + React, Tailwind, context providers, pages/components)
- nutrition-planner-backend (Express API, MongoDB config, auth middleware, routes, User model)
- Key config files: .env files, vite.config.js (frontend), config/db.js, server.js (backend).
- Patterns:
- Frontend uses Context API (AuthContext, MealPlanContext), routing (ProtectedRoute.jsx).
- Backend follows a simple MVC style: routes ↔ controllers (in routes/), models/ (User.js), middleware/auth for JWT validation.

##### README insights
- Architecture overview: React frontend ↔ Node/Express REST API ↔ MongoDB database, plus external AI (Gemini API).
- Auth with JWT.
- Environment variables orchestrate API endpoints and secrets.

##### Elements
- Clear labels: “React Client,” “Express API,” “MongoDB,” “Gemini AI Service”
- UI → API (requests)
- API → DB (CRUD)
- API → AI (HTTP call)
- API → UI (responses)
- Backend components in another (e.g., green)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Front-end (React/Vite/Tailwind)" 
        FE["React Client (src)"]:::frontend
        App["App.jsx"]:::frontend
        AuthCtx["AuthContext.jsx"]:::frontend
        MealCtx["MealPlanContext.jsx"]:::frontend
        Protected["ProtectedRoute.jsx"]:::frontend
        Pages["Pages (.jsx files)"]:::frontend
        Config["vite.config.js"]:::frontend
        EnvFE[".env (frontend)"]:::backend
    end

    subgraph "Back-end (Node/Express)" 
        Server["server.js"]:::backend
        DBConn["config/db.js"]:::backend
        AuthMw["middleware/auth.js"]:::backend
        UserModel["models/User.js"]:::backend
        AuthRoutes["routes/authRoutes.js"]:::backend
        AuthCtrl["routes/auth.js"]:::backend
        EnvBE[".env"]:::backend
    end

    DB["MongoDB"]:::db
    AI["Gemini AI Service"]:::external

    FE -->|"HTTP Requests (JWT)"| Server
    Server -->|"Connects"| DB
    Server -->|"API Call"| AI
    AI -->|"Response"| Server
    Server -->|"Responses"| FE

    click FE "https://github.com/manthann07/msu-footprint/tree/main/nutrition-planner-frontend/src"
    click App "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-frontend/src/App.jsx"
    click AuthCtx "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-frontend/src/context/AuthContext.jsx"
    click MealCtx "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-frontend/src/context/MealPlanContext.jsx"
    click Protected "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-frontend/src/components/ProtectedRoute.jsx"
    click Pages "https://github.com/manthann07/msu-footprint/tree/main/nutrition-planner-frontend/src/pages"
    click Config "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-frontend/vite.config.js"
    click EnvFE "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-frontend/.env"
    click Server "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-backend/server.js"
    click DBConn "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-backend/config/db.js"
    click AuthMw "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-backend/middleware/auth.js"
    click UserModel "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-backend/models/User.js"
    click AuthRoutes "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-backend/routes/authRoutes.js"
    click AuthCtrl "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-backend/routes/auth.js"
    click EnvBE "https://github.com/manthann07/msu-footprint/blob/main/nutrition-planner-backend/.env"

    classDef frontend fill:#A8D0E6,stroke:#333,stroke-width:1px
    classDef backend fill:#C0F2BD,stroke:#333,stroke-width:1px
    classDef db fill:#F9D5E5,stroke:#333,stroke-width:1px,shape:cylinder
    classDef external fill:#FFE680,stroke:#333,stroke-width:1px,shape:cloud
```
