# rahulreddyp/lettuce-eat-restaurant-application architecture

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

- Interactive diagram: https://gitdiagram.com/rahulreddyp/lettuce-eat-restaurant-application
- Repository: https://github.com/rahulreddyp/lettuce-eat-restaurant-application

## Overview

##### Main Components
- Client (Frontend):
- Built with React (create-react-app) using frameworks like React-Bootstrap and Material UI for the UI.
- Contains separate modules for routing, shared components (header, footer), pages (e.g., HomeScreen, Login, Signup, Menu, Cart, Admin, etc.), and API calls (organized inside the “apicalls” folder).
- Server (Backend):
- Developed in Node.js with Express, handling API endpoints via controllers and routes (e.g., user, menu, cart, payment, coupon, feedback, order, wishlist, etc.).
- Uses MongoDB (via Mongoose models) for data management.
- Integrates with AWS S3 for file uploads and retrieval (as seen in menu controllers).
- Database:
- External Services/Integrations:
- AWS S3 for storage.
- Heroku for deployment.
- Authentication using JWT tokens.

##### Relationship & Interactions
- The Client sends RESTful API calls (organized in the apicalls folder) to the Server.
- The Server routes these requests to the appropriate controllers which handle business logic, perform validation (using libraries like Yup and react-hook-form on the client side), and interact with the Database via Mongoose models.
- For file uploads (e.g., menu images), the Server integrates with AWS S3 (uploading and retrieving images) as part of the menu controllers.
- The admin portal (secured through JWT authentication with a dedicated login route) allows administrative management such as updating menus, user management, or coupon creation.

##### Architectural Patterns & Technologies
- MVC Pattern on the backend: The “models”, “controllers”, and “routes” directories clearly indicate an MVC approach.
- Separation of Concerns: Frontend and backend code are separated into the “client” and “server” directories; within the frontend, components, API calls, and asset directories are clearly split.
- RESTful API Design and JWT-based authentication as shown in the user and menu controllers.
- Integration with cloud services (AWS S3 for file storage and Heroku for deployment).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side Subgraph
    subgraph "Client (React Frontend)"
        CF1["React Frontend – General App"]
        CF2["API Calls Module"]
        CF3["Shared UI – Header"]
        CF4["Shared UI – Footer"]
        CF5["Page Components"]
        CF6["Payment Components"]
    end

    %% Server Side Subgraph
    subgraph "Server (Express Backend)"
        SB2["Routing Modules"]
        SB3["Backend Middlewares"]
        SB1["Controllers"]
        SB4["Data Models"]
        SB5["Config & Integrations"]
    end

    %% External & Database Components
    DB1(["MongoDB – Data Storage"])
    EX1(["AWS S3 – File Storage"])
    EX2(["Heroku – Deployment"])

    %% Relationships between Client and Server layers
    CF2 -->|"APIRequests"| SB2

    %% Relationships within Server: Routing to Controllers and Middlewares
    SB2 -->|"RouteHandling"| SB1
    SB2 -->|"JWTAuth"| SB3

    %% Controller interactions with Database and AWS S3
    SB1 -->|"CRUDOperations"| SB4
    SB4 -->|"DataQuery"| DB1
    SB1 -->|"FileUpload/Retrieval"| EX1

    %% Configurations connecting to external services
    SB5 -->|"DBConnection"| DB1
    SB5 -->|"S3Integration"| EX1

    %% Deployment relationship
    SB5 -->|"Deployment"| EX2

    %% Click Events for Frontend Components
    click CF1 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/tree/main/client/src" " "
    click CF2 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/tree/main/client/src/apicalls" " "
    click CF3 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/blob/main/client/src/components/Header.js" " "
    click CF4 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/blob/main/client/src/components/Footer.js" " "
    click CF5 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/tree/main/client/src/components/pages" " "
    click CF6 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/tree/main/client/src/components/paymentscomponents" " "

    %% Click Events for Backend Components
    click SB1 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/tree/main/server/controllers" " "
    click SB2 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/tree/main/server/routes" " "
    click SB4 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/tree/main/server/models" " "
    click SB5 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/blob/main/server/config/aws.config.js" " "
    click SB5 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/blob/main/server/config/db.config.js" " "
    click SB3 "https://github.com/rahulreddyp/lettuce-eat-restaurant-application/tree/main/server/middlewares" " "

    %% Styles
    class CF1,CF2,CF3,CF4,CF5,CF6 frontend
    class SB1,SB2,SB3,SB4,SB5 backend
    class DB1 database
    class EX1,EX2 external

    %% Class Definitions
    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef database fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef external fill:#FFCCBC,stroke:#D84315,stroke-width:2px;
```
