# lee-dongwook/product_engineering architecture

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

- Interactive diagram: https://gitdiagram.com/lee-dongwook/product_engineering
- Repository: https://github.com/lee-dongwook/product_engineering

## Overview

This is an AI-assisted supply-chain platform: a manager requests a product’s purchase proposal, the backend gathers tenant-scoped inventory and sales history, runs demand/supplier/supervisor workflow stages, and saves a draft for review. Users can then approve, modify, or reject proposals, with decision events and metrics; workflow progress is also exposed through streaming endpoints. Authentication and tenant context guard API access. The README documents frontend, SSE, and workflow capabilities; several tracking and persistence implementations were not sampled, so their internal connections are omitted.

Main entry points: [`app/api/v1/router.py`](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/router.py) (API router), [`app/api/v1/endpoints/orders.py`](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/orders.py) (Proposal decisions), [`app/services/prediction_service.py`](https://github.com/lee-dongwook/product_engineering/blob/main/app/services/prediction_service.py) (Prediction orchestration), [`app/api/deps.py`](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/deps.py) (Identity and roles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_web["Next.js interface<br/>[page.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and access"]
  node_api_router["API router<br/>[router.py]"]
  node_auth_api["Login and profile<br/>[auth.py]"]
  node_identity["Identity and roles<br/>[deps.py]"]
  node_security["JWT security<br/>[security.py]"]
  node_inventory_api["Product inventory API<br/>[inventory.py]"]
  node_orders_api["Proposal decisions<br/>[orders.py]"]
  node_stream_api["Progress streaming API<br/>[streaming.py]"]
  node_tracking_api["Tracking API<br/>[tracking.py]"]
end

subgraph group_planning["Inventory planning"]
  node_prediction["Prediction orchestration"]
  node_inventory_service["Inventory and draft service"]
  node_sales_service["Sales history service"]
  node_agent_workflow["SCM agent workflow<br/>[agent_workflow.py]"]
end

subgraph group_workflow["Workflow tracking"]
  node_tracked_workflow["Tracked workflow runner"]
  node_execution_service["Execution history service"]
  node_worker["Async worker tasks<br/>[tasks.py]"]
end

subgraph group_persistence["Data and storage"]
  node_database_session["Database sessions<br/>[database.py]"]
  node_models["Tenant and SCM models<br/>[domain.py]"]
  node_workflow_model["Workflow execution model"]
end

node_user(("SCM user"))
node_postgres[("PostgreSQL")]

node_user -->|"reviews proposals"| node_web
node_web -.->|"uses"| node_api_client
node_api_client -.->|"REST and SSE"| node_api_router
node_api_router -->|"routes"| node_auth_api
node_api_router -->|"routes"| node_inventory_api
node_api_router -->|"routes"| node_orders_api
node_api_router -->|"routes"| node_stream_api
node_api_router -->|"routes"| node_tracking_api
node_auth_api -->|"loads profile"| node_identity
node_auth_api -->|"verifies and issues JWT"| node_security
node_identity -->|"decodes token"| node_security
node_inventory_api -->|"checks access"| node_identity
node_orders_api -->|"checks roles"| node_identity
node_orders_api -->|"runs prediction"| node_prediction
node_stream_api -->|"streams prediction"| node_prediction
node_prediction -->|"loads product; saves draft"| node_inventory_service
node_prediction -->|"loads sales history"| node_sales_service
node_prediction -->|"creates and runs"| node_agent_workflow
node_orders_api -->|"uses inventory service"| node_inventory_service
node_orders_api -->|"reads and records decisions"| node_postgres
node_database_session -->|"uses ORM base"| node_models
node_database_session -->|"opens sessions"| node_postgres
node_execution_service -->|"persists executions"| node_workflow_model
node_worker -->|"runs workflow"| node_agent_workflow
node_tracked_workflow -.->|"tracks execution"| node_execution_service

click node_web "https://github.com/lee-dongwook/product_engineering/blob/main/frontend/app/orders/page.tsx"
click node_api_client "https://github.com/lee-dongwook/product_engineering/blob/main/frontend/lib/api.ts"
click node_api_router "https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/router.py"
click node_auth_api "https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/auth.py"
click node_identity "https://github.com/lee-dongwook/product_engineering/blob/main/app/api/deps.py"
click node_security "https://github.com/lee-dongwook/product_engineering/blob/main/app/core/security.py"
click node_inventory_api "https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/inventory.py"
click node_orders_api "https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/orders.py"
click node_stream_api "https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/streaming.py"
click node_tracking_api "https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/tracking.py"
click node_prediction "https://github.com/lee-dongwook/product_engineering/blob/main/app/services/prediction_service.py"
click node_inventory_service "https://github.com/lee-dongwook/product_engineering/blob/main/app/services/inventory_service.py"
click node_sales_service "https://github.com/lee-dongwook/product_engineering/blob/main/app/services/sales_record_service.py"
click node_agent_workflow "https://github.com/lee-dongwook/product_engineering/blob/main/app/services/agent_workflow.py"
click node_tracked_workflow "https://github.com/lee-dongwook/product_engineering/blob/main/app/services/run_tracked_workflow.py"
click node_execution_service "https://github.com/lee-dongwook/product_engineering/blob/main/app/services/workflow_execution_service.py"
click node_worker "https://github.com/lee-dongwook/product_engineering/blob/main/app/worker/tasks.py"
click node_database_session "https://github.com/lee-dongwook/product_engineering/blob/main/app/core/database.py"
click node_models "https://github.com/lee-dongwook/product_engineering/blob/main/app/models/domain.py"
click node_workflow_model "https://github.com/lee-dongwook/product_engineering/blob/main/app/models/workflow_execution.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_web,node_api_client,node_user toneBlue
class node_api_router,node_auth_api,node_identity,node_security,node_inventory_api,node_orders_api,node_stream_api,node_tracking_api,node_postgres toneAmber
class node_prediction,node_inventory_service,node_sales_service,node_agent_workflow toneMint
class node_tracked_workflow,node_execution_service,node_worker toneRose
class node_database_session,node_models,node_workflow_model toneIndigo
```

## Components

### Web interface

- [Next.js interface](https://github.com/lee-dongwook/product_engineering/blob/main/frontend/app/orders/page.tsx): `frontend/app/orders/page.tsx`
- [API client](https://github.com/lee-dongwook/product_engineering/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`

### API and access

- [API router](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/router.py): `app/api/v1/router.py`
- [Login and profile](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/auth.py): `app/api/v1/endpoints/auth.py`
- [Identity and roles](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/deps.py): `app/api/deps.py`
- [JWT security](https://github.com/lee-dongwook/product_engineering/blob/main/app/core/security.py): `app/core/security.py`
- [Product inventory API](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/inventory.py): `app/api/v1/endpoints/inventory.py`
- [Proposal decisions](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/orders.py): `app/api/v1/endpoints/orders.py`
- [Progress streaming API](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/streaming.py): `app/api/v1/endpoints/streaming.py`
- [Tracking API](https://github.com/lee-dongwook/product_engineering/blob/main/app/api/v1/endpoints/tracking.py): `app/api/v1/endpoints/tracking.py`

### Inventory planning

- [Prediction orchestration](https://github.com/lee-dongwook/product_engineering/blob/main/app/services/prediction_service.py): `app/services/prediction_service.py`
- [Inventory and draft service](https://github.com/lee-dongwook/product_engineering/blob/main/app/services/inventory_service.py): `app/services/inventory_service.py`
- [Sales history service](https://github.com/lee-dongwook/product_engineering/blob/main/app/services/sales_record_service.py): `app/services/sales_record_service.py`
- [SCM agent workflow](https://github.com/lee-dongwook/product_engineering/blob/main/app/services/agent_workflow.py): `app/services/agent_workflow.py`

### Workflow tracking

- [Tracked workflow runner](https://github.com/lee-dongwook/product_engineering/blob/main/app/services/run_tracked_workflow.py): `app/services/run_tracked_workflow.py`
- [Execution history service](https://github.com/lee-dongwook/product_engineering/blob/main/app/services/workflow_execution_service.py): `app/services/workflow_execution_service.py`
- [Async worker tasks](https://github.com/lee-dongwook/product_engineering/blob/main/app/worker/tasks.py): `app/worker/tasks.py`

### Data and storage

- [Database sessions](https://github.com/lee-dongwook/product_engineering/blob/main/app/core/database.py): `app/core/database.py`
- [Tenant and SCM models](https://github.com/lee-dongwook/product_engineering/blob/main/app/models/domain.py): `app/models/domain.py`
- [Workflow execution model](https://github.com/lee-dongwook/product_engineering/blob/main/app/models/workflow_execution.py): `app/models/workflow_execution.py`

### Other components

- **SCM user**
- **PostgreSQL**

## Connections

- SCM user → Next.js interface: reviews proposals
- Next.js interface → API client: uses
- API client → API router: REST and SSE
- API router → Login and profile: routes (evidence: `app/api/v1/router.py`)
- API router → Product inventory API: routes (evidence: `app/api/v1/router.py`)
- API router → Proposal decisions: routes (evidence: `app/api/v1/router.py`)
- API router → Progress streaming API: routes (evidence: `app/api/v1/router.py`)
- API router → Tracking API: routes (evidence: `app/api/v1/router.py`)
- Login and profile → Identity and roles: loads profile (evidence: `app/api/v1/endpoints/auth.py`)
- Login and profile → JWT security: verifies and issues JWT (evidence: `app/api/v1/endpoints/auth.py`)
- Identity and roles → JWT security: decodes token (evidence: `app/api/deps.py`)
- Product inventory API → Identity and roles: checks access (evidence: `app/api/v1/endpoints/inventory.py`)
- Proposal decisions → Identity and roles: checks roles (evidence: `app/api/v1/endpoints/orders.py`)
- Proposal decisions → Prediction orchestration: runs prediction (evidence: `app/api/v1/endpoints/orders.py`)
- Progress streaming API → Prediction orchestration: streams prediction (evidence: `app/api/v1/endpoints/streaming.py`)
- Prediction orchestration → Inventory and draft service: loads product; saves draft (evidence: `app/services/prediction_service.py`)
- Prediction orchestration → Sales history service: loads sales history (evidence: `app/services/prediction_service.py`)
- Prediction orchestration → SCM agent workflow: creates and runs (evidence: `app/services/prediction_service.py`)
- Proposal decisions → Inventory and draft service: uses inventory service (evidence: `app/api/v1/endpoints/orders.py`)
- Proposal decisions → PostgreSQL: reads and records decisions (evidence: `app/api/v1/endpoints/orders.py`)
- Database sessions → Tenant and SCM models: uses ORM base (evidence: `app/core/database.py`)
- Database sessions → PostgreSQL: opens sessions (evidence: `app/core/database.py`)
- Execution history service → Workflow execution model: persists executions (evidence: `app/services/workflow_execution_service.py`)
- Async worker tasks → SCM agent workflow: runs workflow (evidence: `app/worker/tasks.py`)
- Tracked workflow runner → Execution history service: tracks execution
