# narayanaswamy-cts/storeops-harness architecture

> Architecture diagram of the GitHub repository narayanaswamy-cts/storeops-harness, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/narayanaswamy-cts/storeops-harness
- Repository: https://github.com/narayanaswamy-cts/storeops-harness

## Overview

StoreOps is a FastAPI retail-operations API. Its main workflow is client request → feature route → service rules → repository, with paginated responses for list operations. Activities and programmes publish domain events that the alert subscriber turns into alerts; reports aggregate read-only projections through ports. The README documents all five feature areas and the event and reporting boundaries. Repository bodies are explicitly in-memory stubs. Edges reflect README statements or source-index references; unsampled wiring is shown only where documented.

Main entry points: [`src/storeops/main.py`](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/main.py) (FastAPI app), [`src/storeops/modules/reports/service.py`](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/reports/service.py) (Metrics aggregation), [`src/storeops/core/events.py`](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/events.py) (Domain event bus), [`src/storeops/modules/activities/service.py`](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/activities/service.py) (Activity rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["API boundary"]
  node_app["FastAPI app<br/>[main.py]"]
end

subgraph group_domains["Operations domains"]
  node_activity_routes["Activity routes<br/>[routes.py]"]
  node_activity_service["Activity rules<br/>[service.py]"]
  node_activity_store[("Activity repository<br/>[repository.py]")]
  node_programme_routes["Programme routes<br/>[routes.py]"]
  node_programme_service["Programme rules<br/>[service.py]"]
  node_programme_store[("Programme repository<br/>[repository.py]")]
  node_staff_routes["Staff routes<br/>[routes.py]"]
  node_staff_service["Staff rules<br/>[service.py]"]
  node_staff_store[("Staff repository<br/>[repository.py]")]
  node_alerts_routes["Alert routes<br/>[routes.py]"]
  node_alerts_service["Alert rules<br/>[service.py]"]
  node_alerts_store[("Alert repository<br/>[repository.py]")]
  node_alert_subscriber["Event subscriber<br/>[subscribers.py]"]
  node_staff_port["Staff read port<br/>[port.py]"]
end

subgraph group_shared["Shared infrastructure"]
  node_event_bus["Domain event bus<br/>[events.py]"]
  node_shared_config["Shared settings<br/>[config.py]"]
  node_shared_errors["Error envelope<br/>[errors.py]"]
  node_pagination["Pagination contract<br/>[pagination.py]"]
  node_event_dependencies["Bus dependency<br/>[deps.py]"]
end

subgraph group_insights["Reporting"]
  node_reports_routes["Report routes<br/>[routes.py]"]
  node_reports_service["Metrics aggregation<br/>[service.py]"]
  node_reports_store[("Report repository<br/>[repository.py]")]
  node_report_ports["Metrics read ports<br/>[ports.py]"]
end

node_client(("API client"))

node_client -->|"sends request"| node_app
node_app -->|"mounts routes"| node_activity_routes
node_app -->|"mounts routes"| node_programme_routes
node_app -->|"mounts routes"| node_staff_routes
node_app -->|"mounts routes"| node_alerts_routes
node_app -->|"mounts routes"| node_reports_routes
node_activity_routes -->|"calls"| node_activity_service
node_activity_service -->|"reads writes"| node_activity_store
node_programme_routes -->|"calls"| node_programme_service
node_programme_service -->|"reads writes"| node_programme_store
node_staff_routes -->|"calls"| node_staff_service
node_staff_service -->|"reads"| node_staff_store
node_alerts_routes -->|"calls"| node_alerts_service
node_alerts_service -->|"reads writes"| node_alerts_store
node_reports_routes -->|"calls"| node_reports_service
node_reports_service -->|"reads"| node_reports_store
node_reports_service -->|"uses protocols"| node_report_ports
node_report_ports -->|"uses staff contract"| node_staff_port
node_reports_service -->|"reads projection"| node_activity_service
node_reports_service -->|"reads projection"| node_programme_service
node_reports_service -->|"reads projection"| node_staff_service
node_reports_service -->|"reads projection"| node_alerts_service
node_activity_service -->|"publishes events"| node_event_bus
node_programme_service -->|"publishes events"| node_event_bus
node_event_bus -->|"dispatches events"| node_alert_subscriber
node_alert_subscriber -->|"raises alerts"| node_alerts_service
node_app -->|"wires at startup"| node_event_bus
node_event_dependencies -->|"provides bus"| node_event_bus
node_activity_routes -->|"uses contract"| node_pagination
node_programme_routes -->|"uses contract"| node_pagination
node_staff_routes -->|"uses contract"| node_pagination
node_alerts_routes -->|"uses contract"| node_pagination
node_app -->|"configures"| node_shared_config
node_app -->|"handles errors"| node_shared_errors

click node_app "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/main.py"
click node_activity_routes "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/activities/routes.py"
click node_activity_service "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/activities/service.py"
click node_activity_store "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/activities/repository.py"
click node_programme_routes "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/programmes/routes.py"
click node_programme_service "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/programmes/service.py"
click node_programme_store "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/programmes/repository.py"
click node_staff_routes "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/staff/routes.py"
click node_staff_service "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/staff/service.py"
click node_staff_store "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/staff/repository.py"
click node_alerts_routes "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/alerts/routes.py"
click node_alerts_service "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/alerts/service.py"
click node_alerts_store "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/alerts/repository.py"
click node_alert_subscriber "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/alerts/subscribers.py"
click node_reports_routes "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/reports/routes.py"
click node_reports_service "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/reports/service.py"
click node_reports_store "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/reports/repository.py"
click node_report_ports "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/reports/ports.py"
click node_staff_port "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/staff/port.py"
click node_event_bus "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/events.py"
click node_shared_config "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/config.py"
click node_shared_errors "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/errors.py"
click node_pagination "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/pagination.py"
click node_event_dependencies "https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/deps.py"

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_client toneBlue
class node_activity_routes,node_activity_service,node_activity_store,node_programme_routes,node_programme_service,node_programme_store,node_staff_routes,node_staff_service,node_staff_store,node_alerts_routes,node_alerts_service,node_alerts_store,node_alert_subscriber,node_staff_port toneAmber
class node_event_bus,node_shared_config,node_shared_errors,node_pagination,node_event_dependencies toneMint
class node_reports_routes,node_reports_service,node_reports_store,node_report_ports toneRose
```

## Components

### API boundary

- [FastAPI app](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/main.py): `src/storeops/main.py`

### Operations domains

- [Activity routes](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/activities/routes.py): `src/storeops/modules/activities/routes.py`
- [Activity rules](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/activities/service.py): `src/storeops/modules/activities/service.py`
- [Activity repository](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/activities/repository.py): `src/storeops/modules/activities/repository.py`
- [Programme routes](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/programmes/routes.py): `src/storeops/modules/programmes/routes.py`
- [Programme rules](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/programmes/service.py): `src/storeops/modules/programmes/service.py`
- [Programme repository](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/programmes/repository.py): `src/storeops/modules/programmes/repository.py`
- [Staff routes](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/staff/routes.py): `src/storeops/modules/staff/routes.py`
- [Staff rules](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/staff/service.py): `src/storeops/modules/staff/service.py`
- [Staff repository](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/staff/repository.py): `src/storeops/modules/staff/repository.py`
- [Alert routes](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/alerts/routes.py): `src/storeops/modules/alerts/routes.py`
- [Alert rules](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/alerts/service.py): `src/storeops/modules/alerts/service.py`
- [Alert repository](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/alerts/repository.py): `src/storeops/modules/alerts/repository.py`
- [Event subscriber](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/alerts/subscribers.py): `src/storeops/modules/alerts/subscribers.py`
- [Staff read port](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/staff/port.py): `src/storeops/modules/staff/port.py`

### Shared infrastructure

- [Domain event bus](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/events.py): `src/storeops/core/events.py`
- [Shared settings](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/config.py): `src/storeops/core/config.py`
- [Error envelope](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/errors.py): `src/storeops/core/errors.py`
- [Pagination contract](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/pagination.py): `src/storeops/core/pagination.py`
- [Bus dependency](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/core/deps.py): `src/storeops/core/deps.py`

### Reporting

- [Report routes](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/reports/routes.py): `src/storeops/modules/reports/routes.py`
- [Metrics aggregation](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/reports/service.py): `src/storeops/modules/reports/service.py`
- [Report repository](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/reports/repository.py): `src/storeops/modules/reports/repository.py`
- [Metrics read ports](https://github.com/narayanaswamy-cts/storeops-harness/blob/main/src/storeops/modules/reports/ports.py): `src/storeops/modules/reports/ports.py`

### Other components

- **API client**

## Connections

- API client → FastAPI app: sends request (evidence: `README.md`)
- FastAPI app → Activity routes: mounts routes (evidence: `src/storeops/main.py`)
- FastAPI app → Programme routes: mounts routes (evidence: `src/storeops/main.py`)
- FastAPI app → Staff routes: mounts routes (evidence: `src/storeops/main.py`)
- FastAPI app → Alert routes: mounts routes (evidence: `src/storeops/main.py`)
- FastAPI app → Report routes: mounts routes (evidence: `src/storeops/main.py`)
- Activity routes → Activity rules: calls (evidence: `src/storeops/modules/activities/routes.py`)
- Activity rules → Activity repository: reads writes (evidence: `src/storeops/modules/activities/service.py`)
- Programme routes → Programme rules: calls (evidence: `src/storeops/modules/programmes/routes.py`)
- Programme rules → Programme repository: reads writes (evidence: `src/storeops/modules/programmes/service.py`)
- Staff routes → Staff rules: calls (evidence: `src/storeops/modules/staff/routes.py`)
- Staff rules → Staff repository: reads (evidence: `src/storeops/modules/staff/service.py`)
- Alert routes → Alert rules: calls (evidence: `src/storeops/modules/alerts/routes.py`)
- Alert rules → Alert repository: reads writes (evidence: `src/storeops/modules/alerts/service.py`)
- Report routes → Metrics aggregation: calls (evidence: `src/storeops/modules/reports/routes.py`)
- Metrics aggregation → Report repository: reads (evidence: `src/storeops/modules/reports/service.py`)
- Metrics aggregation → Metrics read ports: uses protocols (evidence: `src/storeops/modules/reports/service.py`)
- Metrics read ports → Staff read port: uses staff contract (evidence: `src/storeops/modules/reports/ports.py`)
- Metrics aggregation → Activity rules: reads projection (evidence: `README.md`)
- Metrics aggregation → Programme rules: reads projection (evidence: `README.md`)
- Metrics aggregation → Staff rules: reads projection (evidence: `README.md`)
- Metrics aggregation → Alert rules: reads projection (evidence: `README.md`)
- Activity rules → Domain event bus: publishes events (evidence: `src/storeops/modules/activities/service.py`)
- Programme rules → Domain event bus: publishes events (evidence: `src/storeops/modules/programmes/service.py`)
- Domain event bus → Event subscriber: dispatches events (evidence: `README.md`)
- Event subscriber → Alert rules: raises alerts (evidence: `src/storeops/modules/alerts/subscribers.py`)
- FastAPI app → Domain event bus: wires at startup (evidence: `README.md`)
- Bus dependency → Domain event bus: provides bus (evidence: `src/storeops/core/deps.py`)
- Activity routes → Pagination contract: uses contract (evidence: `src/storeops/modules/activities/routes.py`)
- Programme routes → Pagination contract: uses contract (evidence: `src/storeops/modules/programmes/routes.py`)
- Staff routes → Pagination contract: uses contract (evidence: `src/storeops/modules/staff/routes.py`)
- Alert routes → Pagination contract: uses contract (evidence: `src/storeops/modules/alerts/routes.py`)
- FastAPI app → Shared settings: configures (evidence: `src/storeops/main.py`)
- FastAPI app → Error envelope: handles errors (evidence: `src/storeops/main.py`)
