# hannakot62/mci architecture

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

- Interactive diagram: https://gitdiagram.com/hannakot62/mci
- Repository: https://github.com/hannakot62/mci

## Overview

MCI is a full-stack tool for generating mock transport cargo, identifying MCI units in its packaging hierarchy, and tracking transport through dispatch and delivery. The main workflow runs from setup configuration in the React UI through the Fastify setup API and cargo-generation domain into persistent transport data; users can then inspect the transport tree and update its status. Separate UI branches visualize the cargo hierarchy and expose timing metrics. The tree and sampled files support the route and client connections shown; some internal service-to-repository wiring is not shown where source was unsampled.

Main entry points: [`front/src/App.tsx`](https://github.com/hannakot62/mci/blob/main/front/src/App.tsx) (App shell), [`back/src/modules/setup/setup.routes.ts`](https://github.com/hannakot62/mci/blob/main/back/src/modules/setup/setup.routes.ts) (Setup routes), [`front/src/api/client.ts`](https://github.com/hannakot62/mci/blob/main/front/src/api/client.ts) (API client), [`back/src/bootstrap/createApp.ts`](https://github.com/hannakot62/mci/blob/main/back/src/bootstrap/createApp.ts) (Fastify server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React interface"]
  node_app["App shell<br/>[App.tsx]"]
  node_setup_ui["Setup panel<br/>[useSetupPanel.ts]"]
  node_actions_ui["Transport actions"]
  node_tree_ui["Cargo tree<br/>[CargoTree.tsx]"]
  node_timing_ui["Timing log<br/>[useTimingLog.ts]"]
  node_client["API client<br/>[client.ts]"]
end

subgraph group_api["Fastify API"]
  node_setup_routes["Setup routes<br/>[setup.routes.ts]"]
  node_transport_routes["Transport routes"]
  node_api_server["Fastify server<br/>[createApp.ts]"]
end

subgraph group_domain["Transport domain"]
  node_cargo_generator["Mock cargo generator"]
  node_setup_validation["Setup validation"]
  node_transport_service["Transport service"]
  node_packaging_tree["Packaging tree builder"]
  node_mci_service["MCI service<br/>[mci.service.ts]"]
  node_mci_repository["MCI repository<br/>[mci.repository.ts]"]
  node_transport_repository["Transport repository"]
end

subgraph group_observability["Timing metrics"]
  node_metrics_routes["Metrics routes<br/>[metrics.routes.ts]"]
  node_metrics_store["Timing store<br/>[timer.store.ts]"]
end

node_user(("User"))
node_database[("SQLite database<br/>[prisma.ts]")]

node_user -->|"uses"| node_app
node_app -->|"renders"| node_setup_ui
node_app -->|"renders"| node_actions_ui
node_app -->|"renders"| node_tree_ui
node_app -->|"renders"| node_timing_ui
node_setup_ui -->|"requests setup"| node_client
node_actions_ui -->|"requests status"| node_client
node_tree_ui -->|"loads transport"| node_client
node_timing_ui -->|"loads metrics"| node_client
node_client -->|"sends API requests"| node_api_server
node_api_server -->|"dispatches"| node_setup_routes
node_api_server -->|"dispatches"| node_transport_routes
node_api_server -->|"dispatches"| node_metrics_routes
node_setup_routes -->|"validates groups"| node_setup_validation
node_setup_routes -->|"generates cargo"| node_cargo_generator
node_setup_routes -->|"reads products"| node_database
node_setup_routes -->|"loads locations"| node_transport_service
node_transport_routes -->|"loads transports"| node_transport_service
node_transport_routes -->|"updates MCI status"| node_mci_service
node_transport_service -->|"builds tree"| node_packaging_tree
node_metrics_routes -->|"reads and clears"| node_metrics_store
node_mci_repository -->|"queries and updates"| node_database
node_transport_repository -->|"queries and updates"| node_database

click node_app "https://github.com/hannakot62/mci/blob/main/front/src/App.tsx"
click node_setup_ui "https://github.com/hannakot62/mci/blob/main/front/src/features/setup/useSetupPanel.ts"
click node_actions_ui "https://github.com/hannakot62/mci/blob/main/front/src/features/action-bar/useTransportActions.ts"
click node_tree_ui "https://github.com/hannakot62/mci/blob/main/front/src/features/cargo-tree/CargoTree.tsx"
click node_timing_ui "https://github.com/hannakot62/mci/blob/main/front/src/features/timing-log/useTimingLog.ts"
click node_client "https://github.com/hannakot62/mci/blob/main/front/src/api/client.ts"
click node_setup_routes "https://github.com/hannakot62/mci/blob/main/back/src/modules/setup/setup.routes.ts"
click node_transport_routes "https://github.com/hannakot62/mci/blob/main/back/src/modules/transport/transport.routes.ts"
click node_metrics_routes "https://github.com/hannakot62/mci/blob/main/back/src/modules/metrics/metrics.routes.ts"
click node_cargo_generator "https://github.com/hannakot62/mci/blob/main/back/src/modules/setup/mockCargo.service.ts"
click node_setup_validation "https://github.com/hannakot62/mci/blob/main/back/src/modules/setup/setup.validation.ts"
click node_transport_service "https://github.com/hannakot62/mci/blob/main/back/src/modules/transport/transport.service.ts"
click node_packaging_tree "https://github.com/hannakot62/mci/blob/main/back/src/modules/transport/packagingTree.builder.ts"
click node_mci_service "https://github.com/hannakot62/mci/blob/main/back/src/modules/mci/mci.service.ts"
click node_mci_repository "https://github.com/hannakot62/mci/blob/main/back/src/modules/mci/mci.repository.ts"
click node_transport_repository "https://github.com/hannakot62/mci/blob/main/back/src/modules/transport/transport.repository.ts"
click node_metrics_store "https://github.com/hannakot62/mci/blob/main/back/src/modules/metrics/timer.store.ts"
click node_database "https://github.com/hannakot62/mci/blob/main/back/src/infrastructure/db/prisma.ts"
click node_api_server "https://github.com/hannakot62/mci/blob/main/back/src/bootstrap/createApp.ts"

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_setup_ui,node_actions_ui,node_tree_ui,node_timing_ui,node_client,node_user toneBlue
class node_setup_routes,node_transport_routes,node_api_server,node_database toneAmber
class node_cargo_generator,node_setup_validation,node_transport_service,node_packaging_tree,node_mci_service,node_mci_repository,node_transport_repository toneMint
class node_metrics_routes,node_metrics_store toneRose
```

## Components

### React interface

- [App shell](https://github.com/hannakot62/mci/blob/main/front/src/App.tsx): `front/src/App.tsx`
- [Setup panel](https://github.com/hannakot62/mci/blob/main/front/src/features/setup/useSetupPanel.ts): `front/src/features/setup/useSetupPanel.ts`
- [Transport actions](https://github.com/hannakot62/mci/blob/main/front/src/features/action-bar/useTransportActions.ts): `front/src/features/action-bar/useTransportActions.ts`
- [Cargo tree](https://github.com/hannakot62/mci/blob/main/front/src/features/cargo-tree/CargoTree.tsx): `front/src/features/cargo-tree/CargoTree.tsx`
- [Timing log](https://github.com/hannakot62/mci/blob/main/front/src/features/timing-log/useTimingLog.ts): `front/src/features/timing-log/useTimingLog.ts`
- [API client](https://github.com/hannakot62/mci/blob/main/front/src/api/client.ts): `front/src/api/client.ts`

### Fastify API

- [Setup routes](https://github.com/hannakot62/mci/blob/main/back/src/modules/setup/setup.routes.ts): `back/src/modules/setup/setup.routes.ts`
- [Transport routes](https://github.com/hannakot62/mci/blob/main/back/src/modules/transport/transport.routes.ts): `back/src/modules/transport/transport.routes.ts`
- [Fastify server](https://github.com/hannakot62/mci/blob/main/back/src/bootstrap/createApp.ts): `back/src/bootstrap/createApp.ts`

### Transport domain

- [Mock cargo generator](https://github.com/hannakot62/mci/blob/main/back/src/modules/setup/mockCargo.service.ts): `back/src/modules/setup/mockCargo.service.ts`
- [Setup validation](https://github.com/hannakot62/mci/blob/main/back/src/modules/setup/setup.validation.ts): `back/src/modules/setup/setup.validation.ts`
- [Transport service](https://github.com/hannakot62/mci/blob/main/back/src/modules/transport/transport.service.ts): `back/src/modules/transport/transport.service.ts`
- [Packaging tree builder](https://github.com/hannakot62/mci/blob/main/back/src/modules/transport/packagingTree.builder.ts): `back/src/modules/transport/packagingTree.builder.ts`
- [MCI service](https://github.com/hannakot62/mci/blob/main/back/src/modules/mci/mci.service.ts): `back/src/modules/mci/mci.service.ts`
- [MCI repository](https://github.com/hannakot62/mci/blob/main/back/src/modules/mci/mci.repository.ts): `back/src/modules/mci/mci.repository.ts`
- [Transport repository](https://github.com/hannakot62/mci/blob/main/back/src/modules/transport/transport.repository.ts): `back/src/modules/transport/transport.repository.ts`

### Timing metrics

- [Metrics routes](https://github.com/hannakot62/mci/blob/main/back/src/modules/metrics/metrics.routes.ts): `back/src/modules/metrics/metrics.routes.ts`
- [Timing store](https://github.com/hannakot62/mci/blob/main/back/src/modules/metrics/timer.store.ts): `back/src/modules/metrics/timer.store.ts`

### Other components

- **User**
- [SQLite database](https://github.com/hannakot62/mci/blob/main/back/src/infrastructure/db/prisma.ts): `back/src/infrastructure/db/prisma.ts`

## Connections

- User → App shell: uses
- App shell → Setup panel: renders
- App shell → Transport actions: renders
- App shell → Cargo tree: renders
- App shell → Timing log: renders
- Setup panel → API client: requests setup
- Transport actions → API client: requests status
- Cargo tree → API client: loads transport
- Timing log → API client: loads metrics
- API client → Fastify server: sends API requests
- Fastify server → Setup routes: dispatches
- Fastify server → Transport routes: dispatches
- Fastify server → Metrics routes: dispatches
- Setup routes → Setup validation: validates groups
- Setup routes → Mock cargo generator: generates cargo
- Setup routes → SQLite database: reads products
- Setup routes → Transport service: loads locations
- Transport routes → Transport service: loads transports
- Transport routes → MCI service: updates MCI status
- Transport service → Packaging tree builder: builds tree
- Metrics routes → Timing store: reads and clears
- MCI repository → SQLite database: queries and updates
- Transport repository → SQLite database: queries and updates
