# sanjitvijay/nutrinav architecture

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

- Interactive diagram: https://gitdiagram.com/sanjitvijay/nutrinav
- Repository: https://github.com/sanjitvijay/nutrinav

## Overview

##### Project Type and Purpose
- NutriNav is an all-in-one platform designed to track nutritional information from campus dining halls. It enables users to add foods (automatically or manually) and monitor calories and macros.
- The project is built as a full-stack application, with a React frontend (using TailwindCSS and DaisyUI for components) and a separate backend (Node.js and Express.js) that handles functions like authentication (powered by Supabase Auth), web parsing (Cheerios), and scheduling (Render Cron Scheduler).

##### File Structure
- The file tree provided is for the frontend portion:
- Top-level files include package.json, package-lock.json, and configuration files like tailwind.config.js.
- The public directory contains static assets (index.html, manifest, robots.txt).
- The src directory includes the React application:
- App components (e.g., App.js, various CSS and test files).
- Assets and reusable components located in “src/components” such as navigation bars, custom dropdowns, auth modules, and content display components.
- Context providers in “src/context” (AuthProvider, UserInfoProvider, etc.) managing shared state.
- Various pages for different functionalities (Dashboard, SignIn, SignUp, ScannerPage, etc.).
- Utility files like supabaseClient.js denote integration with Supabase for authentication/data handling.
- These indicate a component-based architecture for the frontend with clear separation of concerns by pages, shared components (UI elements), and context state management.

##### Architectural Points from the README
- The README outlines both the frontend and backend tech stacks, inviting us to consider components like:
- Frontend: React with TailwindCSS, DaisyUI, and Figma designs.
- Backend: Node.js and Express.js paired with a PostgreSQL database.
- External integrations: Supabase Auth and additional parsing and scheduling services.

a. Main Components:
- Frontend (React Application)
- UI Components: Navigation bars, dropdowns, auth-related components, food log displays.
- Pages: Dashboard, AddFood, CalorieCalc, ManualEntryForm, ScannerPage, etc.
- Context Providers: AuthProvider and UserInfoProvider for global state, including user authentication and information.
- Backend Services (separate repository as per README)
- Node.js/Express.js API layer for business logic.
- Authentication & Authorization via Supabase Auth.
- Data Processing: Web parser (Cheerios) and scheduled tasks (Render Cron Scheduler).
- Database:
- PostgreSQL for persistent storage.
- External Services:
- Integration with third-party libraries/services such as Google Auth and possibly future AI recommendation modules.

b. Relationships and Interactions:
- The Frontend communicates with the Backend through defined API endpoints.
- The Backend handles authentication (using Supabase Auth) and communicates with the PostgreSQL database.
- The Frontend interacts with external libraries (e.g., for Google Authentication or data visualization).
- Any scheduled processing (e.g., cron jobs on the backend) interacts with the database to update records.

c. Architectural Patterns and Design Principles:
- Component-based architecture in the frontend (React’s modular design).
- Separation of concerns: Clear boundaries between UI, business logic, and data storage.
- Use of context providers in React for shared application state (global auth and user info).
- RESTful API design in the backend.
- Scalability aspects through modular backend services (parsing, authentication, scheduling).

d. Relevant Technologies and Frameworks:
- Frontend: React.js, TailwindCSS, DaisyUI.
- Backend: Node.js, Express.js, Cheerios, Supabase Auth, Render Cron Scheduler.
- Database: PostgreSQL.
- Additional: Figma for design prototypes and possible integration of Google authentication.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["User (Browser)"]:::external

    subgraph "NutriNav Frontend (React)"
        direction TB
        F1["React App"]:::frontend
        F2["Static Assets"]:::frontend
        subgraph "Pages"
            direction TB
            P1["Dashboard Page"]:::frontend
            P2["Add Food Page"]:::frontend
            P3["Calorie Calculator"]:::frontend
            P4["Manual Entry Form"]:::frontend
            P5["Sign In Page"]:::frontend
            P6["Sign Up Page"]:::frontend
            P7["Scanner Page"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            U1["Navigation Components"]:::frontend
            U2["GoogleAuth"]:::frontend
            U3["AuthRoute"]:::frontend
            U4["Food Log Components"]:::frontend
            U5["Barcode Scanner Component"]:::frontend
        end
        subgraph "Context Providers"
            direction TB
            C1["AuthProvider"]:::frontend
            C2["UserInfoProvider"]:::frontend
        end
        F3["Supabase Integration"]:::frontend
    end

    subgraph "NutriNav Backend"
        direction TB
        B1["Express API"]:::backend
        B2["Supabase Auth"]:::backend
        B3["Data Processing Module"]:::backend
        B4["PostgreSQL Database"]:::database
    end

    subgraph "External Services"
        direction TB
        E1["Google Auth Service"]:::external
    end

    A -->|"uses"| F1
    A -->|"loads"| F2

    F1 -->|"renders"| P1
    F1 -->|"renders"| P2
    F1 -->|"renders"| P3
    F1 -->|"renders"| P4
    F1 -->|"renders"| P5
    F1 -->|"renders"| P6
    F1 -->|"renders"| P7
    F1 -->|"includes"| U1
    F1 -->|"includes"| U2
    F1 -->|"includes"| U3
    F1 -->|"includes"| U4
    F1 -->|"includes"| U5
    F1 -->|"provides"| C1
    F1 -->|"provides"| C2
    F1 -->|"integrates"| F3

    F1 -->|"APIcalls"| B1
    B1 -->|"authcheck"| B2
    B1 -->|"dataprocessing"| B3
    B1 -->|"DBqueries"| B4

    U2 -->|"integrates"| E1
    U5 -->|"triggers"| P7

    click F1 "https://github.com/sanjitvijay/nutrinav/tree/main/src"
    click F2 "https://github.com/sanjitvijay/nutrinav/tree/main/public"
    click U1 "https://github.com/sanjitvijay/nutrinav/tree/main/src/components"
    click U2 "https://github.com/sanjitvijay/nutrinav/blob/main/src/components/GoogleAuth.jsx"
    click U3 "https://github.com/sanjitvijay/nutrinav/blob/main/src/components/AuthRoute.jsx"
    click U4 "https://github.com/sanjitvijay/nutrinav/tree/main/src/components"
    click U5 "https://github.com/sanjitvijay/nutrinav/blob/main/src/components/Scanner.jsx"
    click P1 "https://github.com/sanjitvijay/nutrinav/blob/main/src/pages/Dashboard.jsx"
    click P2 "https://github.com/sanjitvijay/nutrinav/blob/main/src/pages/AddFood.jsx"
    click P3 "https://github.com/sanjitvijay/nutrinav/blob/main/src/pages/CalorieCalc.jsx"
    click P4 "https://github.com/sanjitvijay/nutrinav/blob/main/src/pages/ManualEntryForm.jsx"
    click P5 "https://github.com/sanjitvijay/nutrinav/blob/main/src/pages/SignIn.jsx"
    click P6 "https://github.com/sanjitvijay/nutrinav/blob/main/src/pages/SignUp.jsx"
    click P7 "https://github.com/sanjitvijay/nutrinav/blob/main/src/pages/ScannerPage.jsx"
    click C1 "https://github.com/sanjitvijay/nutrinav/blob/main/src/context/AuthProvider.jsx"
    click C2 "https://github.com/sanjitvijay/nutrinav/blob/main/src/context/UserInfoProvider.jsx"
    click F3 "https://github.com/sanjitvijay/nutrinav/blob/main/src/supabaseClient.js"

    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
