# phan-manh-dung/online-pc-store-be architecture

> Architecture diagram of the GitHub repository phan-manh-dung/online-pc-store-be, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phan-manh-dung/online-pc-store-be
- Repository: https://github.com/phan-manh-dung/online-pc-store-be

## Overview

##### Project type and purpose
- This is a Node.js-based, microservices back-end for an “Online PC Store.” There is no monolithic UI here; instead, we have an API Gateway in front of multiple domain-specific services (cart, order, payment, product, search, recommend, user). Each service is Dockerized, uses Redis for caching, and exposes its own REST endpoints.

##### File structure
- Top-level:
- .github/workflows & Jenkinsfile → CI/CD pipelines (GitHub Actions + Jenkins)
- docker-compose.yml → local multi-container orchestration
- BackEnd/src/API_Gateway → single entry point for clients
- BackEnd/src/{cart,order,payment,product,search,recommend,user}_service → seven independent microservices
- Each service has: Dockerfile, controller/router/service/model layers, Redis client under redis/v1, middleware for authentication.
- Shared patterns: MVC-style within each service, Redis caching layer, environment configuration, Docker builds, package.json per service.

##### README
- README only gives the project name (“Online-PC-Store”), confirming an e-commerce system.

##### Detail without overthinking
- Every service as its own component.
- Data stores and caches alongside each service.
- CI/CD pipeline as an ancillary flow into your container registry / cluster.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Clients" 
        Web["Web/Mobile Client"]:::edge
    end

    Web -->|"HTTPS"| APIGW

    %% Back-End and Microservices
    subgraph "Back-End"
        APIGW["API Gateway"]:::edge

        subgraph "Microservices"
            US["User Service"]:::micro
            PS["Product Service"]:::micro
            CS["Cart Service"]:::micro
            OS["Order Service"]:::micro
            Pays["Payment Service"]:::micro
            SS["Search Service"]:::micro
            RS["Recommend Service"]:::micro
        end
    end

    %% API Gateway routing
    APIGW -->|"routes to"| US
    APIGW -->|"routes to"| PS
    APIGW -->|"routes to"| CS
    APIGW -->|"routes to"| OS
    APIGW -->|"routes to"| Pays
    APIGW -->|"routes to"| SS
    APIGW -->|"routes to"| RS

    %% Service caches and databases
    US -->|"cached in"| USRedis["Redis"]:::cache
    US -->|"stores in"| USDB["Database"]:::db

    PS -->|"cached in"| PSRedis["Redis"]:::cache
    PS -->|"stores in"| PSDB["Database"]:::db
    PS -->|"uploads images to"| Cloudinary["Cloudinary"]:::external

    CS -->|"cached in"| CSRedis["Redis"]:::cache
    CS -->|"stores in"| CSDB["Database"]:::db

    OS -->|"cached in"| OSRedis["Redis"]:::cache
    OS -->|"stores in"| OSDB["Database"]:::db

    Pays -->|"cached in"| PaysRedis["Redis"]:::cache
    Pays -->|"stores in"| PaysDB["Database"]:::db
    Pays -->|"webhooks to/from"| PaymentProvider["Payment Provider"]:::external

    SS -->|"cached in"| SSRedis["Redis"]:::cache
    SS -->|"stores in"| SSDB["Database"]:::db

    RS -->|"cached in"| RSRedis["Redis"]:::cache
    RS -->|"stores in"| RSDB["Database"]:::db

    %% External CI/CD and orchestration
    CICDP["CI/CD Pipelines"]:::ci
    CICDP -->|"build & push images to"| Registry["Container Registry"]:::ci
    Registry -->|deploy via| Orchestration["docker-compose"]:::ci

    %% Click Events
    click APIGW "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/BackEnd/src/API_Gateway/"
    click US "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/BackEnd/src/user_service/"
    click PS "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/BackEnd/src/product_service/"
    click CS "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/BackEnd/src/cart_service/"
    click OS "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/BackEnd/src/order_service/"
    click Pays "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/BackEnd/src/payment_service/"
    click SS "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/BackEnd/src/search_service/"
    click RS "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/BackEnd/src/recommend_service/"
    click CICDP "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/.github/workflows/"
    click Registry "https://github.com/phan-manh-dung/online-pc-store-be/tree/master/Jenkinsfile"
    click Orchestration "https://github.com/phan-manh-dung/online-pc-store-be/blob/master/docker-compose.yml"

    %% Styles
    classDef edge fill:#bbdefb,stroke:#1e88e5,color:#0d47a1,stroke-width:2px
    classDef micro fill:#c8e6c9,stroke:#43a047,color:#1b5e20,stroke-width:2px
    classDef cache fill:#ffe0b2,stroke:#fb8c00,color:#e65100,stroke-width:2px
    classDef db fill:#fff9c4,stroke:#fdd835,color:#f57f17,stroke-width:2px
    classDef external fill:#eceff1,stroke:#546e7a,color:#263238,stroke-width:2px,stroke-dasharray: 5 5
    classDef ci fill:#f8bbd0,stroke:#d81b60,color:#880e4f,stroke-width:2px,stroke-dasharray: 2 2
```
