# aemorabr/ecommerce-recommendation-system architecture

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

- Interactive diagram: https://gitdiagram.com/aemorabr/ecommerce-recommendation-system
- Repository: https://github.com/aemorabr/ecommerce-recommendation-system

## Overview

This is a full-stack e-commerce recommendation product. The main user flow is browsing the catalog in the frontend, requesting recommendations through the Node.js API, and receiving strategy-selected results from the FastAPI ML service; the Node API also enriches recommendations with product records. The ML service supports collaborative, content-based, hybrid, and popularity strategies, similar-item/customer queries, and model retraining and metrics. Some UI and ML wiring is documented rather than visible in excerpts, so those links cite the README; unsampled implementation details are not inferred.

Main entry points: [`ml-service/app/main.py`](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/main.py) (ML API), [`backend-nodejs/server.js`](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/server.js) (Express server), [`ml-service/app/services/database.py`](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/database.py) (ML DB access), [`backend-nodejs/routes/products.js`](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/routes/products.js) (Product routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_catalog["Catalog UI<br/>[index.tsx]"]
  node_ui_components["Catalog widgets"]
  node_frontend_api["Frontend API client<br/>[api.ts]"]
end

subgraph group_backend["Backend API"]
  node_express["Express server<br/>[server.js]"]
  node_product_routes["Product routes<br/>[products.js]"]
  node_customer_routes["Customer routes<br/>[customers.js]"]
  node_recommendation_routes["Recommendation routes<br/>[recommendations.js]"]
  node_node_db["Node DB access<br/>[database.js]"]
end

subgraph group_ml["Recommendation ML"]
  node_ml_api["ML API<br/>[main.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_cf["Collaborative filtering"]
  node_content["Content recommender"]
  node_hybrid["Hybrid recommender"]
  node_embedding_generator["Customer embeddings"]
  node_cache["Recommendation cache<br/>[cache.py]"]
  node_ml_db["ML DB access<br/>[database.py]"]
end

subgraph group_data["Data"]
  node_postgres[("PostgreSQL + pgvector<br/>[schema.sql]")]
end

node_shopper(("Shopper"))

node_shopper -->|"browses"| node_catalog
node_catalog -.->|"requests data"| node_frontend_api
node_frontend_api -.->|"calls API"| node_express
node_express -->|"routes requests"| node_product_routes
node_express -->|"routes requests"| node_customer_routes
node_express -->|"routes requests"| node_recommendation_routes
node_product_routes -->|"queries products"| node_node_db
node_customer_routes -->|"queries history"| node_node_db
node_product_routes -->|"requests recommendations"| node_ml_api
node_recommendation_routes -->|"proxies requests"| node_ml_api
node_ml_api -->|"validates responses"| node_schemas
node_ml_api -->|"dispatches strategy"| node_cf
node_ml_api -->|"dispatches strategy"| node_content
node_ml_api -->|"dispatches strategy"| node_hybrid
node_ml_api -->|"retraining uses"| node_embedding_generator
node_ml_api -->|"invalidates entries"| node_cache
node_cf -->|"reads and writes"| node_ml_db
node_content -->|"reads and writes"| node_ml_db
node_embedding_generator -->|"reads and writes"| node_ml_db
node_hybrid -.->|"combines strategies"| node_cf
node_hybrid -.->|"combines strategies"| node_content
node_ml_db -.->|"queries embeddings"| node_postgres
node_node_db -.->|"queries catalog"| node_postgres

click node_catalog "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/frontend/src/pages/index.tsx"
click node_ui_components "https://github.com/aemorabr/ecommerce-recommendation-system/tree/main/frontend/src/components"
click node_frontend_api "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/frontend/src/services/api.ts"
click node_express "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/server.js"
click node_product_routes "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/routes/products.js"
click node_customer_routes "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/routes/customers.js"
click node_recommendation_routes "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/routes/recommendations.js"
click node_node_db "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/services/database.js"
click node_ml_api "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/main.py"
click node_schemas "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/models/schemas.py"
click node_cf "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/recommendation_engine.py"
click node_content "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/content_based_recommender.py"
click node_hybrid "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/hybrid_recommender.py"
click node_embedding_generator "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/customer_embedding_generator.py"
click node_cache "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/cache.py"
click node_ml_db "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/database.py"
click node_postgres "https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/database/schema.sql"

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_catalog,node_ui_components,node_frontend_api toneBlue
class node_express,node_product_routes,node_customer_routes,node_recommendation_routes,node_node_db toneAmber
class node_ml_api,node_schemas,node_cf,node_content,node_hybrid,node_embedding_generator,node_cache,node_ml_db toneMint
class node_postgres toneRose
class node_shopper toneIndigo
```

## Components

### Storefront

- [Catalog UI](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/frontend/src/pages/index.tsx): `frontend/src/pages/index.tsx`
- [Catalog widgets](https://github.com/aemorabr/ecommerce-recommendation-system/tree/main/frontend/src/components): `frontend/src/components`
- [Frontend API client](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### Backend API

- [Express server](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/server.js): `backend-nodejs/server.js`
- [Product routes](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/routes/products.js): `backend-nodejs/routes/products.js`
- [Customer routes](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/routes/customers.js): `backend-nodejs/routes/customers.js`
- [Recommendation routes](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/routes/recommendations.js): `backend-nodejs/routes/recommendations.js`
- [Node DB access](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/backend-nodejs/services/database.js): `backend-nodejs/services/database.js`

### Recommendation ML

- [ML API](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/main.py): `ml-service/app/main.py`
- [API schemas](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/models/schemas.py): `ml-service/app/models/schemas.py`
- [Collaborative filtering](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/recommendation_engine.py): `ml-service/app/services/recommendation_engine.py`
- [Content recommender](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/content_based_recommender.py): `ml-service/app/services/content_based_recommender.py`
- [Hybrid recommender](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/hybrid_recommender.py): `ml-service/app/services/hybrid_recommender.py`
- [Customer embeddings](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/customer_embedding_generator.py): `ml-service/app/services/customer_embedding_generator.py`
- [Recommendation cache](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/cache.py): `ml-service/app/services/cache.py`
- [ML DB access](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/ml-service/app/services/database.py): `ml-service/app/services/database.py`

### Data

- [PostgreSQL + pgvector](https://github.com/aemorabr/ecommerce-recommendation-system/blob/main/database/schema.sql): `database/schema.sql`

### Other components

- **Shopper**

## Connections

- Shopper → Catalog UI: browses (evidence: `README.md`)
- Catalog UI → Frontend API client: requests data
- Frontend API client → Express server: calls API
- Express server → Product routes: routes requests (evidence: `backend-nodejs/server.js`)
- Express server → Customer routes: routes requests (evidence: `backend-nodejs/server.js`)
- Express server → Recommendation routes: routes requests (evidence: `backend-nodejs/server.js`)
- Product routes → Node DB access: queries products (evidence: `backend-nodejs/routes/products.js`)
- Customer routes → Node DB access: queries history (evidence: `backend-nodejs/routes/customers.js`)
- Product routes → ML API: requests recommendations (evidence: `backend-nodejs/routes/products.js`)
- Recommendation routes → ML API: proxies requests (evidence: `backend-nodejs/routes/recommendations.js`)
- ML API → API schemas: validates responses (evidence: `ml-service/app/main.py`)
- ML API → Collaborative filtering: dispatches strategy (evidence: `ml-service/app/main.py`)
- ML API → Content recommender: dispatches strategy (evidence: `ml-service/app/main.py`)
- ML API → Hybrid recommender: dispatches strategy (evidence: `ml-service/app/main.py`)
- ML API → Customer embeddings: retraining uses (evidence: `ml-service/app/main.py`)
- ML API → Recommendation cache: invalidates entries (evidence: `ml-service/app/main.py`)
- Collaborative filtering → ML DB access: reads and writes (evidence: `ml-service/app/services/recommendation_engine.py`)
- Content recommender → ML DB access: reads and writes (evidence: `ml-service/app/services/content_based_recommender.py`)
- Customer embeddings → ML DB access: reads and writes (evidence: `ml-service/app/services/customer_embedding_generator.py`)
- Hybrid recommender → Collaborative filtering: combines strategies
- Hybrid recommender → Content recommender: combines strategies
- ML DB access → PostgreSQL + pgvector: queries embeddings
- Node DB access → PostgreSQL + pgvector: queries catalog
