# thechance101/beep-beep architecture

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

- Interactive diagram: https://gitdiagram.com/thechance101/beep-beep
- Repository: https://github.com/thechance101/beep-beep

## Overview

##### Project type and purpose
- This is a full‐stack, multi‐module Kotlin project showcasing a food delivery + taxi platform.
- It consists of:
– Six Compose Multiplatform front-end apps (End-User, Restaurant Admin, Delivery, Taxi Driver, Dashboard, Support)
– A shared design_system library (UI components + themes)
– A Kotlin/ Ktor-based API Gateway
– Six Ktor microservices (Identity, Restaurant, Taxi, Location, Notification, Chat)
– Local persistence on mobile via Realm and remote messaging via Firebase Cloud Messaging

##### High-level architecture
[Front-end Layer]
- Apps (mobile and desktop) built with Compose MP
- Consume APIs through a single API Gateway
- Share UI & domain logic via KMP “common” modules and design_system

[Integration Layer]
- API Gateway (Ktor + Koin)
– Authentication, routing, security, serialization, websockets support
– Forwards HTTP/WS calls to dedicated microservices

[Microservices Layer]
- Identity Service
- Restaurant Service
- Taxi Service
- Location Service
- Notification Service
- Chat Service
Each service:
– Exposes REST endpoints and/or WebSocket routes
– Has its own database container (e.g., Realm, Mongo, SQL—encapsulated in DataBaseContainer)
– Implements DI (Koin), domain/use-case layers, data/gateway layers, endpoint plugins

[External Services]
- Firebase Cloud Messaging for push notifications
- APIs (via HTTP gateways in shared modules)

##### Main components
– Shared libraries (design_system, common KMP modules)
– API Gateway

##### Relationships and data flow
a. Front-end → API Gateway (HTTP or WS)
b. API Gateway → respective microservices (HTTP or WS)
c. Microservices → their databases (persistent storage)
d. Notification Service ↔ Firebase Messaging (push tokens, topics)
e. Location & Chat & Restaurant (order updates) via WebSocket bidirectional channels

##### Key architectural patterns & principles
- Microservices behind an API Gateway pattern
- Single Responsibility per service (domain/use-case separation)
- Shared KMP modules for code reuse across front-ends
- WebSocket for real-time features (chat, live location, order streams)
- Dependency Injection (Koin) and plugin-based configuration (Ktor plugins)
- Local caching/persistence on clients (Realm) and paging libraries

##### Detailed element checklist
– Component labels (apps, gateway, services, DBs, external)
- UI → Gateway (HTTP/WS)
- Gateway → Service (HTTP/WS)
- Service → DB (read/write)
- Notification Service ↔ Firebase
– Optional: group services by domain (Identity, Restaurant, Taxi, etc.)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Front-end Layer
    subgraph "Front-end Layer"
        direction TB
        EndUser["End-User App\n(Compose MP)"]:::frontend
        RestaurantAdmin["Restaurant Admin App\n(Compose MP)"]:::frontend
        Delivery["Delivery App\n(Compose MP)"]:::frontend
        TaxiDriver["Taxi Driver App\n(Compose MP)"]:::frontend
        Dashboard["Dashboard App\n(Compose MP)"]:::frontend
        Support["Support App\n(Compose MP)"]:::frontend
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        direction TB
        DesignSystem["Design System Library"]:::shared
    end

    %% API Gateway
    APIGateway["API Gateway\n(Ktor + Koin)"]:::gateway

    %% Microservices Layer
    subgraph "Microservices Layer"
        direction TB
        IdentityService["Identity Service"]:::service
        RestaurantService["Restaurant Service"]:::service
        TaxiService["Taxi Service"]:::service
        LocationService["Location Service"]:::service
        NotificationService["Notification Service"]:::service
        ChatService["Chat Service"]:::service

        %% Databases
        IdentityDB[(Identity DB)]:::db
        RestaurantDB[(Restaurant DB)]:::db
        TaxiDB[(Taxi DB)]:::db
        LocationDB[(Location DB)]:::db
        NotificationDB[(Notification DB)]:::db
        ChatDB[(Chat DB)]:::db

    end

    %% External Services
    Firebase["Firebase Cloud Messaging"]:::external
    MapAPI["Map API"]:::external

    %% Connections Front-end to Gateway
    EndUser -->|"HTTP/REST, WS"| APIGateway
    RestaurantAdmin -->|"HTTP/REST, WS"| APIGateway
    Delivery -->|"HTTP/REST, WS"| APIGateway
    TaxiDriver -->|"HTTP/REST, WS"| APIGateway
    Dashboard -->|"HTTP/REST"| APIGateway
    Support -->|"HTTP/REST"| APIGateway

    %% Shared Libraries usage
    DesignSystem --> EndUser
    DesignSystem --> RestaurantAdmin
    DesignSystem --> Delivery
    DesignSystem --> TaxiDriver
    DesignSystem --> Dashboard
    DesignSystem --> Support
    DesignSystem --> APIGateway

    %% Gateway to Services
    APIGateway -->|"HTTP/REST"| IdentityService
    APIGateway -->|"HTTP/REST"| TaxiService
    APIGateway -->|"HTTP/REST"| NotificationService
    APIGateway -->|"HTTP/REST"| ChatService
    APIGateway -->|"HTTP/REST"| RestaurantService
    APIGateway -->|"HTTP/REST"| LocationService

    APIGateway -.->|"WebSocket"| ChatService
    APIGateway -.->|"WebSocket"| LocationService
    APIGateway -.->|"WebSocket"| RestaurantService

    %% Services to DBs
    IdentityService --> IdentityDB
    RestaurantService --> RestaurantDB
    TaxiService --> TaxiDB
    LocationService --> LocationDB
    NotificationService --> NotificationDB
    ChatService --> ChatDB

    %% Notification Service and Firebase
    NotificationService <-->|"Push"| Firebase

    %% Location Service and Map API
    LocationService -->|"HTTP"| MapAPI

    %% Click Events
    click EndUser "https://github.com/thechance101/beep-beep/tree/develop/client_end_user/androidApp"
    click RestaurantAdmin "https://github.com/thechance101/beep-beep/tree/develop/client_restaurant/androidApp"
    click Delivery "https://github.com/thechance101/beep-beep/tree/develop/client_delivery/androidApp"
    click TaxiDriver "https://github.com/thechance101/beep-beep/tree/develop/client_taxi_driver/androidApp"
    click Dashboard "https://github.com/thechance101/beep-beep/tree/develop/client_dashboard/desktop"
    click Support "https://github.com/thechance101/beep-beep/tree/develop/client_support/desktop"
    click DesignSystem "https://github.com/thechance101/beep-beep/tree/develop/design_system/shared"
    click APIGateway "https://github.com/thechance101/beep-beep/tree/develop/api_gateway"
    click IdentityService "https://github.com/thechance101/beep-beep/tree/develop/service_identity"
    click RestaurantService "https://github.com/thechance101/beep-beep/tree/develop/service_restaurant"
    click TaxiService "https://github.com/thechance101/beep-beep/tree/develop/service_taxi"
    click LocationService "https://github.com/thechance101/beep-beep/tree/develop/service_location"
    click NotificationService "https://github.com/thechance101/beep-beep/tree/develop/service_notification"
    click ChatService "https://github.com/thechance101/beep-beep/tree/develop/service_chat"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef shared fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef gateway fill:#FFA500,stroke:#333,stroke-width:1px
    classDef service fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#A9A9A9,stroke:#333,stroke-width:1px
    classDef external fill:#D8BFD8,stroke:#333,stroke-width:1px
```
