# misaelmamangun/megaworld-parking-system architecture

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

- Interactive diagram: https://gitdiagram.com/misaelmamangun/megaworld-parking-system
- Repository: https://github.com/misaelmamangun/megaworld-parking-system

## Overview

##### Project type and purpose
- This is a Next.js–based web application (bootstrapped with create-next-app) written in TypeScript.
- From the file names (ParkVehicleForm, ParkingSlotList, parking.service) the app’s purpose is to provide a parking-management UI: users can park vehicles, view available slots, etc.

##### File structure
Top-level:
- package.json, tsconfig.json, next.config.ts – configuration and dependency manifests
- app/ – your Next.js “app router” directory
Inside app/:
- components/ – React UI components (Header, ParkVehicleForm, ParkingSlotList, Select)
- enums/ – enumeration definitions (slot and vehicle types)
- services/ – business-logic layer for calling parking APIs (parking.service.ts)
- types/ – TypeScript type definitions for entrances, parking, vehicles
- utils/ – shared helper functions (calculation.util.ts)
- layout.tsx & page.tsx – top-level layout and home page entry point
- globals.css – global stylesheet

##### README
- Confirms this is a Next.js project, runs on localhost:3000, auto-optimizes fonts via next/font, and is deployable on Vercel. No built-in custom backend routes are defined, so external services or serverless functions must be used via parking.service.ts.

##### Elements
- Service layer in another (e.g., green)
- Utility modules in gray
- External API/DB in orange
- Hosting/CDN in teal

##### Detailed layering suggestion
1. Browser (React Hydration)
└─> UI Components (Header, Select, ParkVehicleForm, ParkingSlotList)
2. Next.js App Router (SSR entry → layout.tsx/page.tsx)
3. Service Layer (parking.service.ts)
4. Utility Modules (calculation.util.ts, enums, types)
5. External API / Serverless Backend → persistent storage (e.g., database)
6. Vercel Edge Network (CDN + Serverless function host)

- Reflects the file-based routing and component breakdown of Next.js
- Shows clear separation between presentation, business logic, and data
- Highlights the flow from browser → Next.js → external services → back
- Captures all essential architectural elements without over-splitting components

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Hosting Layer
    Vercel["Vercel Edge Network"]:::hosting

    %% Browser Layer
    Browser["Client Browser"]:::external

    %% Next.js Server Layer
    subgraph "Next.js Server (SSR)"
        Layout["layout.tsx"]:::next
        Page["page.tsx"]:::next
        CSS["globals.css"]:::config
    end

    %% UI Components Layer
    subgraph "UI Components" 
        Header["Header Component"]:::ui
        Select["Select Component"]:::ui
        ParkForm["ParkVehicleForm Component"]:::ui
        SlotList["ParkingSlotList Component"]:::ui
    end

    %% Service Layer
    Service["parking.service.ts"]:::service

    %% Utility Modules Layer
    subgraph "Utility & Type Modules"
        CalcUtil["calculation.util.ts"]:::utils
        SlotEnum["slot-type.enum.ts"]:::enums
        VehicleEnum["vehicle-type.enum.ts"]:::enums
        EntranceType["entrance.type.ts"]:::types
        ParkingType["parking.type.ts"]:::types
        VehicleType["vehicle.type.ts"]:::types
    end

    %% External API / Database
    ExternalAPI["External API / Serverless Backend\n(Database)"]:::external

    %% Data Flow
    Vercel -->|"Route requests"| Layout
    Layout --> Page
    Layout --> CSS
    Page -->|"Serves HTML"| Browser
    Browser -->|"Hydrate & interact"| Header
    Browser -->|"Hydrate & interact"| Select
    Browser -->|"Hydrate & interact"| ParkForm
    Browser -->|"Hydrate & interact"| SlotList
    ParkForm -->|"invoke"| Service
    SlotList -->|"invoke"| Service
    Service -->|"fetch() calls"| ExternalAPI
    Service -->|"use"| CalcUtil
    Service -->|"use"| SlotEnum
    Service -->|"use"| VehicleEnum
    Service -->|"use"| EntranceType
    Service -->|"use"| ParkingType
    Service -->|"use"| VehicleType

    %% Click Events
    click Layout "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/layout.tsx"
    click Page "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/page.tsx"
    click CSS "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/globals.css"
    click Header "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/components/Header.tsx"
    click Select "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/components/Select.tsx"
    click ParkForm "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/components/ParkVehicleForm.tsx"
    click SlotList "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/components/ParkingSlotList.tsx"
    click Service "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/services/parking.service.ts"
    click CalcUtil "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/utils/calculation.util.ts"
    click SlotEnum "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/enums/slot-type.enum.ts"
    click VehicleEnum "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/enums/vehicle-type.enum.ts"
    click EntranceType "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/types/entrance.type.ts"
    click ParkingType "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/types/parking.type.ts"
    click VehicleType "https://github.com/misaelmamangun/megaworld-parking-system/blob/main/app/types/vehicle.type.ts"

    %% Styles
    classDef hosting fill:#008080,stroke:#004c4c,color:#ffffff
    classDef external fill:#ADD8E6,stroke:#6495ED,color:#000000
    classDef next fill:#FFA500,stroke:#CC8400,color:#000000
    classDef config fill:#20B2AA,stroke:#187F6E,color:#ffffff
    classDef ui fill:#ADD8E6,stroke:#87CEEB,color:#000000
    classDef service fill:#90EE90,stroke:#32CD32,color:#000000
    classDef utils fill:#D3D3D3,stroke:#A9A9A9,color:#000000
    classDef enums fill:#D3D3D3,stroke:#A9A9A9,color:#000000
    classDef types fill:#D3D3D3,stroke:#A9A9A9,color:#000000
```
