# 274056675/springboot-openai-chatgpt architecture

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

- Interactive diagram: https://gitdiagram.com/274056675/springboot-openai-chatgpt
- Repository: https://github.com/274056675/springboot-openai-chatgpt

## Overview

##### Main System Components

a) Backend Services (Microservices Architecture):
- Gateway Service (GatewayApplication)
- Authentication Service (AuthApplication)
- System Service (SystemApplication)
- User Service (UserApplication)
- MJKJ Service (MjkjApplication)
- Middleware Services:
- Nacos (Service Discovery/Config)
- MySQL Database
- Redis Cache

b) Frontend Applications:
- PC Web Application (chatgpt_pc)
- Management Web Application (mng_web)
- HTTP Service (chatgpt_http)

**Client Layer**
- PC Web Interface
- Management Interface
- Mobile Apps (Android/iOS)

**API Gateway Layer**
- Gateway Service

**Application Services Layer**
- Auth Service
- System Service
- User Service
- MJKJ Service

**Infrastructure Layer**
- Nacos
- Redis
- MySQL

##### Key Design Elements

- Rectangles: Frontend applications
- Hexagons: Microservices
- Clouds: External services/APIs

- Blue: Frontend components
- Green: Core services
- Yellow: Infrastructure services
- Gray: External services

c) Connection types:

##### Special Features to Highlight

a) AI Integration:
- ChatGPT integration
- Image generation capabilities
- AI toolbox features

b) Security Layer:
- Authentication flow
- Authorization mechanisms
- Token management

c) Data Flow:
- User interaction paths
- Service communication patterns
- Cache utilization

##### Implementation Details

- Frontend-Backend communication through Gateway
- Service discovery via Nacos
- Database relationships
- Cache interaction patterns
- Authentication flow
- File storage system

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef infrastructure fill:#f1c40f,stroke:#f39c12,color:black
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef external fill:#bdc3c7,stroke:#95a5a6,color:black
    classDef api fill:#e74c3c,stroke:#c0392b,color:white

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        PC["PC Web App"]:::frontend
        MNG["Management Web"]:::frontend
        Mobile["Mobile Apps"]:::frontend
        HTTP["HTTP Service"]:::frontend
    end

    %% API Gateway Layer
    subgraph GatewayLayer["API Gateway Layer"]
        Gateway["Gateway Service"]:::api
    end

    %% Application Services Layer
    subgraph ServicesLayer["Application Services Layer"]
        AuthService["Auth Service"]:::service
        SystemService["System Service"]:::service
        UserService["User Service"]:::service
        MJKJService["MJKJ Service"]:::service
    end

    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        Nacos["Nacos\nService Discovery"]:::infrastructure
        Redis["Redis Cache"]:::infrastructure
        MySQL["MySQL Database"]:::infrastructure
    end

    %% External Services
    ChatGPT["ChatGPT API"]:::external
    AITools["AI Toolbox"]:::external

    %% Connections
    PC --> Gateway
    MNG --> Gateway
    Mobile --> Gateway
    HTTP --> Gateway

    Gateway --> AuthService
    Gateway --> SystemService
    Gateway --> UserService
    Gateway --> MJKJService

    AuthService --> Redis
    AuthService --> MySQL
    SystemService --> MySQL
    UserService --> MySQL
    MJKJService --> MySQL
    MJKJService --> Redis

    MJKJService --> ChatGPT
    MJKJService --> AITools

    %% Service Discovery
    AuthService --> Nacos
    SystemService --> Nacos
    UserService --> Nacos
    MJKJService --> Nacos
    Gateway --> Nacos

    %% Click Events
    click PC "https://github.com/274056675/springboot-openai-chatgpt/tree/master/chatgpt_pc/"
    click MNG "https://github.com/274056675/springboot-openai-chatgpt/tree/master/mng_web/"
    click HTTP "https://github.com/274056675/springboot-openai-chatgpt/tree/master/chatgpt_http/"
    click AuthService "https://github.com/274056675/springboot-openai-chatgpt/tree/master/chatgpt-boot/src/main/java/org/springblade/modules/auth/"
    click SystemService "https://github.com/274056675/springboot-openai-chatgpt/tree/master/chatgpt-boot/src/main/java/org/springblade/modules/system/"
    click UserService "https://github.com/274056675/springboot-openai-chatgpt/tree/master/chatgpt-boot/src/main/java/org/springblade/modules/system/service/"
    click MJKJService "https://github.com/274056675/springboot-openai-chatgpt/tree/master/chatgpt-boot/src/main/java/org/springblade/modules/mjkj/"
    click MySQL "https://github.com/274056675/springboot-openai-chatgpt/blob/master/doc/mysql/mjkj_chatgpt.sql"

    %% Legend
    subgraph Legend["Legend"]
        L_Frontend["Frontend"]:::frontend
        L_Service["Microservice"]:::service
        L_Infra["Infrastructure"]:::infrastructure
        L_External["External Service"]:::external
        L_API["API Gateway"]:::api
    end
```
