# bobbibao/ecommerce-with-agentic-ai architecture

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

- Interactive diagram: https://gitdiagram.com/bobbibao/ecommerce-with-agentic-ai
- Repository: https://github.com/bobbibao/ecommerce-with-agentic-ai

## Overview

This monorepo combines an e-commerce application with a Python continuous-improvement agent. The principal workflow observes shop operations, investigates anomalies using SOPs and prior cases, requests a bounded human decision, applies approved changes through the shop API, measures KPI impact, and records outcomes for reuse. The graph also preserves the storefront, administration, and CI Console capabilities. Several agent and web subsystems are represented by their existing enclosing directories because their implementation files were not sampled; their connections follow the README’s documented loop rather than inferred source calls.

Main entry points: [`apps/web-ecommerce/src/app/api`](https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/web-ecommerce/src/app/api) (Shop and agent APIs), [`apps/agent-service/src/ci_agent/interfaces/http/app.py`](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/interfaces/http/app.py) (Agent HTTP API), [`apps/web-ecommerce/src/core/server/database/Database.Provider.ts`](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/web-ecommerce/src/core/server/database/Database.Provider.ts) (Shop database), [`apps/agent-service/src/ci_agent/application/use_cases/detect_signals.py`](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/detect_signals.py) (Signal detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_agent["Improvement agent"]
  node_agent_api["Agent HTTP API<br/>[app.py]"]
  node_detect["Signal detection<br/>[detect_signals.py]"]
  node_investigate["Case investigation<br/>[investigate.py]"]
  node_reasoner["Reasoning engine<br/>[llm_reasoner.py]"]
  node_plan["Improvement planning"]
  node_approval["Human approval<br/>[ask_human.py]"]
  node_execute["Plan execution<br/>[execute_plan.py]"]
  node_measure["KPI measurement<br/>[measure_outcome.py]"]
  node_learn["Outcome learning<br/>[learn.py]"]
  node_agent_store[("Agent case store")]
end

subgraph group_shop["E-commerce shop"]
  node_web_app["E-commerce app<br/>[server.ts]"]
  node_shop_db[("Shop database")]
  node_commerce["Storefront commerce"]
  node_admin["Shop administration"]
end

subgraph group_integration["Shop integration"]
  node_shop_api["Shop and agent APIs"]
  node_ci_console["CI Console"]
end

subgraph group_channels["Human channels"]
  node_notifications["Notification delivery"]
  node_messaging["Email, Telegram, Zalo, web"]
end

node_operator(("Shop operator"))
node_shop_user(("Shop customer"))
node_human(("Human decision-maker"))

node_operator -->|"starts or reviews"| node_agent_api
node_agent_api -->|"runs loop"| node_detect
node_detect -->|"finds anomalies"| node_investigate
node_investigate -->|"reasons against SOPs"| node_reasoner
node_investigate -->|"informs plan"| node_plan
node_plan -->|"requests decision"| node_approval
node_approval -->|"delivers question"| node_notifications
node_notifications -->|"sends via"| node_messaging
node_messaging -->|"collects decision"| node_human
node_approval -->|"acts when approved"| node_execute
node_execute -->|"applies approved change"| node_shop_api
node_shop_api -.->|"reads and writes"| node_shop_db
node_detect -->|"observes operations"| node_shop_db
node_measure -->|"measures KPI impact"| node_shop_db
node_execute -->|"precedes measurement"| node_measure
node_measure -->|"records outcome"| node_learn
node_learn -->|"stores reusable case"| node_agent_store
node_agent_api -.->|"persists agent state"| node_agent_store
node_shop_user -->|"shops"| node_commerce
node_commerce -.->|"uses shop APIs"| node_shop_api
node_operator -->|"manages shop"| node_admin
node_operator -->|"reviews improvements"| node_ci_console
node_ci_console -.->|"uses CI APIs"| node_shop_api
node_web_app -->|"initializes database"| node_shop_db
node_web_app -.->|"mounts API routes"| node_shop_api
node_agent_api -->|"asks for bounded decision"| node_human

click node_agent_api "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/interfaces/http/app.py"
click node_detect "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/detect_signals.py"
click node_investigate "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/investigate.py"
click node_reasoner "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/infrastructure/reasoning/llm_reasoner.py"
click node_plan "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/plan_improvement.py"
click node_approval "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/ask_human.py"
click node_notifications "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/services/notification_service.py"
click node_execute "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/execute_plan.py"
click node_measure "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/measure_outcome.py"
click node_learn "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/learn.py"
click node_agent_store "https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/infrastructure/persistence/postgres"
click node_web_app "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/web-ecommerce/server.ts"
click node_shop_api "https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/web-ecommerce/src/app/api"
click node_shop_db "https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/web-ecommerce/src/core/server/database/Database.Provider.ts"
click node_commerce "https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/web-ecommerce/src/core/client/features"
click node_admin "https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/web-ecommerce/src/core/client/features"
click node_ci_console "https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/web-ecommerce/src/core/client/features/ci-console"

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_agent_api,node_detect,node_investigate,node_reasoner,node_plan,node_approval,node_execute,node_measure,node_learn,node_agent_store toneBlue
class node_web_app,node_shop_db,node_commerce,node_admin toneAmber
class node_shop_api,node_ci_console toneMint
class node_notifications,node_messaging toneRose
class node_operator,node_shop_user,node_human toneIndigo
```

## Components

### Improvement agent

- [Agent HTTP API](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/interfaces/http/app.py): `apps/agent-service/src/ci_agent/interfaces/http/app.py`
- [Signal detection](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/detect_signals.py): `apps/agent-service/src/ci_agent/application/use_cases/detect_signals.py`
- [Case investigation](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/investigate.py): `apps/agent-service/src/ci_agent/application/use_cases/investigate.py`
- [Reasoning engine](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/infrastructure/reasoning/llm_reasoner.py): `apps/agent-service/src/ci_agent/infrastructure/reasoning/llm_reasoner.py`
- [Improvement planning](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/plan_improvement.py): `apps/agent-service/src/ci_agent/application/use_cases/plan_improvement.py`
- [Human approval](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/ask_human.py): `apps/agent-service/src/ci_agent/application/use_cases/ask_human.py`
- [Plan execution](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/execute_plan.py): `apps/agent-service/src/ci_agent/application/use_cases/execute_plan.py`
- [KPI measurement](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/measure_outcome.py): `apps/agent-service/src/ci_agent/application/use_cases/measure_outcome.py`
- [Outcome learning](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/use_cases/learn.py): `apps/agent-service/src/ci_agent/application/use_cases/learn.py`
- [Agent case store](https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/infrastructure/persistence/postgres): `apps/agent-service/src/ci_agent/infrastructure/persistence/postgres`

### E-commerce shop

- [E-commerce app](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/web-ecommerce/server.ts): `apps/web-ecommerce/server.ts`
- [Shop database](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/web-ecommerce/src/core/server/database/Database.Provider.ts): `apps/web-ecommerce/src/core/server/database/Database.Provider.ts`
- [Storefront commerce](https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/web-ecommerce/src/core/client/features): `apps/web-ecommerce/src/core/client/features`
- [Shop administration](https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/web-ecommerce/src/core/client/features): `apps/web-ecommerce/src/core/client/features`

### Shop integration

- [Shop and agent APIs](https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/web-ecommerce/src/app/api): `apps/web-ecommerce/src/app/api`
- [CI Console](https://github.com/bobbibao/ecommerce-with-agentic-ai/tree/feat/ci-t04-t10a/apps/web-ecommerce/src/core/client/features/ci-console): `apps/web-ecommerce/src/core/client/features/ci-console`

### Human channels

- [Notification delivery](https://github.com/bobbibao/ecommerce-with-agentic-ai/blob/feat/ci-t04-t10a/apps/agent-service/src/ci_agent/application/services/notification_service.py): `apps/agent-service/src/ci_agent/application/services/notification_service.py`
- **Email, Telegram, Zalo, web**

### Other components

- **Shop operator**
- **Shop customer**
- **Human decision-maker**

## Connections

- Shop operator → Agent HTTP API: starts or reviews (evidence: `README.md`)
- Agent HTTP API → Signal detection: runs loop (evidence: `README.md`)
- Signal detection → Case investigation: finds anomalies (evidence: `README.md`)
- Case investigation → Reasoning engine: reasons against SOPs (evidence: `README.md`)
- Case investigation → Improvement planning: informs plan (evidence: `README.md`)
- Improvement planning → Human approval: requests decision (evidence: `README.md`)
- Human approval → Notification delivery: delivers question (evidence: `README.md`)
- Notification delivery → Email, Telegram, Zalo, web: sends via (evidence: `README.md`)
- Email, Telegram, Zalo, web → Human decision-maker: collects decision (evidence: `README.md`)
- Human approval → Plan execution: acts when approved (evidence: `README.md`)
- Plan execution → Shop and agent APIs: applies approved change (evidence: `README.md`)
- Shop and agent APIs → Shop database: reads and writes (evidence: `apps/web-ecommerce/src/app/api/ApiBase.Controller.ts`)
- Signal detection → Shop database: observes operations (evidence: `README.md`)
- KPI measurement → Shop database: measures KPI impact (evidence: `README.md`)
- Plan execution → KPI measurement: precedes measurement (evidence: `README.md`)
- KPI measurement → Outcome learning: records outcome (evidence: `README.md`)
- Outcome learning → Agent case store: stores reusable case (evidence: `README.md`)
- Agent HTTP API → Agent case store: persists agent state (evidence: `apps/agent-service/src/ci_agent/interfaces/http/app.py`)
- Shop customer → Storefront commerce: shops (evidence: `README.md`)
- Storefront commerce → Shop and agent APIs: uses shop APIs
- Shop operator → Shop administration: manages shop (evidence: `README.md`)
- Shop operator → CI Console: reviews improvements (evidence: `README.md`)
- CI Console → Shop and agent APIs: uses CI APIs
- E-commerce app → Shop database: initializes database (evidence: `apps/web-ecommerce/server.ts`)
- E-commerce app → Shop and agent APIs: mounts API routes
- Agent HTTP API → Human decision-maker: asks for bounded decision (evidence: `README.md`)
