# phuuquiii/tttn_ecommerce architecture

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

- Interactive diagram: https://gitdiagram.com/phuuquiii/tttn_ecommerce
- Repository: https://github.com/phuuquiii/tttn_ecommerce

## Overview

##### A React-Native mobile app (for mobile users)
4. A NodeJS backend server that exposes REST APIs (with a rich “server” directory for controllers, routes, models, middleware, and database backups)
##### A live-stream module (with its own Docker setup, RTMP configuration and web interface)
6. A chatbot deployment (using Python with components like app.py, model.py, and NLTK utilities)

The purpose of this project appears to be to support a commerce or content delivery system (possibly with e-commerce or interactive features), where different platforms (web client, CRM/admin, mobile) interact with a centralized NodeJS backend. Additional services (such as live-streaming and chatbot functionality) augment the core offerings by providing real-time interaction and automated responses.

##### Main Components
- Frontend Clients:
- Client (NextJS website): Handles public-facing web pages and user interactions.
- CRM (React Dashboard): Provides administrative functions, order management, product management, and analytics.
- Mobile App (React-Native): Targets mobile users with navigation, product display, and integrated commerce features.
- Backend:
- Server (NodeJS): Comprises multiple controllers, API routes, middleware, and models. It serves as the brain of the system, orchestrating data flow with the database and external services.
- Database (implicit based on DB_backup files in the server directory): Likely a NoSQL database (e.g., MongoDB) given the BSON backup files.
- Additional Services:
- Live-Stream Module: A dockerized live streaming service with RTMP and nginx configurations used for real-time video broadcasting.
- Chatbot Deployment: A Python-based service with natural language processing (NLP) components (using NLTK) to handle chatbot interactions.

##### Component Relationships and Data Flow
- Frontend clients (Client, CRM, Mobile App) should be shown as separate UI layers that all make API calls to the NodeJS backend.
- The NodeJS backend should be represented as a central service that:
- Processes requests coming from the different frontends.
- Manages business logic (illustrated via controllers, middleware, and routes).
- Interacts with the underlying database for CRUD operations.
- The database component should be clearly shown, possibly with a note indicating BSON backups hinting at a NoSQL store.
- Live-stream and chatbot services are additional microservices or external service modules:
- Similarly, represent the chatbot as a service that might be embedded within the client’s pages or used within the mobile app, with its own flow to deliver responses.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Different UIs (web, CRM, mobile) are separated from backend business logic.
- Modular / Microservice Elements: The live-stream and chatbot modules are clearly separate and containerized (using Docker) from the main server.
- RESTful API Design: Focus on directional API calls between frontends and the backend.
- MVC-like structure in both the client-side (React components in CRM and mobile app’s structure) and the server-side (separation into models, controllers, and routes).

##### Relevant Technologies, Frameworks, and Libraries
- Frontend:
- NextJS for the Client.
- React for the CRM.
- React Native + Expo for the Mobile App.
- Backend:
- NodeJS with Express (inferred from controllers, routes, and middleware patterns)
- Database access libraries likely appropriate for MongoDB (or similar NoSQL).
- Additional Services:
- Live-stream: Docker, RTMP, nginx.
- Chatbot: Python, NLTK, and associated machine learning utilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        NJClient["NextJS Client"]:::frontend
        CRMClient["CRM Dashboard (React)"]:::frontend
        Mobile["Mobile App (React Native)"]:::frontend
    end

    %% API/Backend Layer
    subgraph "API/Backend Layer"
        APIServer["REST API Server (NodeJS)"]:::backend
    end

    %% Data/Database Layer
    subgraph "Data/Database Layer"
        DB["Database (NoSQL/MongoDB)"]:::database
    end

    %% Service Layer
    subgraph "Service Layer"
        LiveStream["Live-Stream Module (Docker, RTMP, nginx)"]:::service
        Chatbot["Chatbot Service (Python, NLTK)"]:::service
    end

    %% Connections: UI to API Server
    NJClient -->|"API_call"| APIServer
    CRMClient -->|"API_call"| APIServer
    Mobile -->|"API_call"| APIServer

    %% Connection: API Server to Database
    APIServer -->|"CRUD_operations"| DB

    %% Connections between API Server and Services
    APIServer -->|"Integration"| LiveStream
    APIServer -->|"Integration"| Chatbot

    %% Direct interactions from services to UI
    LiveStream ---|"Live_stream_data"| NJClient
    LiveStream ---|"Live_stream_data"| CRMClient
    Chatbot ---|"Chatbot_responses"| NJClient
    Chatbot ---|"Chatbot_responses"| Mobile

    %% Click Events for components mapped to file paths
    click NJClient "https://github.com/phuuquiii/tttn_ecommerce/tree/main/client"
    click CRMClient "https://github.com/phuuquiii/tttn_ecommerce/tree/main/CRM"
    click Mobile "https://github.com/phuuquiii/tttn_ecommerce/tree/main/app"
    click APIServer "https://github.com/phuuquiii/tttn_ecommerce/tree/main/server"
    click LiveStream "https://github.com/phuuquiii/tttn_ecommerce/tree/main/live-stream"
    click Chatbot "https://github.com/phuuquiii/tttn_ecommerce/tree/main/chatbot-deployment"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef backend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef database fill:#afa,stroke:#333,stroke-width:2px;
    classDef service fill:#ff9,stroke:#333,stroke-width:2px;
```
