# harshiniumesh/zomato-clone-final architecture

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

- Interactive diagram: https://gitdiagram.com/harshiniumesh/zomato-clone-final
- Repository: https://github.com/harshiniumesh/zomato-clone-final

## Overview

##### Project Type and Purpose
- This is a full-stack application built with the MERN stack. The frontend is a React-based client with Redux for state management and TailwindCSS for styling, while the backend is an Express.js server working with MongoDB via Mongoose.
- The system purpose is to allow users to explore restaurants, view details, manage profiles, and handle interactions like bookmarking and cart management.

##### Analyzing the File Structure
- The project is clearly divided into two main parts:
- The “client” directory: Contains the entire React application, with a detailed structure including pages, components, custom hooks, state management (Redux store and slices), modals, and configuration files (like tailwind.config.js and vite.config.js). This indicates the use of component-based UI and state management patterns on the frontend.
- The “server” directory: Houses the Node.js/Express backend with subdirectories for controllers (e.g., authControllers, deliveryControllers), models (e.g., foodModel, deliveryModel, userModel), routes, middlewares (e.g., authMiddleware), and a database configuration. This follows the MVC pattern for structuring server-side business logic.

a. Main Components to Include:
- Frontend (Client):
- UI Components (e.g., Header, Footer, various pages such as HomePage, LoginPage, ProfilePage, DeliveryPage, etc.)
- State management (Redux store, slices and thunks)
- Utilities and configuration (customHooks, utility functions, Tailwind CSS, and Vite configuration)
- Backend (Server):
- API Entry Points (server/index.js and server/app.js)
- Controllers (handling requests related to authentication, deliveries, foods, and user operations)
- Models (representing data structures for deliveries, foods, and users)
- Routes (defining endpoints associated with controllers)
- Middlewares (specifically for authentication)
- Database connection (under server/db)
- External Services:
- MongoDB (for data persistence)
- Cloudinary (for image hosting as mentioned in the README)

b. Relationships and Interactions:
- The Backend uses Controllers to process requests, interact with Models to perform CRUD operations on MongoDB, and may invoke middlewares for security, validation, etc.
- Data flow from MongoDB to the backend, then back to the frontend as JSON responses.

c. Architectural Patterns:
- Use of the MVC pattern on the backend.
- The frontend follows a component-based design with Redux managing global state.
- Use of service layers (thunks) in Redux to handle asynchronous actions.

d. Technologies, Frameworks, and Libraries:
- Frontend: React, Redux, TailwindCSS, possibly ChakraUI (as mentioned in the README), and Vite.
- Backend: Node.js, Express.js, MongoDB and Mongoose for data modeling, with Cloudinary integration.

##### Elements
- Clear labels for each component and sub-component:
- User interactions (clicks, API requests) from the frontend to the backend.
- Integration flows to MongoDB and Cloudinary.
- Detailed annotations where needed (e.g., “API endpoint: /login calls loginController via authMiddleware”).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend (Client)
    subgraph "Frontend (Client)"
        FE_Pages["Pages"] 
        FE_Components["UI Components"]
        FE_Store["State Management"]
        FE_Hooks["Custom Hooks & Utilities"]
        FE_Config["Configuration"]
    end

    %% Backend (Server)
    subgraph "Backend (Server)"
        BE_API["API Entry Points"]
        BE_Routes["Routes"]
        BE_Middlewares["Middlewares"]
        BE_Controllers["Controllers"]
        BE_Models["Models"]
        BE_DB["Database Connection"]
    end

    %% External Services
    MongoDB["MongoDB"]
    Cloudinary["Cloudinary"]

    %% Frontend Relationships
    FE_Pages -->|"uses"| FE_Components
    FE_Pages -->|"manages state via"| FE_Store
    FE_Pages -->|"leverages"| FE_Hooks
    FE_Pages -->|"configured by"| FE_Config
    FE_Components -->|"dispatches API calls to"| BE_API

    %% Backend Relationships
    BE_API -->|"forwards to"| BE_Routes
    BE_Routes -->|"invokes"| BE_Middlewares
    BE_Routes -->|"routes to"| BE_Controllers
    BE_Controllers -->|"executes logic with"| BE_Models
    BE_Models -->|"CRUD operations on"| MongoDB
    BE_Controllers -->|"handles image uploads via"| Cloudinary
    BE_API ---|"initializes"| BE_DB

    %% Styling
    class FE_Pages,FE_Components,FE_Store,FE_Hooks,FE_Config frontend
    class BE_API,BE_Routes,BE_Middlewares,BE_Controllers,BE_Models,BE_DB backend
    class MongoDB,Cloudinary external

    %% Click Events for Frontend Components
    click FE_Components "https://github.com/harshiniumesh/zomato-clone-final/tree/main/client/src/components"
    click FE_Pages "https://github.com/harshiniumesh/zomato-clone-final/tree/main/client/src/pages"
    click FE_Store "https://github.com/harshiniumesh/zomato-clone-final/tree/main/client/src/store"
    click FE_Hooks "https://github.com/harshiniumesh/zomato-clone-final/tree/main/client/src/customHooks"
    click FE_Hooks "https://github.com/harshiniumesh/zomato-clone-final/tree/main/client/src/utils"
    click FE_Config "https://github.com/harshiniumesh/zomato-clone-final/blob/main/client/tailwind.config.js"
    click FE_Config "https://github.com/harshiniumesh/zomato-clone-final/blob/main/client/vite.config.js"

    %% Click Events for Backend Components
    click BE_API "https://github.com/harshiniumesh/zomato-clone-final/blob/main/server/index.js"
    click BE_API "https://github.com/harshiniumesh/zomato-clone-final/blob/main/server/app.js"
    click BE_Controllers "https://github.com/harshiniumesh/zomato-clone-final/tree/main/server/controllers"
    click BE_Models "https://github.com/harshiniumesh/zomato-clone-final/tree/main/server/models"
    click BE_Routes "https://github.com/harshiniumesh/zomato-clone-final/tree/main/server/routes"
    click BE_Middlewares "https://github.com/harshiniumesh/zomato-clone-final/tree/main/server/middlewares"
    click BE_DB "https://github.com/harshiniumesh/zomato-clone-final/blob/main/server/db/config.js"

classDef frontend fill:#D6EAF8,stroke:#1F618D,stroke-width:2px;
classDef backend fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
classDef external fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
```
