# eldardautovic/ridewithme architecture

> Architecture diagram of the GitHub repository eldardautovic/ridewithme, 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/eldardautovic/ridewithme
- Repository: https://github.com/eldardautovic/ridewithme

## Overview

##### Main Components Identification

The system consists of several key components:
- Frontend Applications (Flutter-based)
- Admin Panel (ridewithme_admin)
- Mobile Application (ridewithme_mobile)
- Backend Services
- Main API (ridewithme.API)
- RabbitMQ Service (ridewithme.RabbitMQ)
- Database Layer (evident from the RidewithmeContext)
- Message Queue System (RabbitMQ)

**┌─────────────────────┐    ┌─────────────────────┐**
- Mobile App        │    │   Admin Panel        │
- (Flutter)         │    │   (Flutter)          │
- ┘    └─────────────────────┘

**┌─────────────────────────────────────────────┐**
- ridewithme.API                 │
- (Controllers, Authentication, Services)     │
- ┘

**┌─────────────┐ ┌─────────────┐ ┌─────────────┐**
- Voznje    │ │   Korisnici │ │    Zalbe    │
- Service   │ │   Service   │ │   Service   │
- ┘ └─────────────┘ └─────────────┘

**┌─────────────────────────────────────────────┐**
- RabbitMQ Service               │
- (Email Notifications, State Changes)     │
- ┘

**┌─────────────────────────────────────────────┐**
- RidewithmeContext (DB)            │
- ┘

##### Key Relationships to Highlight

- State machine flows for:
- Kuponi (Draft → Active → Hidden)
- Voznje (Draft → Active → Booked → Hidden)
- Zalbe (Initial → Active → Processing → Completed)
- Database relationships between key entities

##### Additional Elements

- Authentication flow indicators
- External service integrations
- Error handling paths

##### Technical Details

- Docker container boundaries
- API endpoints grouping
- Database entity relationships
- State machine transitions
- Message queue topics/channels

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph Clients
        MobileApp["Mobile App (Flutter)"]:::client
        AdminPanel["Admin Panel (Flutter)"]:::client
    end

    %% API Layer
    subgraph API
        APIGateway["API Gateway"]:::api
        VoznjeCtrl["Voznje Controller"]:::controller
        KorisniciCtrl["Korisnici Controller"]:::controller
        ZalbeCtrl["Zalbe Controller"]:::controller
    end

    %% Service Layer
    subgraph Services
        VoznjeService["Voznje Service"]:::service
        KorisniciService["Korisnici Service"]:::service
        ZalbeService["Zalbe Service"]:::service
        KuponiService["Kuponi Service"]:::service
    end

    %% State Machines
    subgraph StateMachines
        VoznjeSM["Voznje State Machine"]:::statemachine
        ZalbeSM["Zalbe State Machine"]:::statemachine
        KuponiSM["Kuponi State Machine"]:::statemachine
    end

    %% Message Queue Layer
    subgraph MessageQueue
        RabbitMQ["RabbitMQ Service"]:::queue
        EmailService["Email Service"]:::queue
        BGWorker["Background Worker"]:::queue
    end

    %% Data Layer
    subgraph Database
        DB[(RidewithmeContext)]:::database
    end

    %% Relationships
    MobileApp <--> APIGateway
    AdminPanel <--> APIGateway
    
    APIGateway --> VoznjeCtrl & KorisniciCtrl & ZalbeCtrl
    
    VoznjeCtrl --> VoznjeService
    KorisniciCtrl --> KorisniciService
    ZalbeCtrl --> ZalbeService
    
    VoznjeService --> VoznjeSM
    ZalbeService --> ZalbeSM
    KuponiService --> KuponiSM
    
    VoznjeService & KorisniciService & ZalbeService & KuponiService --> DB
    
    VoznjeSM & ZalbeSM & KuponiSM --> RabbitMQ
    RabbitMQ --> EmailService & BGWorker
    
    %% Click Events
    click MobileApp "https://github.com/eldardautovic/ridewithme/tree/main/UI/ridewithme_mobile/"
    click AdminPanel "https://github.com/eldardautovic/ridewithme/tree/main/UI/ridewithme_admin/"
    click APIGateway "https://github.com/eldardautovic/ridewithme/tree/main/ridewithme.API/"
    click VoznjeCtrl "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.API/Controllers/VoznjeController.cs"
    click KorisniciCtrl "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.API/Controllers/KorisniciController.cs"
    click ZalbeCtrl "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.API/Controllers/ZalbeController.cs"
    click VoznjeService "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.Service/VoznjeService.cs"
    click KorisniciService "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.Service/KorisniciService.cs"
    click ZalbeService "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.Service/ZalbeService.cs"
    click KuponiService "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.Service/KuponiService.cs"
    click VoznjeSM "https://github.com/eldardautovic/ridewithme/tree/main/ridewithme.Service/VoznjeStateMachine/"
    click ZalbeSM "https://github.com/eldardautovic/ridewithme/tree/main/ridewithme.Service/ZalbeStateMachine/"
    click KuponiSM "https://github.com/eldardautovic/ridewithme/tree/main/ridewithme.Service/KuponiStateMachine/"
    click RabbitMQ "https://github.com/eldardautovic/ridewithme/tree/main/ridewithme.RabbitMQ/"
    click EmailService "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.RabbitMQ/EmailSender.cs"
    click BGWorker "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.RabbitMQ/BackgroundWorkerService.cs"
    click DB "https://github.com/eldardautovic/ridewithme/blob/main/ridewithme.Service/Database/RidewithmeContext.cs"

    %% Styles
    classDef client fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef api fill:#90EE90,stroke:#333,stroke-width:2px
    classDef controller fill:#98FB98,stroke:#333,stroke-width:2px
    classDef service fill:#32CD32,stroke:#333,stroke-width:2px
    classDef statemachine fill:#FFD700,stroke:#333,stroke-width:2px
    classDef queue fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef database fill:#C0C0C0,stroke:#333,stroke-width:2px
```
