# garvit-nag/reciperover-production architecture

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

- Interactive diagram: https://gitdiagram.com/garvit-nag/reciperover-production
- Repository: https://github.com/garvit-nag/reciperover-production

## Overview

##### Recognize the Project Purpose and Components
- RecipeRover is a full-stack application for recipe management and discovery.
- Its core elements include a Next.js-based frontend with React and Tailwind CSS, a Python backend building the API and business logic, and MongoDB as the database.
- Deployment is split: the frontend is deployed on Vercel and the backend is hosted on Hugging Face Spaces.

##### Main Components
- Frontend:
- Next.js Application: Found under the “src” directory with pages such as “about”, “contact”, “dashboard”, “recipes”, and “recommendations”.
- UI Components: Both under “src/components” and “components/ui” for repeated widgets (e.g., Navbar, cards, loaders etc.).
- Static Assets: “public” directory encompasses static files.
- Backend:
- API Server: The backend folder (specifically “backend/app”) houses the API routing (e.g., api/routes.py) and startup (main.py).
- Services and Business Logic: Within “backend/app/services” (e.g., extraction, image search, recommendation) and “backend/app/utils” (data loading, preprocessing, recommendation utils, scrapers, similarity_calculation).
- Models: In “backend/app/models” which defines recipe-related data structures.
- Database:
- MongoDB: Integration is visible in “src/lib/mongodb.ts” with configuration details for the database.
- Deployment:
- Frontend on Vercel.
- Backend deployed on Hugging Face Spaces.
- Supporting Files:
- Configuration files (e.g., tailwind.config.ts, tsconfig.json, .eslintrc.json) underline environment and build dependencies.
- Package and dependency management: “package.json”, “requirements.txt” for Node.js and Python respectively.

##### Relationships and Data Flow
- Frontend interacts with the backend API endpoints to perform operations such as searching recipes, handling ingredient management, and querying recommendations.
- The backend consumes incoming API requests, processes them through various service layers (e.g., extraction, image query, recommendation) and accesses the database (MongoDB) for storing and retrieving data.
- Utility modules like scrapers perform external data extraction which then feeds into the recommendation and image search functionalities.
- Deployment nodes influence the routing and scalability – with Vercel handling the frontend's performance optimization and Hugging Face Spaces managing the backend’s execution environment.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clear separation between presentation (Next.js pages/components), business logic (Python backend services), and data access (MongoDB).
- Micro-modularity: Within the backend, services are organized by distinct functionalities (data preprocessing, feature engineering, and various scraping tasks).
- Clear API contracts: Frontend calls RESTful API endpoints provided by the backend (as seen in “backend/app/api/routes.py” and in “src/app/api” for frontend-side interactions).
- Maintainability and Extensibility: Separation of concerns in file organization (e.g., splitting scraping into multiple files) ensures clear boundaries.

