# tanbinhphuoc/swp391-druguseprevention-fe architecture

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

- Interactive diagram: https://gitdiagram.com/tanbinhphuoc/swp391-druguseprevention-fe
- Repository: https://github.com/tanbinhphuoc/swp391-druguseprevention-fe

## Overview

##### Project type and purpose
- This is a single‐page application (SPA) built with React and Vite.
- Its primary purpose is to provide a modular UI for various user roles (admin, manager, staff, consultant, user) and features (articles, blogs, services “dichvu,” resources, authentication, dashboards, etc.).
- No backend code resides here; data is fetched via the api abstraction in src/services/api.js or mocked in src/mock.

##### File structure
- Top-level files:
- package.json / package-lock.json – dependency and script manifest
- vite.config.js – build & dev server config
- postcss.config.js, tailwind.config.js – CSS build pipeline
- eslint.config.js – linting rules
- index.html – SPA shell
- src/main.jsx: application entry point (mounts App)
- src/App.jsx: root component & router layout
- src/components: feature-based folders (home, login, admin, manager, staff, user, article, blog, dichvu/*, resource)
- src/services/api.js: API wrapper (fetch/post calls)
- src/mock: mock data for dev/testing
- public: static assets

##### README for additional insights
- Confirms it’s the standard Vite + React SPA template
- Uses HMR via @vitejs/plugin-react or SWC plugin
- Encourages ESLint + PostCSS + Tailwind for styling and linting

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Environment
    subgraph "Developer Environment"
        PKG["package.json"]:::dev
        PKGLOCK["package-lock.json"]:::dev
        ESLINT["eslint.config.js"]:::dev
        POSTCSS["postcss.config.js"]:::dev
        TAILWIND["tailwind.config.js"]:::dev
    end

    %% Build & Dev Pipeline
    subgraph "Build & Dev Pipeline"
        VITE["vite.config.js"]:::build
        MAIN_ENTRY["src/main.jsx"]:::build
        INDEX_HTML["index.html"]:::build
    end

    %% Browser (Client Shell)
    subgraph "Browser (Client)"
        BROWSER_HTML["index.html"]:::client
        PUBLIC_ASSETS["public/"]:::client
    end

    %% React Application
    subgraph "React Application"
        APP_ROOT["src/App.jsx"]:::react
        MAIN_BOOT["src/main.jsx"]:::react
        subgraph "Feature Modules"
            HOME["home"]:::react
            LOGIN["login"]:::react
            ADMIN["admin"]:::react
            MANAGER["manager"]:::react
            STAFF["staff"]:::react
            USER["user"]:::react
            ARTICLE["article"]:::react
            BLOG["blog"]:::react
            DICHVU["dichvu"]:::react
            RESOURCE["resource"]:::react
        end
    end

    %% API & Data Layers
    subgraph "Data Layer"
        API_CLIENT["src/services/api.js"]:::backend
        MOCK_DATA["src/mock"]:::backend
        EXTERNAL_API["External REST API"]:::backend
    end

    %% Connections
    PKG --> VITE
    PKGLOCK --> VITE
    ESLINT --> VITE
    POSTCSS --> VITE
    TAILWIND --> VITE

    VITE --> MAIN_ENTRY
    VITE --> INDEX_HTML

    INDEX_HTML --> BROWSER_HTML
    BROWSER_HTML --> APP_ROOT

    BROWSER_HTML --> PUBLIC_ASSETS

    APP_ROOT --> HOME
    APP_ROOT --> LOGIN
    APP_ROOT --> ADMIN
    APP_ROOT --> MANAGER
    APP_ROOT --> STAFF
    APP_ROOT --> USER
    APP_ROOT --> ARTICLE
    APP_ROOT --> BLOG
    APP_ROOT --> DICHVU
    APP_ROOT --> RESOURCE

    HOME --> API_CLIENT
    LOGIN --> API_CLIENT
    ADMIN --> API_CLIENT
    MANAGER --> API_CLIENT
    STAFF --> API_CLIENT
    USER --> API_CLIENT
    ARTICLE --> API_CLIENT
    BLOG --> API_CLIENT
    DICHVU --> API_CLIENT
    RESOURCE --> API_CLIENT

    API_CLIENT --> EXTERNAL_API
    API_CLIENT --> MOCK_DATA
    EXTERNAL_API --> API_CLIENT
    MOCK_DATA --> API_CLIENT

    %% Click Events
    click PKG "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/package.json"
    click PKGLOCK "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/package-lock.json"
    click ESLINT "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/eslint.config.js"
    click POSTCSS "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/postcss.config.js"
    click TAILWIND "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/tailwind.config.js"

    click VITE "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/vite.config.js"
    click MAIN_ENTRY "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/src/main.jsx"
    click INDEX_HTML "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/index.html"

    click BROWSER_HTML "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/index.html"
    click PUBLIC_ASSETS "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/public/"

    click APP_ROOT "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/src/App.jsx"
    click MAIN_BOOT "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/src/main.jsx"

    click HOME "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/home"
    click LOGIN "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/login"
    click ADMIN "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/admin"
    click MANAGER "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/manager"
    click STAFF "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/staff"
    click USER "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/user"
    click ARTICLE "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/article"
    click BLOG "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/blog"
    click DICHVU "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/dichvu"
    click RESOURCE "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/components/resource"

    click API_CLIENT "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/blob/main/src/services/api.js"
    click MOCK_DATA "https://github.com/tanbinhphuoc/swp391-druguseprevention-fe/tree/main/src/mock"

    %% Styles
    classDef dev fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef build fill:#fdd9b5,stroke:#333,stroke-width:1px
    classDef client fill:#d0e7ff,stroke:#333,stroke-width:1px
    classDef react fill:#add8e6,stroke:#333,stroke-width:1px
    classDef backend fill:#b5f2e7,stroke:#333,stroke-width:1px
```
