# anktuan/qlt architecture

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

- Interactive diagram: https://gitdiagram.com/anktuan/qlt
- Repository: https://github.com/anktuan/qlt

## Overview

##### Project type and purpose
- This is a full-stack pharmacy management system (“pharmacy-management/quanlythuoc”) composed of a React frontend and a Django REST-API backend.
- Purpose: allow employees and customers to register/login, manage medicines catalog, handle sales orders, payments, invoices, and integrate a chatbot.

##### File structure
- Top-level directories:
- backend/ – Django project (“pharmacy”) and three Django apps: authentication, medicines, sales, plus fixtures and media storage.
- frontend/ – React application, includes pages (Accounts, Customers, Dashboard, etc.), shared components, services (chatbotService), and configuration.
- docs/ – API documentation for each subsystem (auth_api.md, medicines_api.md, sales_api.md, swagger_api.md).
- Key files:
- backend/pharmacy/settings.py, urls.py, wsgi.py, asgi.py – project configuration.
- backend/*/views.py, serializers.py, urls.py – REST API endpoints via Django REST Framework.
- frontend/src/services/chatbotService.js & backend/pharmacy/chatbot_service.py – chatbot integration.
- fixtures/ – initial data for DB.
- media/ – uploaded medicine images.
- requirements.txt / package.json – dependencies.

##### README
- Limited description, but naming conventions confirm “pharmacy management.”
- No explicit architecture section, so infer stack: React + DRF + relational DB.

##### Essential details to capture
- All three Django apps and their respective database tables.
- The React pages and major components (Chatbot, Header/Footer, Dashboard).
- The chat-bot integration path.
- The API documentation endpoint (Swagger).
- Data flow for user auth, CRUD on medicines, order processing, payment, invoice generation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        RF["React Frontend"]:::frontend
        IDX["index.js"]:::frontend
        APP["App.js"]:::frontend
        CHAT_UI["Chatbot.js"]:::frontend
        CHAT_SVC["chatbotService.js"]:::frontend

        RF --> IDX
        IDX --> APP
        APP --> CHAT_UI
        CHAT_UI --> CHAT_SVC
    end

    click RF "https://github.com/anktuan/qlt/tree/main/frontend/"
    click IDX "https://github.com/anktuan/qlt/blob/main/frontend/src/index.js"
    click APP "https://github.com/anktuan/qlt/blob/main/frontend/src/App.js"
    click CHAT_UI "https://github.com/anktuan/qlt/blob/main/frontend/src/components/Chatbot.js"
    click CHAT_SVC "https://github.com/anktuan/qlt/blob/main/frontend/src/services/chatbotService.js"

    RF -->|"HTTPS/REST"| WS["Web Server (ASGI/WSGI)"]:::backend

    %% Backend Layer
    subgraph "Backend"
        direction TB
        WS --> ROUTER["Django URL Router"]:::backend
        CFG["Settings & Config"]:::backend
        ROUTER --> CFG

        subgraph "Authentication App"
            direction TB
            AUTH_V["views.py"]:::backend
            AUTH_S["serializers.py"]:::backend
            AUTH_M["models.py"]:::backend
            AUTH_U["urls.py"]:::backend
        end

        subgraph "Medicines App"
            direction TB
            MED_V["views.py"]:::backend
            MED_S["serializers.py"]:::backend
            MED_M["models.py"]:::backend
            MED_U["urls.py"]:::backend
        end

        subgraph "Sales App"
            direction TB
            SALES_V["views.py"]:::backend
            SALES_S["serializers.py"]:::backend
            SALES_M["models.py"]:::backend
            SALES_U["urls.py"]:::backend
        end

        CHAT_BACK["chatbot_service.py"]:::backend

        ROUTER --> AUTH_V
        ROUTER --> MED_V
        ROUTER --> SALES_V
        ROUTER --> CHAT_BACK
    end

    click CFG "https://github.com/anktuan/qlt/blob/main/backend/pharmacy/settings.py"
    click CFG "https://github.com/anktuan/qlt/blob/main/backend/pharmacy/urls.py"
    click CFG "https://github.com/anktuan/qlt/blob/main/backend/pharmacy/asgi.py"
    click CFG "https://github.com/anktuan/qlt/blob/main/backend/pharmacy/wsgi.py"
    click AUTH_M "https://github.com/anktuan/qlt/blob/main/backend/authentication/models.py"
    click AUTH_V "https://github.com/anktuan/qlt/blob/main/backend/authentication/views.py"
    click AUTH_S "https://github.com/anktuan/qlt/blob/main/backend/authentication/serializers.py"
    click AUTH_U "https://github.com/anktuan/qlt/blob/main/backend/authentication/urls.py"
    click MED_M "https://github.com/anktuan/qlt/blob/main/backend/medicines/models.py"
    click MED_V "https://github.com/anktuan/qlt/blob/main/backend/medicines/views.py"
    click MED_S "https://github.com/anktuan/qlt/blob/main/backend/medicines/serializers.py"
    click MED_U "https://github.com/anktuan/qlt/blob/main/backend/medicines/urls.py"
    click SALES_M "https://github.com/anktuan/qlt/blob/main/backend/sales/models.py"
    click SALES_V "https://github.com/anktuan/qlt/blob/main/backend/sales/views.py"
    click SALES_S "https://github.com/anktuan/qlt/blob/main/backend/sales/serializers.py"
    click SALES_U "https://github.com/anktuan/qlt/blob/main/backend/sales/urls.py"
    click CHAT_BACK "https://github.com/anktuan/qlt/blob/main/backend/pharmacy/chatbot_service.py"

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DB["Relational Database"]:::db
        MEDIA["Media Storage"]:::storage
    end

    AUTH_M --> DB
    MED_M --> DB
    SALES_M --> DB
    MED_M --> MEDIA

    %% Chatbot Flow
    CHAT_SVC -->|"REST API"| WS
    CHAT_BACK -->|"calls"| AI["External AI Chatbot API"]:::external

    %% Documentation
    subgraph "Documentation"
        direction TB
        DOCS_AUTH["auth_api.md"]:::docs
        DOCS_MED["medicines_api.md"]:::docs
        DOCS_SALES["sales_api.md"]:::docs
        DOCS_SWAG["swagger_api.md"]:::docs
    end

    click DOCS_AUTH "https://github.com/anktuan/qlt/blob/main/docs/auth_api.md"
    click DOCS_MED "https://github.com/anktuan/qlt/blob/main/docs/medicines_api.md"
    click DOCS_SALES "https://github.com/anktuan/qlt/blob/main/docs/sales_api.md"
    click DOCS_SWAG "https://github.com/anktuan/qlt/blob/main/docs/swagger_api.md"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:# blue,stroke-width:1px
    classDef backend fill:#DFFFD6,stroke:#2E8B57,stroke-width:1px
    classDef db fill:#FFF7D6,stroke:#DAA520,stroke-width:1px
    classDef storage fill:#FFE4E1,stroke:#CD5C5C,stroke-width:1px
    classDef external fill:#F0F8FF,stroke:#1E90FF,stroke-width:1px
    classDef docs fill:#F5F5F5,stroke:#A9A9A9,stroke-width:1px
```
