# madhank93/learn-system-design architecture

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

- Interactive diagram: https://gitdiagram.com/madhank93/learn-system-design
- Repository: https://github.com/madhank93/learn-system-design

## Overview

##### Project Type and Purpose
- This is a low-level design project that implements a parking lot management system, with a clear focus on object-oriented design (e.g., accounts, parking spots, vehicles, panels) as demonstrated by the file tree under low-level-design/parking-lot.
- The purpose is to design and simulate a parking lot system that includes key functionality such as entry/exit panels, toll calculations (hourly cost), ticket management, and multiple classes of vehicles and parking spots.

##### Analyzing the File Structure
- The top-level directories include “high-level-design” (which contains general system design concepts and prerequisites) and “low-level-design” (which contains the parking-lot domain).
- Under the low-level design, the “ts” directory in the parking lot domain holds the TypeScript code. Within “src”, you have well-organized folders for account, parking-spot, vehicles and other components like entry.panel.ts and exit.panel.ts.
- There are also configuration files (package.json, tsconfig.json, vite.config.ts) that indicate how to build and run the project, showing the usage of modern JavaScript/TypeScript tooling.
- The test directory suggests a unit testing approach that validates key functionalities (e.g., different spec files for panels, parking floors, etc.).

##### Extracting Key Architectural Insights from the README
- Although the README mainly provides useful reference links for system design, it confirms that the repository is intended to be a learning and design resource for system architecture and low-level design.

a. Main Components:
- Entry Point / Entry Panel: Handles the incoming vehicles registering their entry.
- Exit Point / Exit Panel: Manages and handles the vehicle exit and billing.
- Parking Lot Core: Represents the overall parking lot system, integrating various component interactions.
- Accounts: Different types of account modules (admin, parking attendant) used for managing system operations.
- Parking Spots: Various specialized spots (car spot, disabled spot, electric spot, motorcycle spot) reflecting the domain distinctions.
- Vehicles: Capable of handling different vehicle types (car, electric, motorcycle, truck) corresponding to available parking spots.
- Parking Display Board: Likely a real-time representation of parking occupancy and available spots.
- Utilities: Modules like hourly cost calculation and ticketing (parking.ticket.ts).

b. Relationships and Interactions:
- Upon entry, the system allocates an appropriate Parking Spot based on vehicle type and availability.
- The Parking Lot Core manages these allocations and tracks the occupancy across different floors and spots.
- Parking Tickets are generated and later used at the Exit Panel to calculate the parking cost using the hourly cost module.
- The Accounts module (including admin and attendant functionalities) oversees managing operations, such as updating system settings or verifying usage.
- There is an overall interaction between the display board and the parking lot to show real-time information.

c. Architectural Patterns / Design Principles:
- Object-Oriented Design: Reflecting through the use of encapsulated classes for accounts, parking spots, vehicles, etc.
- Modular Structure: Separation of concerns is clear, with dedicated directories for each domain component.
- Possibly a layered architecture where user interface components (panels) separate from business logic (parking lot, cost calculation) and data management (potential ticket generation).

d. Key Technologies and Frameworks:
- TypeScript is the primary language.
- Tooling like Vite for bundling and pnpm for dependency management.
- Testing structure is present to demonstrate unit testing practices.

##### Final Recommendations
- That all major interactions (data flow, service calls, component responsibilities) are clearly indicated.
- Avoid unnecessary detail; however, capture all essential architectural elements as outlined.
- Use the high-level and low-level design documents as references if further clarification is needed in specific areas.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entity
    extVehicle["Incoming Vehicle"]:::external

    %% User Interface Layer
    subgraph "User Interface"
        EP["Entry Panel"]:::ui
        XP["Exit Panel"]:::ui
        PDB["Parking Display Board"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        PLC["Parking Lot Core"]:::logic
        HCC["Hourly Cost Calculation Module"]:::logic
        PTM["Parking Ticket Module"]:::logic
        PF["Parking Floor Module"]:::logic
    end

    %% Domain Entities Layer
    subgraph "Domain Entities"
        AM["Account Management"]:::domain
        PS["Parking Spots"]:::domain
        V["Vehicles"]:::domain
    end

    %% Connections: Vehicle flow and interactions
    extVehicle -->|"arrives"| EP
    EP -->|"registers"| PLC
    PLC -->|"allocates"| PS
    PS -->|"matches"| V
    V -->|"providesType"| PLC

    %% Ticketing and Payment Flow
    PLC -->|"issuesTicket"| PTM
    PTM -->|"calculatesFee"| HCC
    XP -->|"validatesTicket"| PTM
    XP -->|"updatesExit"| PLC

    %% Additional Interactions
    PLC -->|"tracksOccupancy"| PF
    PLC -->|"updatesDisplay"| PDB
    AM -->|"manages"| PLC

    %% Class Definitions for colouring
    classDef ui fill:#8FBC8F,stroke:#333,stroke-width:2px;
    classDef logic fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef domain fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px;

    %% Click Events mapping to file paths
    click EP "https://github.com/madhank93/learn-system-design/blob/main/low-level-design/parking-lot/ts/src/entry.panel.ts"
    click XP "https://github.com/madhank93/learn-system-design/blob/main/low-level-design/parking-lot/ts/src/exit.panel.ts"
    click PLC "https://github.com/madhank93/learn-system-design/blob/main/low-level-design/parking-lot/ts/src/parking.lot.ts"
    click AM "https://github.com/madhank93/learn-system-design/tree/main/low-level-design/parking-lot/ts/src/account"
    click PS "https://github.com/madhank93/learn-system-design/tree/main/low-level-design/parking-lot/ts/src/parking-spot"
    click V "https://github.com/madhank93/learn-system-design/tree/main/low-level-design/parking-lot/ts/src/vehicles"
    click PDB "https://github.com/madhank93/learn-system-design/blob/main/low-level-design/parking-lot/ts/src/parking.display.board.ts"
    click HCC "https://github.com/madhank93/learn-system-design/blob/main/low-level-design/parking-lot/ts/src/hourly.cost.ts"
    click PTM "https://github.com/madhank93/learn-system-design/blob/main/low-level-design/parking-lot/ts/src/parking.ticket.ts"
    click PF "https://github.com/madhank93/learn-system-design/blob/main/low-level-design/parking-lot/ts/src/parking.floor.ts"
```
