# tejasshinkar12/eat-fit-1 architecture

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

- Interactive diagram: https://gitdiagram.com/tejasshinkar12/eat-fit-1
- Repository: https://github.com/tejasshinkar12/eat-fit-1

## Overview

##### Project type and purpose
- PantryFit is a mobile-first full-stack application: a React Native frontend (TypeScript) communicating with a FastAPI backend (Python), backed by PostgreSQL, and augmented by specialized ML services (image processing, recipe generation, text Q&A).

##### File structure
- Top-level folders:
- docs/ – detailed design, flows, tech stack
- src/frontend/ – React Native app
- src/backend/ – FastAPI app + database migrations (Alembic)
- (README hints at src/ml_services/, but the file tree omits it; treat ML modules as separate services)
- Backend uses Alembic for migrations, exposes OpenAPI docs, reads .env for JWT and DB config.
- Frontend uses React Native with contexts (AuthContext), navigation, and a TypeScript project structure.

##### README for additional insights
- Core features (inventory ingestion, calorie tracking, recipe gen, reports) identify the main functional modules.
- ML services are distinct technical components:
- Image Processing (Detectron2 + TrOCR)
- Recipe Generation (Flan-T5)
- Text Q&A

a. Main components
- Mobile Client (React Native app)
- Backend API (FastAPI)
- Relational Database (PostgreSQL)
- ML Microservices (3 separate services)
- Authentication & Security (JWT, bcrypt)
- External Storage (if images are stored on S3 or similar—add as needed)
b. Relationships and interactions
- Client ↔ API: all user-driven actions (login, inventory CRUD, recipe requests)
- API ↔ DB: read/write user profiles, inventory, nutrition logs, reports
- API → ML Services:
- Image upload endpoint calls Image Processing service → returns detected items
- Recipe endpoint calls Recipe Generation service → returns suggestions
- Q&A endpoint calls Text Q&A service
c. Architectural patterns
- Layered (Mobile UI → API Layer → Data Layer)
- Microservice pattern for ML components
- JWT-based stateless auth in API layer
- Use of configuration/migration (Alembic) indicates IaC/DevOps awareness
d. Technologies/frameworks
- Frontend: React Native, TypeScript, React Navigation
- Backend: FastAPI, Pydantic models, Alembic migrations
- DB: PostgreSQL
- ML: Detectron2, TrOCR, Flan-T5
- Auth: JWT, bcrypt

##### Detailed component breakdown (suggested grouping)
- Mobile Client
- AuthContext
- Navigation
- Screens: Inventory, Camera, Recipes, Reports
- Backend API
- Routers: auth.py, inventory.py, recipes.py, reports.py
- Services: user_service, inventory_service
- Data Layer: SQLAlchemy models (users, items, logs)
- Database (PostgreSQL)
- Tables: users, inventory_items, nutrition_logs, recipes
- ML Services (as separate deployable units)
- Image Processing Service
- Recipe Generation Service
- Text QA Service
- External components (optional)
- Object store (e.g., AWS S3) for image uploads
- Monitoring/Logging (e.g., Prometheus, Grafana)

##### Final advice
- Be granular but avoid clutter: start high-level, then drill into sub-components in a second view.
- Notes or callouts for important patterns (JWT stateless auth, database migrations).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Mobile Client Layer
    subgraph "Mobile Client" 
        style Mobile Client fill:#e0f7fa,stroke:#006064,stroke-width:2px
        RNApp["React Native App"]:::client
        AuthContext["AuthContext"]:::client
        AppNavigator["AppNavigator"]:::client
    end

    %% Backend Services Layer
    subgraph "Backend Services"
        style Backend Services fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px
        API["FastAPI + Alembic"]:::backend
        DBConfig["DB Session & Config"]:::backend
        ORMModels["ORM & Pydantic Models"]:::backend
        AlembicConfig["Alembic Migrations"]:::backend
    end

    %% Database
    DB[(PostgreSQL)]:::db

    %% ML Microservices
    subgraph "ML Microservices"
        style ML Microservices fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
        ImgService["Image Processing\n(Detectron2 + TrOCR)"]:::ml
        RecipeService["Recipe Generation\n(Flan-T5)"]:::ml
        QAService["Text Q&A Service"]:::ml
    end

    %% Documentation
    Docs["Project Documentation"]:::docs

    %% Connections
    RNApp -->|"POST /auth/login\nGET /auth/*"| API
    RNApp -->|"GET /inventory\nPOST /recipes\nGET /reports"| API
    AuthContext -->|uses| RNApp
    AppNavigator -->|routes| RNApp

    API -->|reads/writes| DBConfig
    DBConfig -->|session| DB
    API -->|uses| ORMModels
    API -->|runs migrations| AlembicConfig

    API -->|"POST /upload-image"| ImgService
    API -->|"POST /recipes"| RecipeService
    API -->|"POST /qa"| QAService

    %% Async report generation (batch)
    API -.->|"async batch reports"| DB

    Docs --- RNApp
    Docs --- API

    %% Click Events
    click RNApp "https://github.com/tejasshinkar12/eat-fit-1/tree/main/src/frontend/"
    click AuthContext "https://github.com/tejasshinkar12/eat-fit-1/blob/main/src/frontend/src/contexts/AuthContext.tsx"
    click AppNavigator "https://github.com/tejasshinkar12/eat-fit-1/blob/main/src/frontend/src/navigation/AppNavigator.tsx"
    click API "https://github.com/tejasshinkar12/eat-fit-1/tree/main/src/backend/app/"
    click DBConfig "https://github.com/tejasshinkar12/eat-fit-1/tree/main/src/backend/app/db/"
    click ORMModels "https://github.com/tejasshinkar12/eat-fit-1/tree/main/src/backend/app/models/"
    click AlembicConfig "https://github.com/tejasshinkar12/eat-fit-1/blob/main/src/backend/alembic.ini"
    click Docs "https://github.com/tejasshinkar12/eat-fit-1/tree/main/docs/"

    %% Styles
    classDef client fill:#b3e5fc,stroke:#0277bd,color:#000;
    classDef backend fill:#c8e6c9,stroke:#2e7d32,color:#000;
    classDef db fill:#ffe0b2,stroke:#ef6c00,color:#000,stroke-width:2px;
    classDef ml fill:#e1bee7,stroke:#6a1b9a,color:#000;
    classDef docs fill:#f5f5f5,stroke:#9e9e9e,color:#000,stroke-dasharray: 5 5;
```
