# neta-rose/delivery-app-pathfinding architecture

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

- Interactive diagram: https://gitdiagram.com/neta-rose/delivery-app-pathfinding
- Repository: https://github.com/neta-rose/delivery-app-pathfinding

## Overview

##### Main System Components

a. Frontend (Client Layer):
- Views (OrderPage, HistoryPage)
- Components (Grid, Menu, Navbar, Sidebar)
- Context Providers (Grid, OrderDetails, SelectedRestaurant, Settings)
- API Service Layer

b. Backend (Server Layer):
- Controllers (Customer, DeliveryMan, Menu, Order, Restaurant)
- Services Layer (including Pathfinding Algorithms)
- Data Structures (MinHeapQueue)
- Middleware (Error Handler, Logger)

c. Database Layer:
- Person (base entity)
- Customer
- DeliveryMan
- Restaurant
- Order
- Menu
- Item

##### Component Relationships and Data Flow

- Frontend to Backend: Use REST API calls (show with HTTP methods)
- Backend to Database: Show TypeORM interactions
- Pathfinding Visualization Flow:
- Grid Component → Pathfinding Algorithms (A*, Dijkstra)
- Algorithm Results → Grid Visualization

##### Special Architectural Elements

- Pathfinding Algorithm Components:
- A* Implementation
- Dijkstra Implementation
- Grid Structure
- Node Entity

##### Technical Stack Indicators

- React + TypeScript (Frontend)
- Node.js + Express (Backend)
- PostgreSQL (Database)
- TypeORM (ORM Layer)
- Vite (Build Tool)

##### Specific Implementation Details

- Grid Visualization Implementation
- Algorithm Selection Mechanism
- Order Processing Flow
- Restaurant-Customer-DeliveryMan Relationship

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,color:white
    classDef backend fill:#2ecc71,color:white
    classDef service fill:#f1c40f,color:black
    classDef database fill:#e74c3c,color:white
    classDef algorithm fill:#9b59b6,color:white
    classDef context fill:#1abc9c,color:white

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        B[Backend]:::backend
        S[Service]:::service
        D[Database]:::database
        A[Algorithm]:::algorithm
        C[Context]:::context
    end

    %% Frontend Layer
    subgraph Frontend
        Views --> |Uses| Contexts
        Views --> |Makes| APILayer

        subgraph Views
            OrderPage["Order Page"]:::frontend
            HistoryPage["History Page"]:::frontend
        end

        subgraph Contexts
            GridCtx["Grid Context"]:::context
            OrderCtx["Order Details Context"]:::context
            RestaurantCtx["Selected Restaurant Context"]:::context
            SettingsCtx["Settings Context"]:::context
        end

        subgraph APILayer
            AxiosInstance["Axios Instance"]:::frontend
            APIInterface["API Interface"]:::frontend
        end
    end

    %% Backend Layer
    subgraph Backend
        APILayer --> |HTTP| Routes
        Routes --> Controllers
        Controllers --> Services
        Services --> |CRUD| Database
        Services --> Algorithms

        subgraph Routes
            RestaurantRouter["Restaurant Router"]:::backend
            OrderRouter["Order Router"]:::backend
            CustomerRouter["Customer Router"]:::backend
            DeliveryRouter["Delivery Router"]:::backend
            MenuRouter["Menu Router"]:::backend
        end

        subgraph Controllers
            RestaurantCtrl["Restaurant Controller"]:::backend
            OrderCtrl["Order Controller"]:::backend
            CustomerCtrl["Customer Controller"]:::backend
            DeliveryCtrl["Delivery Controller"]:::backend
            MenuCtrl["Menu Controller"]:::backend
        end

        subgraph Services
            RestaurantSvc["Restaurant Service"]:::service
            OrderSvc["Order Service"]:::service
            CustomerSvc["Customer Service"]:::service
            DeliverySvc["Delivery Service"]:::service
            MenuSvc["Menu Service"]:::service
        end

        subgraph Algorithms
            AStar["A* Algorithm"]:::algorithm
            Dijkstra["Dijkstra Algorithm"]:::algorithm
            MinHeap["MinHeap Queue"]:::algorithm
        end

        subgraph Database
            RestaurantEntity["Restaurant"]:::database
            OrderEntity["Order"]:::database
            CustomerEntity["Customer"]:::database
            DeliveryEntity["DeliveryMan"]:::database
            MenuEntity["Menu"]:::database
            ItemEntity["Item"]:::database
        end
    end

    %% Click Events
    click OrderPage "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/client/src/views/OrderPage/OrderPage.tsx"
    click HistoryPage "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/client/src/views/HistoryPage/HistoryPage.tsx"
    click GridCtx "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/client/src/context/GridContext/GridContext.ts"
    click OrderCtx "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/client/src/context/OrderDetailsContext/OrderDetailsContext.ts"
    click RestaurantCtx "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/client/src/context/SelectedRestaurantContext/SelectedRestaurantContext.ts"
    click SettingsCtx "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/client/src/context/SettingsContext/SettingsContext.tsx"
    click AxiosInstance "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/client/src/api/axiosInstance.ts"
    click APIInterface "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/client/src/api/api.ts"
    click RestaurantRouter "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/routes/restaurant.router.ts"
    click OrderRouter "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/routes/order.router.ts"
    click CustomerRouter "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/routes/customer.router.ts"
    click DeliveryRouter "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/routes/deliveryMan.router.ts"
    click MenuRouter "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/routes/menu.router.ts"
    click RestaurantCtrl "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/controllers/restaurant.controller.ts"
    click OrderCtrl "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/controllers/order.controller.ts"
    click CustomerCtrl "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/controllers/customer.controller.ts"
    click DeliveryCtrl "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/controllers/deliveryMan.controller.ts"
    click MenuCtrl "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/controllers/menu.controller.ts"
    click RestaurantSvc "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/services/restaurant.service.ts"
    click OrderSvc "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/services/order.service.ts"
    click CustomerSvc "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/services/customers.service.ts"
    click DeliverySvc "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/services/deliveryMan.service.ts"
    click MenuSvc "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/services/menu.service.ts"
    click AStar "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/services/algorithms/astar.ts"
    click Dijkstra "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/services/algorithms/dijkstra.ts"
    click MinHeap "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/services/data structures/MinHeapQueue.ts"
    click RestaurantEntity "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/entities/typeORM/Restaurant.entity.ts"
    click OrderEntity "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/entities/typeORM/Order.entity.ts"
    click CustomerEntity "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/entities/typeORM/Customer.entity.ts"
    click DeliveryEntity "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/entities/typeORM/DeliveryMan.entity.ts"
    click MenuEntity "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/entities/typeORM/Menu.entity.ts"
    click ItemEntity "https://github.com/Neta-Rose/delivery-app-pathfinding/blob/prod/server/src/entities/typeORM/Item.entity.ts"
```
