# abdullahalnoman003/food-khazana-client architecture

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

- Interactive diagram: https://gitdiagram.com/abdullahalnoman003/food-khazana-client
- Repository: https://github.com/abdullahalnoman003/food-khazana-client

## Overview

##### Project Type and Purpose
- This is a full-stack, single-page React application (“Food Khazana”) for recipe management.
- Users authenticate (email/password + Google) via Firebase, then perform CRUD on recipes through a custom Node/Express REST API, which persists data in MongoDB Atlas.

##### Core Components
a. Frontend (React SPA)
- UI Components:
- Nav+Footer (Navbar, Footer, ThemeToggle)
- Home (Hero, HomeSlider, HomeRecipes, Ratings, WhyUs)
- FoodSection (AllRecipes, AddRecipes, MyRecipes, FoodDetails, UpdateRecipe)
- Auth (Login, Register, ForgotPassword, PrivateRoute, PublicRoute)
- Errorpage (NotFound)
- State & Routing:
- AuthContext/AuthProvider – manages user session and Firebase calls
- React Router (router.jsx) – defines PublicRoute vs PrivateRoute for protected pages
b. Authentication Service
- Firebase Authentication (email/password + Google)
c. Backend API
- Node.js + Express.js REST API
- Endpoints for recipes: GET /recipes, GET /recipes/:id, POST /recipes, PUT /recipes/:id, DELETE /recipes/:id
- CORS, dotenv for config
d. Database
- MongoDB Atlas – stores user-linked recipe documents
e. Deployment & Hosting
- Frontend: Vercel (static hosting + CDN)
- Backend: your choice (could be Vercel Serverless Functions, Heroku, AWS, etc.)

##### Relationships & Data Flows
- User Browser ↔ React SPA (UI interactions, route changes)
- React SPA ↔ Firebase Auth (login, signup, token management)
- React SPA ↔ Node/Express API (authenticated CRUD calls carrying Firebase JWT)
- Node/Express API ↔ MongoDB Atlas (data persistence)

##### Architectural Patterns & Design Principles
- SPA (client-centric rendering, client-side routing)
- Client-Server REST pattern (React ↔ Express)
- Context API for global auth state
- Protected Routes (PublicRoute vs PrivateRoute)
- Modular component hierarchy (Auth, FoodSection, Home, Layout)
- Separation of concerns (presentation vs service vs data layers)

