# iammanojpatel/order-hub architecture

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

- Interactive diagram: https://gitdiagram.com/iammanojpatel/order-hub
- Repository: https://github.com/iammanojpatel/order-hub

## Overview

This is a full-stack product-catalog application: users browse and manage tenant-scoped products through a Next.js interface and FastAPI API. The principal workflow is product request → API route → application use case → domain rules → transactional persistence; changes also produce events for asynchronous outbox dispatch. The README confirms the Next.js products experience and MySQL-backed API. The graph includes the documented event-driven capability, but sampled code shows only a logging subscriber. Some frontend page wiring and database setup are unsampled, so those connections are omitted.

Main entry points: [`backend/src/app/main.py`](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/main.py) (App composition), [`backend/src/app/catalog/api/router.py`](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/api/router.py) (Catalog API), [`backend/src/app/catalog/application/services.py`](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/application/services.py) (Catalog use cases), [`frontend/src/features/products/api/products.server.ts`](https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/features/products/api/products.server.ts) (Server API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Product Web"]
  node_products_page["Products page<br/>[page.tsx]"]
  node_create_form["Create form"]
  node_product_actions["Product actions<br/>[actions.ts]"]
  node_product_client["Server API client<br/>[products.server.ts]"]
  node_product_schemas["Product schemas<br/>[schemas.ts]"]
end

subgraph group_api["API Layer"]
  node_api_service["Catalog API<br/>[router.py]"]
  node_api_schemas["API schemas<br/>[schemas.py]"]
  node_app_root["App composition<br/>[main.py]"]
end

subgraph group_catalog["Catalog Domain"]
  node_use_cases["Catalog use cases<br/>[services.py]"]
  node_ports["Catalog ports<br/>[ports.py]"]
  node_product_model["Product aggregate<br/>[model.py]"]
  node_repository_port["Repository contract<br/>[repository.py]"]
end

subgraph group_infra["Persistence and Events"]
  node_sql_uow["SQL unit of work<br/>[uow.py]"]
  node_sql_repository["SQL repositories<br/>[repository.py]"]
  node_tables["Catalog tables<br/>[tables.py]"]
  node_outbox["Outbox relay and bus<br/>[outbox.py]"]
end

subgraph group_shared["Shared Services"]
  node_auth["Bearer authentication<br/>[auth.py]"]
  node_db_support["Database setup<br/>[db.py]"]
  node_security["Authorization rules<br/>[security.py]"]
  node_middleware["Request middleware<br/>[middleware.py]"]
  node_problems["Problem responses<br/>[problems.py]"]
  node_settings["Application settings<br/>[config.py]"]
end

node_user(("Catalog user"))
node_database[("MySQL database")]

node_user -->|"uses"| node_products_page
node_create_form -->|"submits"| node_product_actions
node_product_actions -->|"calls"| node_product_client
node_product_client -->|"validates with"| node_product_schemas
node_product_client -->|"requests products"| node_api_service
node_app_root -->|"registers"| node_api_service
node_app_root -->|"configures"| node_sql_uow
node_app_root -->|"installs"| node_middleware
node_app_root -->|"registers"| node_problems
node_app_root -->|"creates"| node_db_support
node_app_root -->|"starts relay"| node_outbox
node_api_service -->|"resolves principal"| node_auth
node_api_service -->|"dispatches"| node_use_cases
node_api_service -->|"uses"| node_api_schemas
node_use_cases -->|"checks permissions"| node_security
node_use_cases -->|"uses"| node_ports
node_use_cases -->|"invokes"| node_product_model
node_ports -->|"defines access"| node_repository_port
node_sql_uow -->|"provides"| node_sql_repository
node_sql_uow -->|"appends events"| node_outbox
node_sql_repository -->|"queries"| node_tables
node_tables -->|"uses database types"| node_db_support
node_db_support -.->|"connects"| node_database
node_sql_repository -->|"hydrates"| node_product_model
node_outbox -->|"stores events"| node_database
node_settings -->|"configures"| node_app_root

click node_products_page "https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/app/products/page.tsx"
click node_create_form "https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/features/products/components/CreateProductForm.tsx"
click node_product_actions "https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/features/products/api/actions.ts"
click node_product_client "https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/features/products/api/products.server.ts"
click node_product_schemas "https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/features/products/model/schemas.ts"
click node_api_service "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/api/router.py"
click node_api_schemas "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/api/schemas.py"
click node_app_root "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/main.py"
click node_auth "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/api/auth.py"
click node_use_cases "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/application/services.py"
click node_ports "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/application/ports.py"
click node_product_model "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/domain/model.py"
click node_repository_port "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/domain/repository.py"
click node_sql_uow "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/infrastructure/uow.py"
click node_sql_repository "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/infrastructure/repository.py"
click node_tables "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/infrastructure/tables.py"
click node_db_support "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/infrastructure/db.py"
click node_outbox "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/infrastructure/outbox.py"
click node_security "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/application/security.py"
click node_middleware "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/api/middleware.py"
click node_problems "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/api/problems.py"
click node_settings "https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/config.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_products_page,node_create_form,node_product_actions,node_product_client,node_product_schemas,node_user toneBlue
class node_api_service,node_api_schemas,node_app_root,node_database toneAmber
class node_use_cases,node_ports,node_product_model,node_repository_port toneMint
class node_sql_uow,node_sql_repository,node_tables,node_outbox toneRose
class node_auth,node_db_support,node_security,node_middleware,node_problems,node_settings toneIndigo
```

## Components

### Product Web

- [Products page](https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/app/products/page.tsx): `frontend/src/app/products/page.tsx`
- [Create form](https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/features/products/components/CreateProductForm.tsx): `frontend/src/features/products/components/CreateProductForm.tsx`
- [Product actions](https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/features/products/api/actions.ts): `frontend/src/features/products/api/actions.ts`
- [Server API client](https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/features/products/api/products.server.ts): `frontend/src/features/products/api/products.server.ts`
- [Product schemas](https://github.com/iammanojpatel/order-hub/blob/main/frontend/src/features/products/model/schemas.ts): `frontend/src/features/products/model/schemas.ts`

### API Layer

- [Catalog API](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/api/router.py): `backend/src/app/catalog/api/router.py`
- [API schemas](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/api/schemas.py): `backend/src/app/catalog/api/schemas.py`
- [App composition](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/main.py): `backend/src/app/main.py`

### Catalog Domain

- [Catalog use cases](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/application/services.py): `backend/src/app/catalog/application/services.py`
- [Catalog ports](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/application/ports.py): `backend/src/app/catalog/application/ports.py`
- [Product aggregate](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/domain/model.py): `backend/src/app/catalog/domain/model.py`
- [Repository contract](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/domain/repository.py): `backend/src/app/catalog/domain/repository.py`

### Persistence and Events

- [SQL unit of work](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/infrastructure/uow.py): `backend/src/app/catalog/infrastructure/uow.py`
- [SQL repositories](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/infrastructure/repository.py): `backend/src/app/catalog/infrastructure/repository.py`
- [Catalog tables](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/catalog/infrastructure/tables.py): `backend/src/app/catalog/infrastructure/tables.py`
- [Outbox relay and bus](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/infrastructure/outbox.py): `backend/src/app/shared/infrastructure/outbox.py`

### Shared Services

- [Bearer authentication](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/api/auth.py): `backend/src/app/shared/api/auth.py`
- [Database setup](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/infrastructure/db.py): `backend/src/app/shared/infrastructure/db.py`
- [Authorization rules](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/application/security.py): `backend/src/app/shared/application/security.py`
- [Request middleware](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/api/middleware.py): `backend/src/app/shared/api/middleware.py`
- [Problem responses](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/shared/api/problems.py): `backend/src/app/shared/api/problems.py`
- [Application settings](https://github.com/iammanojpatel/order-hub/blob/main/backend/src/app/config.py): `backend/src/app/config.py`

### Other components

- **Catalog user**
- **MySQL database**

## Connections

- Catalog user → Products page: uses
- Create form → Product actions: submits (evidence: `frontend/src/features/products/components/CreateProductForm.tsx`)
- Product actions → Server API client: calls (evidence: `frontend/src/features/products/api/actions.ts`)
- Server API client → Product schemas: validates with (evidence: `frontend/src/features/products/api/products.server.ts`)
- Server API client → Catalog API: requests products (evidence: `frontend/src/features/products/api/products.server.ts`)
- App composition → Catalog API: registers (evidence: `backend/src/app/main.py`)
- App composition → SQL unit of work: configures (evidence: `backend/src/app/main.py`)
- App composition → Request middleware: installs (evidence: `backend/src/app/main.py`)
- App composition → Problem responses: registers (evidence: `backend/src/app/main.py`)
- App composition → Database setup: creates (evidence: `backend/src/app/main.py`)
- App composition → Outbox relay and bus: starts relay (evidence: `backend/src/app/main.py`)
- Catalog API → Bearer authentication: resolves principal (evidence: `backend/src/app/catalog/api/router.py`)
- Catalog API → Catalog use cases: dispatches (evidence: `backend/src/app/catalog/api/router.py`)
- Catalog API → API schemas: uses (evidence: `backend/src/app/catalog/api/router.py`)
- Catalog use cases → Authorization rules: checks permissions (evidence: `backend/src/app/catalog/application/services.py`)
- Catalog use cases → Catalog ports: uses (evidence: `backend/src/app/catalog/application/services.py`)
- Catalog use cases → Product aggregate: invokes (evidence: `backend/src/app/catalog/application/services.py`)
- Catalog ports → Repository contract: defines access (evidence: `backend/src/app/catalog/application/ports.py`)
- SQL unit of work → SQL repositories: provides (evidence: `backend/src/app/catalog/infrastructure/uow.py`)
- SQL unit of work → Outbox relay and bus: appends events (evidence: `backend/src/app/catalog/infrastructure/uow.py`)
- SQL repositories → Catalog tables: queries (evidence: `backend/src/app/catalog/infrastructure/repository.py`)
- Catalog tables → Database setup: uses database types (evidence: `backend/src/app/catalog/infrastructure/tables.py`)
- Database setup → MySQL database: connects
- SQL repositories → Product aggregate: hydrates (evidence: `backend/src/app/catalog/infrastructure/repository.py`)
- Outbox relay and bus → MySQL database: stores events (evidence: `backend/src/app/shared/infrastructure/outbox.py`)
- Application settings → App composition: configures (evidence: `backend/src/app/main.py`)
