# mayankist/foodie architecture

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

- Interactive diagram: https://gitdiagram.com/mayankist/foodie
- Repository: https://github.com/mayankist/foodie

## Overview

##### Main Components

A. Frontend Layer:
- Views (EJS Templates)
- Static Assets (CSS, JS, Images)
- Client-side JavaScript

B. Backend Layer:
- Express.js Server (app.js)
- Routes
- Models
- Controllers (implied in routes)

C. Database Layer:
- MongoDB (implied by the models structure)

##### Component Relationships

**[Client Browser] ←→ [Frontend Layer]**
- ↑                    ↑

- ↓                    ↓
**[Express Server] ←→ [Routes Layer]**
- ↑                    ↑

- ↓                    ↓
**[Models Layer]  ←→  [Database]**

##### Detailed Component Breakdown

- User Views (user.ejs, usershow.ejs, useredit.ejs)
- Shop Views (shoppost.ejs, show.ejs, edit.ejs)
- Shared Components (partials/header.ejs, partials/footer.ejs)
- CSS Files
- Client JS Files
- Images/Uploads

- Shop Routes (routes/shop.js)
- Index Routes (routes/index.js)
- User Model
- Shop Model
- Comment Model

- Users Collection
- Shops Collection
- Comments Collection

##### Flow Indicators

- HTTP Request/Response flows
- Database queries and responses
- Static asset serving
- Template rendering paths

##### Additional Notes

- Separation between public and private routes
- Where user authentication happens
- Areas where file uploads are processed
- Where shop ratings are calculated and stored

## Diagram (Mermaid)

```mermaid
graph TB
    title[Foodie - Restaurant Search and Review System Architecture]:::title

    subgraph Client
        browser[Client Browser]:::client
    end

    subgraph Frontend
        views[Views Layer]:::frontend
        assets[Static Assets]:::frontend
        clientJS[Frontend JavaScript]:::frontend
    end

    subgraph Backend
        server[Express Server]:::backend
        routes[Routes Layer]:::backend
        models[Models Layer]:::backend
    end

    subgraph Database
        mongodb[(MongoDB)]:::database
        subgraph Collections
            users[(Users)]:::database
            shops[(Shops)]:::database
            comments[(Comments)]:::database
        end
    end

    %% Frontend Layer Breakdown
    views --> |Contains| userViews[User Views]:::frontend
    views --> |Contains| shopViews[Shop Views]:::frontend
    views --> |Contains| sharedViews[Shared Components]:::frontend
    
    assets --> |Contains| cssFiles[CSS Files]:::frontend
    assets --> |Contains| jsFiles[JavaScript Files]:::frontend
    assets --> |Contains| imageFiles[Images & Uploads]:::frontend

    clientJS --> |Contains| phoneHandler[Phone Handler]:::frontend
    clientJS --> |Contains| scrollHandler[Scroll Handler]:::frontend

    %% Backend Layer Breakdown
    routes --> |Contains| indexRoutes[Index Routes]:::backend
    routes --> |Contains| shopRoutes[Shop Routes]:::backend

    models --> |Contains| userModel[User Model]:::backend
    models --> |Contains| shopModel[Shop Model]:::backend
    models --> |Contains| commentModel[Comment Model]:::backend

    %% Connections
    browser <--> views
    browser <--> assets
    browser <--> clientJS
    
    views <--> server
    server <--> routes
    routes <--> models
    models <--> mongodb

    %% Click Events
    click server "https://github.com/mayankist/Foodie/blob/main/app.js"
    click routes "https://github.com/mayankist/Foodie/tree/main/routes"
    click indexRoutes "https://github.com/mayankist/Foodie/blob/main/routes/index.js"
    click shopRoutes "https://github.com/mayankist/Foodie/blob/main/routes/shop.js"
    click models "https://github.com/mayankist/Foodie/tree/main/models"
    click userModel "https://github.com/mayankist/Foodie/blob/main/models/user.js"
    click shopModel "https://github.com/mayankist/Foodie/blob/main/models/shop.js"
    click commentModel "https://github.com/mayankist/Foodie/blob/main/models/comment.js"
    click views "https://github.com/mayankist/Foodie/tree/main/views"
    click assets "https://github.com/mayankist/Foodie/tree/main/public"
    click cssFiles "https://github.com/mayankist/Foodie/tree/main/public/css"
    click jsFiles "https://github.com/mayankist/Foodie/tree/main/public/js"
    click imageFiles "https://github.com/mayankist/Foodie/tree/main/public/pics"
    click phoneHandler "https://github.com/mayankist/Foodie/blob/main/public/js/phone.js"
    click scrollHandler "https://github.com/mayankist/Foodie/blob/main/public/js/scrollelement.js"

    %% Styles
    classDef title fill:#f9f,stroke:#333,stroke-width:4px
    classDef client fill:#e6e6e6,stroke:#333
    classDef frontend fill:#a8d1ff,stroke:#333
    classDef backend fill:#90EE90,stroke:#333
    classDef database fill:#ffdb99,stroke:#333

    %% Legend
    subgraph Legend
        client1[Client]:::client
        frontend1[Frontend Component]:::frontend
        backend1[Backend Component]:::backend
        db1[(Database Component)]:::database
    end
```
