# kaizenx209/automation-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/kaizenx209/automation-chatbot
- Repository: https://github.com/kaizenx209/automation-chatbot

## Overview

##### Main Components

A. Frontend Layer (React.js Application):
- Chat Components (ChatBox, ChatMessage)
- Pages (ChatPage)
- Services (chatService)

B. Backend Layer (Python FastAPI):
- API Layer (v1/chat routes)
- Core AI Services
- Database Services

C. External Services/Dependencies:
- Database (indicated by the presence of database services)
- AI Service Integration (shown in core/ai)
- Docker Container Environment

##### Component Relationships

**Frontend ←→ Backend API (REST/HTTP)**
**Backend API ←→ Core AI Services**
**Backend API ←→ Database Services**

##### Detailed Component Breakdown

A. Frontend Structure:
**React Application**
- Components
- Chat Module
- ChatBox
- ChatMessage
- Pages
- ChatPage
- Services
- ChatService (API Integration)

B. Backend Structure:
**FastAPI Application**
- API (v1)
- Chat Routes
- Core
- AI Services
- AI Service
- Tools
- Database Services
- Chat History
- Order
- Product
- Wallet

##### Important Elements to Highlight

- Docker containerization (shown by docker-compose.yml)
- Database interaction patterns
- AI service integration
- RESTful API structure
- Chat functionality flow

##### Technical Stack Indicators

A tech stack section showing:
- Frontend: React.js
- Backend: Python FastAPI
- Database: (Type indicated in .env)
- Container: Docker
- Environment: Anaconda (Python 3.11)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend["Frontend Layer (React.js)"]
        direction TB
        FC["Chat Components"]
        FP["Pages"]
        FS["Services"]
        
        subgraph FChatComp["Chat Module"]
            direction TB
            CB["ChatBox"]
            CM["ChatMessage"]
        end
        
        subgraph FPages["Page Components"]
            CP["ChatPage"]
        end
        
        subgraph FServices["Frontend Services"]
            CS["Chat Service"]
        end
        
        FC --> FChatComp
        FP --> FPages
        FS --> FServices
    end
    
    subgraph Backend["Backend Layer (FastAPI)"]
        direction TB
        API["API Layer (v1)"]
        Core["Core Services"]
        DB["Database Services"]
        
        subgraph APIRoutes["API Routes"]
            CR["Chat Routes"]
        end
        
        subgraph CoreServices["AI Services"]
            AIS["AI Service"]
            AIT["AI Tools"]
        end
        
        subgraph DBServices["Database Services"]
            CHS["Chat History Service"]
            OS["Order Service"]
            PS["Product Service"]
            WS["Wallet Service"]
            DBM["Database Models"]
        end
        
        API --> APIRoutes
        Core --> CoreServices
        DB --> DBServices
    end
    
    subgraph External["External Dependencies"]
        Docker["Docker Container"]
        Database[(Database)]
    end
    
    %% Relationships
    CS --> CR
    CR --> CoreServices
    CoreServices --> DBServices
    DBServices --> Database
    Docker --> Backend
    Docker --> Frontend
    
    %% Click Events
    click CB "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-frontend/src/components/chat/ChatBox.jsx"
    click CM "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-frontend/src/components/chat/ChatMessage.jsx"
    click CP "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-frontend/src/pages/ChatPage.jsx"
    click CS "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-frontend/src/services/chatService.js"
    click CR "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-backend/app/api/v1/chat/routes.py"
    click AIS "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-backend/app/core/ai/ai_service.py"
    click AIT "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-backend/app/core/ai/tools.py"
    click CHS "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-backend/app/database/chat_history_service.py"
    click OS "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-backend/app/database/order_service.py"
    click PS "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-backend/app/database/product_service.py"
    click WS "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-backend/app/database/wallet_service.py"
    click DBM "https://github.com/kaizenX209/Automation-Chatbot/blob/main/chatbot-backend/app/database/models.py"
    click Docker "https://github.com/kaizenX209/Automation-Chatbot/blob/main/docker-compose.yml"
    
    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:#fff
    classDef backend fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef database fill:#e74c3c,stroke:#c0392b,color:#fff
    classDef external fill:#9b59b6,stroke:#8e44ad,color:#fff
    classDef service fill:#f1c40f,stroke:#f39c12,color:#000
    
    class Frontend,FChatComp,FPages,FServices,CB,CM,CP,CS frontend
    class Backend,APIRoutes,CoreServices,DBServices,CR,AIS,AIT,CHS,OS,PS,WS,DBM backend
    class Database database
    class Docker external
    class Core,API,DB service
```
