# rahulsahofficial/lld architecture

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

- Interactive diagram: https://gitdiagram.com/rahulsahofficial/lld
- Repository: https://github.com/rahulsahofficial/lld

## Overview

##### Project type and purpose
- This repo is a teaching/learning workspace covering:
- Design Patterns demos (Strategy, Factory, Singleton, etc.)
- OOP experiments
- SOLID principles code
- Two small applications:
– GoogleDoc editor (Projects/GoogleDoc)
– BrOla ride‐sharing hackathon (Hackathon/BrOla)
- Of these, the BrOla folder represents a coherent mini‐application with multiple cooperating modules.

##### File structure
- Top‐level folders each represent independent domains.
- Drill into Hackathon/BrOla:
- Models/ — domain entities (Driver, Rider, Ride, Vehicle, User)
- Managers/ — in‐memory state managers (DriverManager, RiderManager, RideManager)
- Services/ — functional modules:
– DriverAssignService
– PricingService
– VehiclePricingService
– PaymentService (+ factory & strategies)
– NotificationService (SMS, App)
– OtpService
- Utils/ and Types/ — shared types (e.g. Location, Types.h)
- main.cpp — orchestrates end‐to‐end flow
- Outputs/ — sample run logs

##### Extract insights from README
- “BrOla” implements ride‐request, assignment, pricing, payment and notifications using Strategy and Factory patterns.
- The code emphasizes separation of concerns via interfaces and service classes.

a. Main components
- Clients (Rider App / CLI)
- RideManager (handles ride requests)
- DriverAssignService (matches riders & drivers)
- PricingService & VehiclePricingService (compute fare)
- PaymentService (+ PaymentServiceFactory + strategies)
- NotificationService (+ SMS & App channels)
- OtpService (for authentication)
- Data stores (in this demo, in‐memory Managers)
- Domain Models (Driver, Rider, Ride, Vehicle)
b. Relationships & interactions
1. Rider sends “requestRide” → RideManager
2. RideManager → DriverAssignService → selects Driver via DriverManager
3. RideManager → PricingService & VehiclePricingService → calculate fare
4. Rider confirms → PaymentServiceFactory produces chosen PaymentStrategy (UPI/COD) → processPayment
5. On success/failure → NotificationService notifies via SMS or In‐App
6. Optionally, OtpService invoked for verification
7. RideManager creates Ride model, updates RideManager state
c. Architectural patterns & principles
- Strategy (Payment, Notification, Vehicle pricing)
- Factory (PaymentServiceFactory)
- Single Responsibility (each service does one thing)
- Dependency Injection (services interact via interfaces)
d. Key technologies & libraries
- Plain C++ classes & headers
- No external DB: in‐memory managers
- Console‐based I/O (main.cpp demonstrating flows)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI/Client
    subgraph "UI/Client"
        RiderApp["Rider UI / CLI"]:::ui
    end

    %% Managers & Models
    subgraph "Managers & Models"
        subgraph "In-Memory Managers"
            DriverMgr["DriverManager"]:::store
            RiderMgr["RiderManager"]:::store
            RideMgr["RideManager"]:::store
        end
        subgraph "Domain Models"
            Driver["Driver"]:::model
            Rider["Rider"]:::model
            Ride["Ride"]:::model
            Vehicle["Vehicle"]:::model
            User["User"]:::model
        end
    end

    %% Services
    subgraph "Services"
        DAS["DriverAssignService"]:::service
        PS["PricingService"]:::service
        VPS["VehiclePricingService"]:::service
        PFac["PaymentServiceFactory"]:::service
        COD["CODPaymentStrategy"]:::service
        UPI["UPIPaymentStrategy"]:::service
        NSvc["NotificationService"]:::service
        SMS["SMSNotification"]:::service
        AppNot["AppNotification"]:::service
        OTP["OtpService"]:::service
    end

    %% Flow
    RiderApp -->|"requestRide(riderId, origin, dest)"| RideMgr
    RideMgr -->|"assignDriver(riderId)"| DAS
    DAS -->|"getAvailableDriver()"| DriverMgr
    DAS -->|"returns Driver"| Driver
    RideMgr -->|"calculateFare(origin, dest)"| PS
    RideMgr -->|"calculateFareWithVehicle(vehicle)"| VPS
    PS -->|"uses vehicle data"| Vehicle
    VPS -->|"uses vehicle data"| Vehicle
    RideMgr -->|"createRide(rider, driver, fare)"| Ride
    RiderApp -->|"confirmPayment(type, amount)"| PFac
    PFac -->|"createStrategy(type)"| COD
    PFac -->|"createStrategy(type)"| UPI
    COD -->|"processPayment(amount)"| PFac
    UPI -->|"processPayment(amount)"| PFac
    PFac -->|"paymentResult(success/fail)"| RideMgr
    RideMgr -->|"notify(user, message)"| NSvc
    NSvc -->|"sendSMS(message)"| SMS
    NSvc -->|"sendAppNotification(message)"| AppNot
    RideMgr -.->|"verifyOtp(user)"| OTP

    %% Click Events
    click Driver "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/Models/Driver.h"
    click Rider "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/Models/Rider.h"
    click Ride "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/Models/Ride.h"
    click Vehicle "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/Models/Vehicle.h"
    click User "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/Models/User.h"
    click DriverMgr "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/Managers/DriverManager.h"
    click RiderMgr "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/Managers/RiderManager.h"
    click RideMgr "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/Managers/RideManager.h"
    click DAS "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/DriverAssignService/DriverAssignService.h"
    click PS "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/PricingService/PricingService.h"
    click VPS "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/VehiclePricingService/VehiclePricingService.h"
    click PFac "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/PaymentService/PaymentServiceFactory.h"
    click COD "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/PaymentService/CODPaymentStrategy.h"
    click UPI "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/PaymentService/UPIPaymentStrategy.h"
    click NSvc "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/NotificationService/NotificationService.h"
    click SMS "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/NotificationService/SMSNotification.h"
    click AppNot "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/NotificationService/AppNotification.h"
    click OTP "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/OtpService/OtpService.h"
    click RiderApp "https://github.com/rahulsahofficial/lld/blob/main/Hackathon/BrOla/main.cpp"

    %% Styles
    classDef ui fill:#f96,stroke:#333,stroke-width:1px
    classDef store fill:#bbf,stroke:#333,stroke-width:1px
    classDef model fill:#acf,stroke:#333,stroke-width:1px
    classDef service fill:#9f9,stroke:#333,stroke-width:1px
    class OTP dashed
```
