# thanhtran0311/smart_e_hub architecture

> Architecture diagram of the GitHub repository thanhtran0311/smart_e_hub, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thanhtran0311/smart_e_hub
- Repository: https://github.com/thanhtran0311/smart_e_hub

## Overview

Smart E-Mobility Hub is a client-side SPA for student mobility services and operator management. Students search hubs, reserve vehicles or parking/charging, pick up and return vehicles; operators monitor the network, dispatch vehicles, manage charging, incidents, simulations, recommendations and telemetry. The app wires role-aware routes and use cases over shared domain rules and browser-persisted state. The README documents demo data, IndexedDB persistence and simulated device control. Some links rely on documented capabilities or import references; unsampled implementation details are not assumed.

Main entry points: [`src/app.js`](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/app.js) (App bootstrap), [`src/pages/operator/views.js`](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/pages/operator/views.js) (Operator views), [`src/pages/student`](https://github.com/thanhtran0311/smart_e_hub/tree/main/src/pages/student) (Student views), [`src/application/student.js`](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/student.js) (Student use cases)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_app["App bootstrap<br/>[app.js]"]
  node_router["Role-aware router<br/>[router.js]"]
  node_student_views["Student views"]
  node_operator_views["Operator views<br/>[views.js]"]
  node_ui["UI components<br/>[ui.js]"]
  node_hub_map["Hub map<br/>[hub-map.js]"]
end

subgraph group_workflows["Application workflows"]
  node_student_service["Student use cases<br/>[student.js]"]
  node_hub_service["Hub search<br/>[hubs.js]"]
  node_vehicle_service["Vehicle operations<br/>[vehicle.js]"]
  node_charging_service["Charging operations<br/>[charging.js]"]
  node_operator_service["Operator operations<br/>[operator.js]"]
  node_simulation["What-if simulation<br/>[simulation.js]"]
  node_telemetry["Telemetry processing<br/>[telemetry.js]"]
  node_monitoring["Network monitoring<br/>[monitoring.js]"]
  node_device_control["Device control<br/>[device-control.js]"]
end

subgraph group_domain["Domain services"]
  node_domain_rules["Resource and booking rules<br/>[student-rules.js]"]
  node_entities["Domain entities<br/>[entities.js]"]
  node_incidents["Incident management<br/>[incidents.js]"]
  node_notifications["Notifications<br/>[notifications.js]"]
  node_status["Status vocabulary<br/>[status.js]"]
end

subgraph group_platform["Browser infrastructure"]
  node_store[("Persistent state<br/>[store.js]")]
  node_device["Simulated devices<br/>[device.js]"]
  node_operational_snapshot["Operational snapshot"]
  node_shared_snapshot["Shared snapshot<br/>[shared-snapshot.js]"]
end

subgraph group_demo["Demo data"]
  node_demo_data["Seed data"]
end

node_student(("Student"))
node_operator(("Operator"))

node_student -->|"uses"| node_app
node_operator -->|"uses"| node_app
node_app -->|"initializes"| node_router
node_router -->|"routes student"| node_student_views
node_router -->|"routes operator"| node_operator_views
node_app -->|"wires"| node_student_service
node_app -->|"wires"| node_charging_service
node_app -->|"wires"| node_operator_service
node_app -->|"wires"| node_telemetry
node_app -->|"wires"| node_monitoring
node_app -->|"uses"| node_store
node_app -->|"uses"| node_ui
node_app -->|"renders"| node_student_views
node_app -->|"renders"| node_operator_views
node_student_views -->|"invokes"| node_student_service
node_student_views -->|"invokes"| node_charging_service
node_student_views -->|"uses"| node_ui
node_operator_views -->|"invokes"| node_operator_service
node_operator_views -->|"invokes"| node_simulation
node_operator_views -->|"invokes"| node_monitoring
node_operator_views -->|"invokes"| node_telemetry
node_operator_views -->|"uses"| node_hub_map
node_student_views -->|"uses"| node_hub_map
node_student_service -->|"uses"| node_hub_service
node_student_service -->|"uses"| node_vehicle_service
node_student_service -->|"uses"| node_telemetry
node_student_service -->|"applies"| node_domain_rules
node_charging_service -->|"requests control"| node_device_control
node_device_control -->|"dispatches"| node_device
node_operator_service -->|"uses"| node_simulation
node_operator_service -->|"uses"| node_telemetry
node_telemetry -->|"updates readings"| node_charging_service
node_telemetry -->|"checks load"| node_monitoring
node_monitoring -->|"records alerts"| node_notifications
node_monitoring -->|"reads metrics"| node_domain_rules
node_incidents -->|"notifies"| node_notifications
node_domain_rules -->|"checks resources"| node_entities
node_store -->|"loads"| node_operational_snapshot
node_store -->|"loads"| node_shared_snapshot
node_store -.->|"migrates legacy data"| node_demo_data
node_app -.->|"loads demo data"| node_demo_data

click node_app "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/app.js"
click node_router "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/router.js"
click node_student_views "https://github.com/thanhtran0311/smart_e_hub/tree/main/src/pages/student"
click node_operator_views "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/pages/operator/views.js"
click node_ui "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/components/ui.js"
click node_hub_map "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/components/hub-map.js"
click node_student_service "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/student.js"
click node_hub_service "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/hubs.js"
click node_vehicle_service "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/vehicle.js"
click node_charging_service "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/charging.js"
click node_operator_service "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/operator.js"
click node_simulation "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/simulation.js"
click node_telemetry "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/telemetry.js"
click node_monitoring "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/monitoring.js"
click node_device_control "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/device-control.js"
click node_domain_rules "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/domain/student-rules.js"
click node_entities "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/domain/entities.js"
click node_incidents "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/domain/incidents.js"
click node_notifications "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/domain/notifications.js"
click node_status "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/utils/status.js"
click node_store "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/infrastructure/store.js"
click node_device "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/infrastructure/device.js"
click node_operational_snapshot "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/infrastructure/operational-snapshot.js"
click node_shared_snapshot "https://github.com/thanhtran0311/smart_e_hub/blob/main/src/infrastructure/shared-snapshot.js"
click node_demo_data "https://github.com/thanhtran0311/smart_e_hub/tree/main/data"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_router,node_student_views,node_operator_views,node_ui,node_hub_map toneBlue
class node_student_service,node_hub_service,node_vehicle_service,node_charging_service,node_operator_service,node_simulation,node_telemetry,node_monitoring,node_device_control toneAmber
class node_domain_rules,node_entities,node_incidents,node_notifications,node_status toneMint
class node_store,node_device,node_operational_snapshot,node_shared_snapshot toneRose
class node_demo_data,node_student,node_operator toneIndigo
```

## Components

### User interface

- [App bootstrap](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/app.js): `src/app.js`
- [Role-aware router](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/router.js): `src/router.js`
- [Student views](https://github.com/thanhtran0311/smart_e_hub/tree/main/src/pages/student): `src/pages/student`
- [Operator views](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/pages/operator/views.js): `src/pages/operator/views.js`
- [UI components](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/components/ui.js): `src/components/ui.js`
- [Hub map](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/components/hub-map.js): `src/components/hub-map.js`

### Application workflows

- [Student use cases](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/student.js): `src/application/student.js`
- [Hub search](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/hubs.js): `src/application/hubs.js`
- [Vehicle operations](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/vehicle.js): `src/application/vehicle.js`
- [Charging operations](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/charging.js): `src/application/charging.js`
- [Operator operations](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/operator.js): `src/application/operator.js`
- [What-if simulation](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/simulation.js): `src/application/simulation.js`
- [Telemetry processing](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/telemetry.js): `src/application/telemetry.js`
- [Network monitoring](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/monitoring.js): `src/application/monitoring.js`
- [Device control](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/application/device-control.js): `src/application/device-control.js`

### Domain services

- [Resource and booking rules](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/domain/student-rules.js): `src/domain/student-rules.js`
- [Domain entities](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/domain/entities.js): `src/domain/entities.js`
- [Incident management](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/domain/incidents.js): `src/domain/incidents.js`
- [Notifications](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/domain/notifications.js): `src/domain/notifications.js`
- [Status vocabulary](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/utils/status.js): `src/utils/status.js`

### Browser infrastructure

- [Persistent state](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/infrastructure/store.js): `src/infrastructure/store.js`
- [Simulated devices](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/infrastructure/device.js): `src/infrastructure/device.js`
- [Operational snapshot](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/infrastructure/operational-snapshot.js): `src/infrastructure/operational-snapshot.js`
- [Shared snapshot](https://github.com/thanhtran0311/smart_e_hub/blob/main/src/infrastructure/shared-snapshot.js): `src/infrastructure/shared-snapshot.js`

### Demo data

- [Seed data](https://github.com/thanhtran0311/smart_e_hub/tree/main/data): `data`

### Other components

- **Student**
- **Operator**

## Connections

- Student → App bootstrap: uses (evidence: `README.md`)
- Operator → App bootstrap: uses (evidence: `README.md`)
- App bootstrap → Role-aware router: initializes (evidence: `src/app.js`)
- Role-aware router → Student views: routes student (evidence: `README.md`)
- Role-aware router → Operator views: routes operator (evidence: `README.md`)
- App bootstrap → Student use cases: wires (evidence: `src/app.js`)
- App bootstrap → Charging operations: wires (evidence: `src/app.js`)
- App bootstrap → Operator operations: wires (evidence: `src/app.js`)
- App bootstrap → Telemetry processing: wires (evidence: `src/app.js`)
- App bootstrap → Network monitoring: wires (evidence: `src/app.js`)
- App bootstrap → Persistent state: uses (evidence: `src/app.js`)
- App bootstrap → UI components: uses (evidence: `src/app.js`)
- App bootstrap → Student views: renders (evidence: `src/app.js`)
- App bootstrap → Operator views: renders (evidence: `src/app.js`)
- Student views → Student use cases: invokes (evidence: `src/pages/student/hub-search.js`)
- Student views → Charging operations: invokes (evidence: `src/pages/student/parking-charging.js`)
- Student views → UI components: uses (evidence: `src/pages/student/parking-charging.js`)
- Operator views → Operator operations: invokes (evidence: `src/pages/operator/views.js`)
- Operator views → What-if simulation: invokes (evidence: `src/pages/operator/views.js`)
- Operator views → Network monitoring: invokes (evidence: `src/pages/operator/views.js`)
- Operator views → Telemetry processing: invokes (evidence: `src/pages/operator/views.js`)
- Operator views → Hub map: uses (evidence: `src/pages/operator/views.js`)
- Student views → Hub map: uses (evidence: `src/pages/student/hub-search.js`)
- Student use cases → Hub search: uses (evidence: `src/application/student.js`)
- Student use cases → Vehicle operations: uses (evidence: `src/application/student.js`)
- Student use cases → Telemetry processing: uses (evidence: `src/application/student.js`)
- Student use cases → Resource and booking rules: applies (evidence: `src/application/student.js`)
- Charging operations → Device control: requests control (evidence: `src/application/charging.js`)
- Device control → Simulated devices: dispatches (evidence: `src/application/device-control.js`)
- Operator operations → What-if simulation: uses (evidence: `src/application/operator.js`)
- Operator operations → Telemetry processing: uses (evidence: `src/application/operator.js`)
- Telemetry processing → Charging operations: updates readings (evidence: `src/application/telemetry.js`)
- Telemetry processing → Network monitoring: checks load (evidence: `src/application/telemetry.js`)
- Network monitoring → Notifications: records alerts (evidence: `src/application/monitoring.js`)
- Network monitoring → Resource and booking rules: reads metrics (evidence: `src/application/monitoring.js`)
- Incident management → Notifications: notifies (evidence: `src/domain/incidents.js`)
- Resource and booking rules → Domain entities: checks resources
- Persistent state → Operational snapshot: loads (evidence: `src/infrastructure/store.js`)
- Persistent state → Shared snapshot: loads (evidence: `src/infrastructure/store.js`)
- Persistent state → Seed data: migrates legacy data
- App bootstrap → Seed data: loads demo data
