# mohamedmahmouddorah/cairo-metro architecture

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

- Interactive diagram: https://gitdiagram.com/mohamedmahmouddorah/cairo-metro
- Repository: https://github.com/mohamedmahmouddorah/cairo-metro

## Overview

Metro Cairo is a Flutter app for finding Cairo Metro routes and stations. The main user flow is to choose stations or a place, optionally use the device location, calculate a route or nearest station, and inspect the result; search history supports repeating and deleting trips. The README also documents an interactive metro map and routing preferences. The graph reflects these documented capabilities, but Dart implementation excerpts were not provided, so unverified calls between app components are shown as dashed links without evidence paths.

Main entry points: [`lib/features/home/views/home_view.dart`](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/views/home_view.dart) (Home and results), [`lib/features/home/controllers/home_controller.dart`](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/controllers/home_controller.dart) (Trip controller), [`lib/core/services/graph_service.dart`](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/graph_service.dart) (Route optimizer), [`lib/features/nearest_station/controllers/metro_controller.dart`](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/nearest_station/controllers/metro_controller.dart) (Nearest station screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["User experience"]
  node_app["App entry<br/>[main.dart]"]
  node_home["Home and results<br/>[home_view.dart]"]
  node_home_logic["Trip controller"]
  node_station_picker["Station picker"]
  node_result_view["Route results<br/>[result_view.dart]"]
  node_metro_map["Metro map<br/>[metro_view.dart]"]
end

subgraph group_domain["Metro routing"]
  node_graph["Route optimizer<br/>[graph_service.dart]"]
  node_network_data["Metro network data<br/>[metro_data.dart]"]
  node_route_models["Route models<br/>[route_result.dart]"]
  node_preferences["Route preferences"]
end

subgraph group_discovery["Location and places"]
  node_nearest_logic["Nearest station logic"]
  node_location["Device location"]
  node_nearest_ui["Nearest station screen"]
  node_place_search["Place search"]
  node_map_picker["Map place picker"]
end

subgraph group_persistence["Local state"]
  node_history["Trip history"]
  node_recent_trip["Recent trips"]
end

node_user(("App user"))

node_user -->|"opens"| node_home
node_app -.->|"starts"| node_home
node_home -.->|"delegates trips"| node_home_logic
node_home -->|"selects stations"| node_station_picker
node_home_logic -.->|"requests route"| node_graph
node_graph -->|"uses network"| node_network_data
node_graph -.->|"produces route"| node_route_models
node_home -.->|"shows results"| node_result_view
node_home_logic -->|"uses preferences"| node_preferences
node_user -->|"requests nearby"| node_nearest_ui
node_nearest_ui -->|"gets coordinates"| node_location
node_nearest_ui -.->|"finds nearest"| node_nearest_logic
node_nearest_logic -->|"checks stations"| node_network_data
node_user -.->|"searches places"| node_place_search
node_user -->|"picks location"| node_map_picker
node_metro_map -->|"sets stations"| node_home_logic
node_home_logic -->|"records searches"| node_history
node_history -->|"serializes trips"| node_recent_trip

click node_app "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/main.dart"
click node_home "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/views/home_view.dart"
click node_home_logic "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/controllers/home_controller.dart"
click node_station_picker "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/views/widgets/station_search_dialog.dart"
click node_result_view "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/views/result_view.dart"
click node_metro_map "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/nearest_station/views/metro_view.dart"
click node_graph "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/graph_service.dart"
click node_network_data "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/data/metro_data.dart"
click node_route_models "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/data/models/route_result.dart"
click node_nearest_logic "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/nearest_station_service.dart"
click node_location "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/location_service.dart"
click node_nearest_ui "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/nearest_station/controllers/metro_controller.dart"
click node_place_search "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/places/controllers/place_search_controller.dart"
click node_map_picker "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/places/views/map_picker_view.dart"
click node_history "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/history_service.dart"
click node_recent_trip "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/recent_trip_service.dart"
click node_preferences "https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/data/models/route_preference.dart"

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_home,node_home_logic,node_station_picker,node_result_view,node_metro_map,node_user toneBlue
class node_graph,node_network_data,node_route_models,node_preferences toneAmber
class node_nearest_logic,node_location,node_nearest_ui,node_place_search,node_map_picker toneMint
class node_history,node_recent_trip toneRose
```

## Components

### User experience

- [App entry](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/main.dart): `lib/main.dart`
- [Home and results](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/views/home_view.dart): `lib/features/home/views/home_view.dart`
- [Trip controller](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/controllers/home_controller.dart): `lib/features/home/controllers/home_controller.dart`
- [Station picker](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/views/widgets/station_search_dialog.dart): `lib/features/home/views/widgets/station_search_dialog.dart`
- [Route results](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/home/views/result_view.dart): `lib/features/home/views/result_view.dart`
- [Metro map](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/nearest_station/views/metro_view.dart): `lib/features/nearest_station/views/metro_view.dart`

### Metro routing

- [Route optimizer](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/graph_service.dart): `lib/core/services/graph_service.dart`
- [Metro network data](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/data/metro_data.dart): `lib/data/metro_data.dart`
- [Route models](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/data/models/route_result.dart): `lib/data/models/route_result.dart`
- [Route preferences](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/data/models/route_preference.dart): `lib/data/models/route_preference.dart`

### Location and places

- [Nearest station logic](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/nearest_station_service.dart): `lib/core/services/nearest_station_service.dart`
- [Device location](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/location_service.dart): `lib/core/services/location_service.dart`
- [Nearest station screen](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/nearest_station/controllers/metro_controller.dart): `lib/features/nearest_station/controllers/metro_controller.dart`
- [Place search](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/places/controllers/place_search_controller.dart): `lib/features/places/controllers/place_search_controller.dart`
- [Map place picker](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/features/places/views/map_picker_view.dart): `lib/features/places/views/map_picker_view.dart`

### Local state

- [Trip history](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/history_service.dart): `lib/core/services/history_service.dart`
- [Recent trips](https://github.com/mohamedmahmouddorah/cairo-metro/blob/main/lib/core/services/recent_trip_service.dart): `lib/core/services/recent_trip_service.dart`

### Other components

- **App user**

## Connections

- App user → Home and results: opens (evidence: `README.md`)
- App entry → Home and results: starts
- Home and results → Trip controller: delegates trips
- Home and results → Station picker: selects stations (evidence: `README.md`)
- Trip controller → Route optimizer: requests route
- Route optimizer → Metro network data: uses network (evidence: `README.md`)
- Route optimizer → Route models: produces route
- Home and results → Route results: shows results
- Trip controller → Route preferences: uses preferences (evidence: `README.md`)
- App user → Nearest station screen: requests nearby (evidence: `README.md`)
- Nearest station screen → Device location: gets coordinates (evidence: `README.md`)
- Nearest station screen → Nearest station logic: finds nearest
- Nearest station logic → Metro network data: checks stations (evidence: `README.md`)
- App user → Place search: searches places
- App user → Map place picker: picks location (evidence: `README.md`)
- Metro map → Trip controller: sets stations (evidence: `README.md`)
- Trip controller → Trip history: records searches (evidence: `README.md`)
- Trip history → Recent trips: serializes trips (evidence: `README.md`)
