# tanmay-tiwaricyber/food-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/tanmay-tiwaricyber/food-tracker
- Repository: https://github.com/tanmay-tiwaricyber/food-tracker

## Overview

##### Project type and purpose
- Food Tracker is a modern full-stack web application built with Next.js (React), Tailwind CSS, and Firebase.
- It lets users log food, track expiry, and get AI-driven recipe & storage tips via the Gemini 2.0 Flash integration.

##### File structure
- app/
- layout.tsx, page.tsx and globals.css under app/ indicate a Next.js 13+ “app” directory structure using React Server Components and Client Components.
- app/api/gemini/route.ts is a serverless API route that handles AI calls to Gemini.
- components/
- UI building blocks and dialog components live in components/ and components/ui/, suggesting a design-system approach.
- hooks/ for shared React hooks (useMobile, useToast)
- lib/ contains firebase.ts (initializes Firebase SDK), localStorage utils, and misc utilities
- scripts/ for environment setup and testing integrations (Firebase, Gemini)
- public/, styles/, tailwind.config.ts for styling & static assets
- types/ for TypeScript data models (e.g., types/food.ts)

##### README for additional insights
- Confirms Next.js, Tailwind CSS, Firebase, TypeScript, and Gemini 2.0 Flash AI integration
- Features: food logging, expiry tracking, AI recipes, storage tips, meal plans

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client: Browser / React App"
        direction TB
        Layout["App Layout & Page"]:::ui
        GlobalsCSS["Global CSS"]:::ui
        subgraph "UI Components"
            direction TB
            Dashboard["Dashboard"]:::ui
            FoodList["Food List View"]:::ui
            AddFood["Add Food Dialog"]:::ui
            EditFood["Edit Food Dialog"]:::ui
            AIFeatures["AI Features Panel"]:::ui
            AuthPage["Authentication Page"]:::ui
            FirebaseNotice["Firebase Config Notice"]:::ui
            ThemeProvider["Theme Provider"]:::ui
        end
        subgraph "Hooks & Client Utils"
            direction TB
            UseMobile["useMobile Hook"]:::hook
            UseToast["useToast Hook"]:::hook
            LocalStorage["localStorage Util"]:::lib
        end
    end

    %% Server Layer
    subgraph "Server: Next.js Serverless API & Backend"
        direction TB
        APIRoute["API Route /api/gemini"]:::lib
        FirebaseLib["Firebase SDK (lib/firebase.ts)"]:::lib
        Utils["Misc Utilities"]:::lib
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Auth["Firebase Auth"]:::external
        Firestore["Firestore DB"]:::db
        Gemini["Gemini 2.0 Flash AI"]:::external
    end

    %% Client Component Flows
    Layout --> Dashboard
    Dashboard --> FoodList
    Dashboard --> AddFood
    Dashboard --> EditFood
    Dashboard --> AIFeatures
    Layout --> AuthPage
    Layout --> FirebaseNotice
    Layout --> ThemeProvider

    %% Hooks & Utils Usage
    FoodList --> UseToast
    AddFood --> UseToast
    EditFood --> UseToast
    AuthPage --> UseMobile

    %% Data Flows
    FoodList -->|"read/write food data"| Firestore
    AddFood -->|"create food item"| Firestore
    EditFood -->|"update food item"| Firestore
    LocalStorage -.->|"cache data"| FoodList
    LocalStorage -.->|"cache prompts/responses"| AIFeatures

    %% AI Flow
    Dashboard --> APIRoute
    AIFeatures --> APIRoute
    APIRoute -->|"fetch AI response"| Gemini
    APIRoute --> FirebaseLib
    FirebaseLib --> Firestore
    FirebaseLib --> Auth
    AuthPage --> Auth

    %% Click Events
    click Layout "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/app/layout.tsx"
    click GlobalsCSS "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/app/globals.css"
    click APIRoute "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/app/api/gemini/route.ts"
    click components/ui/ "https://github.com/tanmay-tiwaricyber/food-tracker/tree/main/components/ui/"
    click AddFood "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/components/add-food-dialog.tsx"
    click EditFood "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/components/edit-food-dialog.tsx"
    click FoodList "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/components/food-list.tsx"
    click AIFeatures "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/components/ai-features.tsx"
    click Dashboard "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/components/dashboard.tsx"
    click AuthPage "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/components/auth-page.tsx"
    click FirebaseNotice "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/components/firebase-config-notice.tsx"
    click ThemeProvider "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/components/theme-provider.tsx"
    click UseMobile "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/hooks/use-mobile.tsx"
    click UseToast "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/hooks/use-toast.tsx"
    click LocalStorage "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/lib/localStorage.ts"
    click FirebaseLib "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/lib/firebase.ts"
    click Utils "https://github.com/tanmay-tiwaricyber/food-tracker/blob/main/lib/utils.ts"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366D6,color:#0366D6,stroke-width:1px;
    classDef hook fill:#E8F4FF,stroke:#0366D6,color:#0366D6,stroke-width:1px;
    classDef lib fill:#E0FFE4,stroke:#028A0F,color:#028A0F,stroke-width:1px;
    classDef external fill:#F0E6FF,stroke:#6F42C1,color:#6F42C1,stroke-width:1px;
    classDef db fill:#D0FFD8,stroke:#22863A,color:#22863A,stroke-width:1px;
```
