# nhuttran02/hair-salon architecture

> Architecture diagram of the GitHub repository nhuttran02/hair-salon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nhuttran02/hair-salon
- Repository: https://github.com/nhuttran02/hair-salon

## Overview

##### Project Type and Purpose
- That the repository “ears” elements from both the Node.js world (in the BE folder, with controllers, routers, services, Knex configuration, etc.) and a Python-based machine learning solution (e.g., faceshape_nhuttran_v3.py and requirements.txt, along with instructions to run a FastAPI server). This shows a hybrid architecture where frontend and Node.js backend serve the primary web application and a separate FastAPI-based microservice is likely used for ML inference.

##### File Structure
- The project is organized into two top-level directories:
– BE (Backend): Contains .js files for controllers, routes, services, middlewares, and database configuration (using Knex). It also includes Docker, ESLint, and upload directories for static assets (avatars, hairstyles).
– FE (Frontend): Contains Vue.js components, assets, pages (both public and admin), a Vue Router setup, and Tailwind CSS configuration.
- Additional key files include:
– Root files: README.md, requirements.txt, and a Python file (faceshape_nhuttran_v3.py) that hints at the ML component.
– Configuration files for Docker, package.json, and deployment instructions involving Nginx, Certbot, and GitHub Actions.
- The structure implies an architectural separation:
– A web client (Vue.js SPA) in FE.
– A Node.js backend in BE managing API endpoints for authentication, users, admin functions, and more.

##### README for Additional Insights
- The README details the tech stack and layered structure. On the frontend side, it uses Vue.js, Vuex, and Vue Router. On the backend, it mentions FastAPI, but the BE folder suggests a Node.js based API – a dual-backend scenario is possible where one service manages business logic and another, specialized service handles ML inference.
- It also points out deployment strategies (Docker, Nginx reverse proxy with SSL/Certbot) and CI/CD using GitHub Actions.

- Each component must have a clear and concise label (e.g., “Frontend (Vue.js)”, “Backend (Node.js API)”, “ML Service (FastAPI/Python)”, “Database”, “Deployment Layer (Docker/Nginx)”).
– The API request/response cycle between FE and BE.
– Communication between the BE and the ML service.
– Data interactions between the BE and the Database.
– Frontend requests routed through Nginx to either FE or BE.
- Including annotations for:
– Key technologies (e.g., “Tailwind CSS”, “Knex for DB”, “ONNX for inference”).
– Architectural design patterns (like microservices or modular architecture).
– Deployment aspects (Docker containerization, CI/CD pipelines with GitHub Actions).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    subgraph "User Layer"
        FEClient("Frontend (Vue.js SPA)"):::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        BEService("Backend API (Node.js)"):::backend
        MLService("Machine Learning Service (FastAPI/Python)"):::ml
        Database("Database"):::database
        StaticAssets("Static Assets (Uploads)"):::assets
    end

    %% Deployment & Infrastructure Layer
    subgraph "Deployment & Infrastructure"
        DEP("Deployment Infrastructure (Nginx/Docker)"):::deployment
        BE_Docker("Docker Config (BE)"):::docker
        FE_Docker("Docker Config (FE)"):::docker
        CICD("CI/CD (GitHub Actions)"):::cicd
    end

    %% Connections between Layers
    FEClient -->|"APIRequest"| BEService
    BEService -->|"DataQueryCRUD"| Database
    Database -->|"DataResponse"| BEService
    BEService -->|"FaceShapeRequest"| MLService
    MLService -->|"ClassificationResult"| BEService
    BEService -->|"ServesStatic"| StaticAssets

    %% Deployment routing arrows
    DEP -->|"Routes to"| FEClient
    DEP -->|"Routes to"| BEService
    DEP -->|"Routes to"| MLService
    DEP -->|"Routes to"| StaticAssets
    CICD -->|"Automates"| DEP

    %% Connections within Deployment sub-components
    DEP --> BE_Docker
    DEP --> FE_Docker

    %% Click Events
    click FEClient "https://github.com/nhuttran02/hair-salon/tree/main/FE/"
    click BEService "https://github.com/nhuttran02/hair-salon/tree/main/BE/"
    click MLService "https://github.com/nhuttran02/hair-salon/blob/main/faceshape_nhuttran_v3.py"
    click Database "https://github.com/nhuttran02/hair-salon/blob/main/BE/src/database/knex.js"
    click StaticAssets "https://github.com/nhuttran02/hair-salon/tree/main/BE/public/uploads"
    click BE_Docker "https://github.com/nhuttran02/hair-salon/blob/main/BE/.dockerignore"
    click FE_Docker "https://github.com/nhuttran02/hair-salon/blob/main/FE/.dockerignore"

    %% Class Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef ml fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef database fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef assets fill:#F0E68C,stroke:#000,stroke-width:2px;
    classDef deployment fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef docker fill:#E6E6FA,stroke:#000,stroke-width:2px;
    classDef cicd fill:#FFB6C1,stroke:#000,stroke-width:2px;
```