##### Final Recommendations
- Data flow with arrowheads and label: “POST /recipes”, “GET /recipes/:id”, “PUT /recipes/:id”.
- Keep it at two abstraction levels:
- High-level: Frontend, Auth Service, API, Database
- Mid-level (optional zoom): component groups inside Frontend and endpoint list inside API

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Deployment Boundary
    subgraph "Deployment (Vercel)" 
        direction TB
        %% Frontend
        subgraph "Frontend (React SPA)"
            direction TB
            Main["main.jsx"]:::frontend
            App["App.jsx"]:::frontend
            Router["router.jsx"]:::frontend
            AuthContext["AuthContext.jsx"]:::frontend
            AuthProvider["AuthProvider.jsx"]:::frontend

            subgraph "Nav+Footer"
                direction TB
                Navbar["Navbar.jsx"]:::frontend
                Footer["Footer.jsx"]:::frontend
                ThemeToggle["ThemeToggle.jsx"]:::frontend
            end

            subgraph "Home"
                direction TB
                Hero["Hero.jsx"]:::frontend
                HomeSlider["HomeSlider.jsx"]:::frontend
                HomeRecipes["HomeRecipes.jsx"]:::frontend
                Ratings["Ratings.jsx"]:::frontend
                WhyUs["WhyUs.jsx"]:::frontend
            end

            subgraph "FoodSection"
                direction TB
                AllRecipes["AllRecipes.jsx"]:::frontend
                AddRecipes["AddRecipes.jsx"]:::frontend
                MyRecipes["MyRecipes.jsx"]:::frontend
                FoodDetails["FoodDetails.jsx"]:::frontend
                UpdateRecipe["UpdateRecipe.jsx"]:::frontend
            end

            subgraph "Auth"
                direction TB
                Login["Login.jsx"]:::frontend
                Register["Register.jsx"]:::frontend
                ForgotPassword["ForgotPassword.jsx"]:::frontend
                PrivateRoute["PrivateRoute.jsx"]:::frontend
                PublicRoute["PublicRoute.jsx"]:::frontend
            end

            subgraph "Errorpage"
                direction TB
                Animation404["Animation404.json"]:::frontend
                NotFound["NotFound.jsx"]:::frontend
            end

            FirebaseInit["firebase.init.js"]:::frontend
            PublicRedirects["_redirects"]:::frontend
        end

        %% Backend
        subgraph "Backend API (Node/Express)"
            direction TB
            API["Express API"]:::backend
            GET_ALL["GET /recipes"]:::backend
            GET_ID["GET /recipes/:id"]:::backend
            POST_RE["POST /recipes"]:::backend
            PUT_RE["PUT /recipes/:id"]:::backend
            DEL_RE["DELETE /recipes/:id"]:::backend
        end
    end

    %% External Services and DB
    UserBrowser((User Browser)):::external
    Firebase(("Firebase Auth")):::external
    Mongo[(MongoDB Atlas)]:::db

    %% Flows
    UserBrowser -->|Uses SPA| Main
    Main -->|Renders| App
    App -->|Routes via| Router
    App -->|Manages auth state| AuthContext
    AuthContext -->|Provides context| AuthProvider

    App -->|"authenticate via HTTPS"| Firebase
    App -->|"CRUD via HTTPS/REST (Bearer JWT)"| API

    API -->|"read/write"| Mongo

    %% Click Events
    click Navbar "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Nav+Footer/Navbar.jsx"
    click Footer "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Nav+Footer/Footer.jsx"
    click ThemeToggle "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Nav+Footer/ThemeToggle.jsx"
    click Hero "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Home/Hero.jsx"
    click HomeSlider "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Home/HomeSlider.jsx"
    click HomeRecipes "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Home/HomeRecipes.jsx"
    click Ratings "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Home/Ratings.jsx"
    click WhyUs "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Home/WhyUs.jsx"
    click AllRecipes "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/FoodSection/AllRecipes.jsx"
    click AddRecipes "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/FoodSection/AddRecipes.jsx"
    click MyRecipes "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/FoodSection/MyRecipes.jsx"
    click FoodDetails "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/FoodSection/FoodDetails.jsx"
    click UpdateRecipe "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/FoodSection/UpdateRecipe.jsx"
    click Login "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Auth/Login.jsx"
    click Register "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Auth/Register.jsx"
    click ForgotPassword "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Auth/ForgotPassword.jsx"
    click PrivateRoute "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Auth/PrivateRoute.jsx"
    click PublicRoute "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Auth/PublicRoute.jsx"
    click AuthContext "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Auth/AuthContext.jsx"
    click AuthProvider "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Auth/AuthProvider.jsx"
    click FirebaseInit "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/firebase/firebase.init.js"
    click Router "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/routes/router.jsx"
    click Main "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/main.jsx"
    click App "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/App.jsx"
    click Animation404 "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Errorpage/Animation404.json"
    click NotFound "https://github.com/abdullahalnoman003/food-khazana-client/blob/main/src/components/Errorpage/NotFound.jsx"
    click PublicRedirects "https://github.com/abdullahalnoman003/food-khazana-client/tree/main/public/_redirects"

    %% Styles
    classDef frontend fill:#D6EAFE,stroke:#1E90FF,stroke-width:1px
    classDef backend fill:#D4F8E8,stroke:#28A745,stroke-width:1px
    classDef db fill:#FFE5B4,stroke:#FF8C00,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#A9A9A9,stroke-width:1px
    classDef deployment stroke-dasharray: 5 5,fill:none,stroke:#000000,stroke-width:1px
```
