# ssdsai/cuisine-connect architecture

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

- Interactive diagram: https://gitdiagram.com/ssdsai/cuisine-connect
- Repository: https://github.com/ssdsai/cuisine-connect

## Overview

##### Main Components
- Frontend:
- Built with React (see the public folder, src directory, and various UI component subdirectories like Cart, Chat, Checkout, etc.).
- Responsible for rendering user interfaces like Home, Login, Navbar, Carousel, etc.
- Communicates with the backend via API calls (e.g., for order creation, user authentication, chat functionality).

- Backend (Flask):
- The flask_backend directory contains all business logic.
- The “Agents” folder includes specialized modules (e.g., create_orders_agent, fraud_detection_agent, food_recommendation_agent, query_agent, decision_agent) that encapsulate discrete functionalities and decision-making tasks.
- The “Routes” folder (for agent_routes and likely other route definitions) maps API endpoints to business logic operations.
- Other files (Checkout.py, Login.py, Orders.py) focus on core operations such as user login, order management, and checkout processing.
- There is also a “backend” subdirectory that may represent a legacy or additional related module (with its own src folder and uploads) – this might be for file handling or other backend processing.

- Database:
- As specified in the README, a MongoDB database named CuisineConnect is used.
- It contains collections like Logincredentials and Orders.
- The backend integrates with this database for persisting user login details and order data.

- External Services / APIs:
- The README mentions the need for an OpenAPI key, suggesting that external API calls (e.g., for food recommendations or other decision processes) might be integrated into some of the agent modules.

##### Relationships and Interactions
- The React frontend makes HTTP requests (e.g., via REST API calls) that target the Flask backend endpoints (defined under the Routes directory).
- The backend processes these requests, invoking specific agents or modules (for creating orders, detecting fraud, recommending food, etc.) to perform the required business logic.
- Business logic components interact with the MongoDB database to store and retrieve user credentials and orders.
- The Flask backend may also communicate with external services (via the OpenAPI Key) to enrich functionalities like food recommendations.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- The architecture separates presentation (React UI) and business logic (Flask backend agents and routes).
- The Agents modularization reflects a decoupled approach where each agent handles a specific task (e.g., fraud detection, order creation).

- Layered Architecture:
- Presentation Layer (React Frontend)
- API/Controller Layer (Flask Routes)
- Business Logic Layer (Agents and core modules like Checkout, Login, Orders)
- Data Access Layer (MongoDB interactions within the Flask backend)

- Testing:
- Tests are located in the flask_backend/tests directory, indicating an attention to validating key functionalities like agents and routes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React)"
        FE1["Public Assets"]:::frontend
        FE2["UI Components"]:::frontend
        FE3["Main App Logic"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (Flask)"
        %% Core Application & Routing
        subgraph "Core Application & Routing"
            BA1["Main Application"]:::backend
            BA1b["Init File"]:::backend
            BA2["API Routes"]:::backend
        end
        %% Business Logic
        subgraph "Business Logic"
            BL1["Checkout Operations"]:::backend
            BL2["Login Operations"]:::backend
            BL3["Order Management"]:::backend
            BL4["Database Operations"]:::backend
        end
        %% Agents
        subgraph "Agents"
            AG1["Create Orders Agent"]:::agent
            AG2["Decision Agent"]:::agent
            AG3["Fetch Orders Agent"]:::agent
            AG4["Food Recommendation Agent"]:::agent
            AG5["Fraud Detection Agent"]:::agent
            AG6["Query Agent"]:::agent
            AG7["Test Agent"]:::agent
        end
        %% Testing
        subgraph "Testing"
            T1["Agent Tests"]:::test
            T2["Route Tests"]:::test
        end
        %% Uploads Handling
        subgraph "Uploads Handling"
            U1["Uploads Directory (flask_backend)"]:::upload
            U2["Uploads Directory (legacy backend)"]:::upload
        end
    end

    %% Database and External Services
    DB["CuisineConnect Database"]:::database
    EXT["External API Service"]:::external

    %% Relationships and Data Flow
    FE2 -->|"APIcalls"| BA2
    FE3 -->|"APIcalls"| BA2

    BA1 --> BA2
    BA1 --> BA1b

    BA2 -->|"executes"| BL1
    BA2 -->|"executes"| BL2
    BA2 -->|"executes"| BL3
    BA2 -->|"executes"| BL4
    BA2 -->|"delegates"| AG1
    BA2 -->|"delegates"| AG2
    BA2 -->|"delegates"| AG3
    BA2 -->|"delegates"| AG4
    BA2 -->|"delegates"| AG5
    BA2 -->|"delegates"| AG6
    BA2 -->|"delegates"| AG7

    BL4 -->|"persist/retrieve"| DB

    AG1 -->|"interacts"| DB
    AG2 -->|"interacts"| DB
    AG3 -->|"interacts"| DB
    AG4 -->|"interacts"| DB
    AG5 -->|"interacts"| DB
    AG6 -->|"interacts"| DB
    AG7 -->|"interacts"| DB

    AG4 -->|"OpenAPI"| EXT

    BA2 -->|"handles_uploads"| U1
    BA2 -->|"handles_uploads"| U2

    %% Click Events
    click FE1 "https://github.com/ssdsai/cuisine-connect/tree/main/public/"
    click FE2 "https://github.com/ssdsai/cuisine-connect/tree/main/src/Components/"
    click FE3 "https://github.com/ssdsai/cuisine-connect/blob/main/src/App.js"
    click BA1 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/main.py"
    click BA1b "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/__init__.py"
    click BA2 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Routes/agent_routes.py"
    click BL1 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Checkout.py"
    click BL2 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Login.py"
    click BL3 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Orders.py"
    click BL4 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Db.py"
    click AG1 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Agents/craete_orders_agent.py"
    click AG2 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Agents/decision_agent.py"
    click AG3 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Agents/fetch_orders.py"
    click AG4 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Agents/food_recommendation_agent.py"
    click AG5 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Agents/fraud_detection_agent.py"
    click AG6 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Agents/query_agent.py"
    click AG7 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/Agents/test_agent.py"
    click T1 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/tests/test_agents.py"
    click T2 "https://github.com/ssdsai/cuisine-connect/blob/main/flask_backend/tests/test_routes.py"
    click U1 "https://github.com/ssdsai/cuisine-connect/tree/main/flask_backend/uploads"
    click U2 "https://github.com/ssdsai/cuisine-connect/tree/main/flask_backend/backend/src/uploads"

    %% Styling Classes
    classDef frontend fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef agent fill:#eeeeee,stroke:#616161,stroke-width:2px;
    classDef test fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
    classDef upload fill:#f8bbd0,stroke:#c2185b,stroke-width:2px;
    classDef database fill:#d1c4e9,stroke:#512da8,stroke-width:2px;
    classDef external fill:#ffe0b2,stroke:#fb8c00,stroke-width:2px;
```