##### Including Specifics
- Clear labels for each component with notations such as “API Routes”, “Service Modules”, and “Database Connector”.
- User actions → Frontend pages/ components.
- Frontend API calls → Backend API endpoints.
- Data flow → Backend service interactions with the Database.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Global User
    U("User"):::external

    %% Frontend Subgraph
    subgraph "Frontend (Next.js, React, Tailwind CSS)"
        FNA("Next.js App"):::frontend
        FP1("About Page"):::frontend
        FP2("Contact Page"):::frontend
        FP3("Dashboard Page"):::frontend
        FP4("Recipes Page"):::frontend
        FP5("Recommendations Page"):::frontend
        FC1("Navbar Component"):::frontend
        FC2("3D Card Component"):::frontend
        PSA("Public Assets"):::frontend
    end

    %% Backend API Subgraph
    subgraph "Backend API (Python, FastAPI)"
        BA1("API Routes"):::backend
        BA2("Main Startup"):::backend
        BM("Recipe Model"):::backend
        
        subgraph "Services"
            BS1("Extraction Service"):::backend
            BS2("Image Query Service"):::backend
            BS3("Image Search Service"):::backend
            BS4("Recommendation Service"):::backend
        end
        
        subgraph "Utility Modules"
            BU1("Data Loading"):::backend
            BU2("Data Preprocessing"):::backend
            BU3("Feature Engineering"):::backend
            BU4("Recommendation Utils"):::backend
            BU5("Similarity Calculation"):::backend
            BU6("Scrapers"):::backend
        end
    end

    %% Database Node
    MDB(["MongoDB Database"]):::database

    %% Deployment and Configuration Subgraph
    subgraph "Deployment & Configuration"
        D1("Frontend Deployment (Vercel)"):::deployment
        D2("Backend Deployment (Hugging Face Spaces)"):::deployment
        DC1("Tailwind Config"):::deployment
        DC2("TypeScript Config"):::deployment
        DC3("ESLint Config"):::deployment
        DC4("Package.json"):::deployment
        DC5("Backend Requirements"):::deployment
    end

    %% Relationships
    U --> FNA
    FNA -->|"API_call"| BA1
    BA1 -->|"queries"| MDB

    %% Frontend Pages and UI Components (no directional flow; details)
    FNA --- FP1
    FNA --- FP2
    FNA --- FP3
    FNA --- FP4
    FNA --- FP5
    FNA --- FC1
    FNA --- FC2
    FNA --- PSA

    %% Backend internal relationships
    BA1 -->|"uses"| BS1
    BA1 -->|"uses"| BS2
    BA1 -->|"uses"| BS3
    BA1 -->|"uses"| BS4

    BS1 -->|"calls"| BU6
    BS4 -->|"utilizes"| BU4

    %% Deployment relationships
    FNA -->|"deployed_to"| D1
    BA1 -->|"deployed_to"| D2

    %% Click Events for Frontend
    click FP1 "https://github.com/garvit-nag/reciperover-production/blob/main/src/app/about/page.tsx"
    click FP2 "https://github.com/garvit-nag/reciperover-production/blob/main/src/app/contact/page.tsx"
    click FP3 "https://github.com/garvit-nag/reciperover-production/blob/main/src/app/dashboard/page.tsx"
    click FP4 "https://github.com/garvit-nag/reciperover-production/blob/main/src/app/recipes/page.tsx"
    click FP5 "https://github.com/garvit-nag/reciperover-production/blob/main/src/app/recommendations/page.tsx"
    click FC1 "https://github.com/garvit-nag/reciperover-production/blob/main/src/components/Navbar.tsx"
    click FC2 "https://github.com/garvit-nag/reciperover-production/blob/main/src/components/ui/3d-card.tsx"
    click PSA "https://github.com/garvit-nag/reciperover-production/tree/main/public"

    %% Click Events for Backend API
    click BA1 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/api/routes.py"
    click BA2 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/main.py"
    click BM "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/models/recipe.py"
    
    %% Click Events for Backend Services
    click BS1 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/services/extraction.py"
    click BS2 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/services/image_query.py"
    click BS3 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/services/image_search.py"
    click BS4 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/services/recommendation.py"
    
    %% Click Events for Utility Modules
    click BU1 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/utils/data_loading.py"
    click BU2 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/utils/data_preprocessing.py"
    click BU3 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/utils/feature_engineering.py"
    click BU4 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/utils/recommendation_utils.py"
    click BU5 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/app/utils/similarity_calculation.py"
    click BU6 "https://github.com/garvit-nag/reciperover-production/tree/main/backend/app/utils/scrapers"

    %% Click Event for Database Integration
    click MDB "https://github.com/garvit-nag/reciperover-production/blob/main/src/lib/mongodb.ts"

    %% Click Events for Deployment & Configuration
    click D1 "https://github.com/garvit-nag/reciperover-production/blob/main/.vercelignore"
    click D2 "https://github.com/garvit-nag/reciperover-production/blob/main/backend/requirements.txt"
    click DC1 "https://github.com/garvit-nag/reciperover-production/blob/main/tailwind.config.ts"
    click DC2 "https://github.com/garvit-nag/reciperover-production/blob/main/tsconfig.json"
    click DC3 "https://github.com/garvit-nag/reciperover-production/blob/main/.eslintrc.json"
    click DC4 "https://github.com/garvit-nag/reciperover-production/blob/main/package.json"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef deployment fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px,stroke-dasharray: 5 5;
```
