# the-seven-js/fptu-clothing-be architecture

> Architecture diagram of the GitHub repository the-seven-js/fptu-clothing-be, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/the-seven-js/fptu-clothing-be
- Repository: https://github.com/the-seven-js/fptu-clothing-be

## Overview

##### Project type and purpose
- From the file tree we see a Dockerfile, a GitHub Actions CI/CD workflow, package.json, and a src/ directory structured into controllers, routes, middleware and config. The presence of JSON “advice” files and “attribute_data” suggests this is a standalone Node.js/Express RESTful API service that delivers “male” and “female” advice data, handles articles, comments, photo uploads, and authentication flows (login, logout, change-password).

##### File structure
- Top-level:
- Dockerfile and .github/workflows/cicd.yml → containerization & CI/CD pipeline
- package.json / package-lock.json → Node.js + npm modules
- src/ → application code
- uploads/ → persistent storage for user-uploaded photos
- src/ subfolders:
- config/db.js → database connection settings
- controllers/*.js → business logic for articles, comments, demos, photos
- routes/*.js → Express routing definitions, mapping HTTP endpoints to controllers
- middleware/authmiddleware.js → authentication/authorization logic
- static JSON files (male_advice.json, female_advice.json, attribute_data_*.json) → data fixtures

##### README
- The README (“aNH qUÝ âm vô cực điểm”) contains no architectural guidance. All insights must come from the file layout and naming conventions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Systems
    Client["Client"]:::external

    %% API Service
    subgraph "API Service"
        direction TB
        Entry["API Entry Point"]:::backend
        click Entry "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/index.js"
        subgraph "Config"
            DBConfig["Database Configuration"]:::backend
            click DBConfig "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/config/db.js"
        end
        subgraph "Middleware"
            AuthMW["Auth Middleware"]:::backend
            click AuthMW "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/middleware/authmiddleware.js"
        end
        subgraph "Routes"
            ARoute["Article Route"]:::backend
            click ARoute "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/routes/article-route.js"
            CRoute["Comment Route"]:::backend
            click CRoute "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/routes/comment-route.js"
            DRoute["Demo Route"]:::backend
            click DRoute "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/routes/demo-routes.js"
            PRoute["Photo Route"]:::backend
            click PRoute "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/routes/photo-route.js"
            LRoute["Login Route"]:::backend
            click LRoute "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/routes/login-route.js"
            OutRoute["Logout Route"]:::backend
            click OutRoute "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/routes/logout-route.js"
            CPRoute["Change Password Route"]:::backend
            click CPRoute "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/routes/change-password-route.js"
            LogicRoute["Logic Route"]:::backend
            click LogicRoute "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/routes/logic-route.js"
        end
        subgraph "Controllers"
            AController["Article Controller"]:::backend
            click AController "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/controllers/article-controller.js"
            ComController["Comment Controller"]:::backend
            click ComController "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/controllers/comment-controller.js"
            DemoController["Demo Controller"]:::backend
            click DemoController "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/controllers/demo-controller.js"
            PhotoController["Photo Controller"]:::backend
            click PhotoController "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/controllers/photo-controller.js"
        end
        Entry --> DBConfig
        Entry --> AuthMW
        AuthMW --> ARoute
        AuthMW --> CRoute
        AuthMW --> DRoute
        AuthMW --> PRoute
        AuthMW --> LRoute
        AuthMW --> OutRoute
        AuthMW --> CPRoute
        AuthMW --> LogicRoute
        ARoute --> AController
        CRoute --> ComController
        DRoute --> DemoController
        PRoute --> PhotoController
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        DB["Database"]:::datastore
        Uploads["File Upload Storage"]:::datastore
        click Uploads "https://github.com/the-seven-js/fptu-clothing-be/tree/master/uploads/"
        subgraph "JSON Fixtures"
            MaleAdv["Male Advice Data"]:::datastore
            click MaleAdv "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/male_advice.json"
            FemaleAdv["Female Advice Data"]:::datastore
            click FemaleAdv "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/female_advice.json"
            MaleAttr["Male Attribute Data"]:::datastore
            click MaleAttr "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/attribute_data_male.json"
            FemaleAttr["Female Attribute Data"]:::datastore
            click FemaleAttr "https://github.com/the-seven-js/fptu-clothing-be/blob/master/src/attribute_data_female.json"
        end
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        CI["CI/CD Pipeline"]:::infra
        click CI "https://github.com/the-seven-js/fptu-clothing-be/blob/master/.github/workflows/cicd.yml"
        DockerfileNode["Docker Configuration"]:::infra
        click DockerfileNode "https://github.com/the-seven-js/fptu-clothing-be/tree/master/Dockerfile"
        DockerHost["Container Host"]:::infra
    end

    %% Connections
    Client -->|"HTTP Request"| Entry
    AController -->|CRUD| DB
    ComController -->|CRUD| DB
    DemoController -->|Read| MaleAdv
    DemoController -->|Read| FemaleAdv
    LogicRoute -->|Read| MaleAttr
    LogicRoute -->|Read| FemaleAttr
    PhotoController -->|Store/Retrieve| Uploads
    CI -->|"Build & Test"| DockerfileNode
    CI -->|"Push Image"| DockerHost
    DockerHost -->|"Deploy Service"| Entry

    %% Styles
    classDef external fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#1B5E20
    classDef datastore fill:#FFF3E0,stroke:#EF6C00,color:#E65100
    classDef infra fill:#ECEFF1,stroke:#607D8B,color:#37474F
```
