# jack20410/restaurant-order-system architecture

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

- Interactive diagram: https://gitdiagram.com/jack20410/restaurant-order-system
- Repository: https://github.com/jack20410/restaurant-order-system

## Overview

##### Main Components
- API Gateway: Acts as the central entry point for all incoming requests.
- Frontend: The user interface built with modern JavaScript frameworks (React-like structure from the frontend code). It connects to the API gateway via web API calls.
- Microservices: Three distinct services, each handling a unique domain:
- User Service (port 8001): Handles user management, registration, login, and JWT authentication, interfacing with a MySQL database (named user_db on port 3306).
- Order Service (port 8002): Manages order processing, status tracking, and integration with the User Service. Uses its own MySQL database (order_db on port 3307).
- Kitchen Service (port 8003): Manages kitchen order queues and real-time order preparations with a MongoDB backend (kitchen_db on port 27017).
- User Service (MySQL)
- Order Service (MySQL)
- Kitchen Service (MongoDB)

##### Relationships and Data Flow
- Frontend → API Gateway (gateway handles and routes requests to the appropriate service).
- API Gateway → Each Microservice (User, Order, Kitchen) to forward requests.
- Service-to-service communication, e.g., Order Service calling User Service for user-related operations.

##### Architectural Patterns and Technology Stack
- Use of Docker & Docker Compose for container orchestration.
- FastAPI as the framework for services.
- RESTful HTTP communication for inter-service calls.
- Varying backend databases configured with environment variables.

##### Final Touches

This approach covers the microservices architecture, highlighting individual responsibilities, the separation of concerns, and service interdependencies specific to this project. The goal is to have an accurate, modular, and visually engaging system design that stakeholders and team members can easily follow and appreciate.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    FE["Frontend"]:::frontend

    %% API Gateway Layer
    APIG["API Gateway"]:::apigw

    %% Microservices Layer
    subgraph "Microservices"
        US["User Service (port 8001)"]:::serviceUser
        OS["Order Service (port 8002)"]:::serviceOrder
        KS["Kitchen Service (port 8003)"]:::serviceKitchen
    end

    %% Databases Layer
    subgraph "Databases"
        DB_USER["MySQL (User DB) (3306)"]:::database
        DB_ORDER["MySQL (Order DB) (3307)"]:::database
        DB_KS["MongoDB (Kitchen DB) (27017)"]:::database
    end

    %% Connections between layers
    FE -->|"API_call"| APIG
    APIG -->|"Routes(8001)"| US
    APIG -->|"Routes(8002)"| OS
    APIG -->|"Routes(8003)"| KS
    OS -->|"UserLookup"| US
    US -->|"MySQL:3306"| DB_USER
    OS -->|"MySQL:3307"| DB_ORDER
    KS -->|"MongoDB:27017"| DB_KS
    KS -->|"LiveUpdate"| FE

    %% Click Events
    click FE "https://github.com/jack20410/restaurant-order-system/tree/main/frontend"
    click APIG "https://github.com/jack20410/restaurant-order-system/tree/main/api-gateway"
    click US "https://github.com/jack20410/restaurant-order-system/tree/main/services/user-service"
    click OS "https://github.com/jack20410/restaurant-order-system/tree/main/services/order-service"
    click KS "https://github.com/jack20410/restaurant-order-system/tree/main/services/kitchen-service"

    %% Styles
    classDef frontend fill:#85C1E9,stroke:#1F618D,stroke-width:2px;
    classDef apigw fill:#F7DC6F,stroke:#B7950B,stroke-width:2px;
    classDef serviceUser fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef serviceOrder fill:#A9DFBF,stroke:#1E8449,stroke-width:2px;
    classDef serviceKitchen fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef database fill:#D7BDE2,stroke:#633974,stroke-width:2px;
```
