# tycoding/langchat architecture

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

- Interactive diagram: https://gitdiagram.com/tycoding/langchat
- Repository: https://github.com/tycoding/langchat

## Overview

The LangChat project is a comprehensive, enterprise-grade AIGC (AI generative chat) solution built on the Java ecosystem, combining back-end business logic with a modern, reactive front-end (Vue-based). The overall purpose is to provide a unified, configurable platform for integrating multiple AI large model providers and supporting enterprise-level features such as RBAC, dynamic configuration of AI model parameters, and knowledge bases.

##### Main Components
- Backend Services:
- Core AI Logic Modules: Modules like langchat-ai and langchat-ai-core provide business logic for interacting with various AI models.
- Authentication & Authorization: The langchat-auth and langchat-common-auth modules focus on security aspects, including RBAC and token management.
- Common Libraries: langchat-common modules (ai, auth, core, oss) supply shared configurations, utilities, and auto-configurations.
- User Management/Upms: The langchat-upms modules manage organizational information and user permissions.
- Server Gateway/API: The langchat-server module serves as the main API gateway, consolidating endpoints for business, authentication, and integrations.
- Frontend:
- langchat-ui: A rich, Vue-based client application that handles the user interface including chat, dashboards, knowledge management, and more.
- Deployment & Configuration:
- Scripts and Docker configurations (e.g., in docs, docker-compose.yml) to support containerized deployment.
- Configuration files (application.yml, application-dev.yml, etc.) which denote a strong emphasis on externalized, dynamic configuration.
- Databases and External Services:
- Although not explicitly detailed in the file tree, the README and configuration files hint at integrations with vector databases, storage OSS, and external models like OpenAI, DeepSeek, etc.
- Documentation & Assets:

##### Analyzing Architectural Patterns
- Modular and Multi-module Structure: The project is clearly divided into separate Maven modules (core, auth, common, server, ui, upms) that adopt microservice-like separation within a monorepo – this is a mix of modular design with service separation.
- Separation of Concerns: The backend is divided into a business logic layer (langchat-ai, langchat-ai-core) and infrastructure modules (langchat-auth, langchat-common-*), while the front-end (langchat-ui) is completely separated, integrated via REST APIs.

##### Relationships and Interactions
- The UI (langchat-ui) communicates with the Server (langchat-server) over REST/WebSocket endpoints.
- The main Server API routes requests to underlying business modules (AIGC, Authentication, Upms) which in turn rely on common libraries for core functionalities and integrations.
- The authentication service (langchat-auth) intercepts requests (as seen in AuthEndpoint and AuthInterceptor) enforcing RBAC policies.
- The langchat-ai modules interact with the AI providers (DeepSeek, OpenAI, etc.) and incorporate dynamic model parameters set via dynamic configuration from the UI.
- There is strong inter-module dependency where core functionalities like embedding, chat services, and file storage (oss) are abstracted away in langchat-common modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    subgraph "Frontend"
        UI("LangChat Client (Vue UI)"):::frontend
    end

    %% Backend Services
    subgraph "Backend Services"
        APIServer("LangChat Server (API Gateway)"):::server
        %% Business Modules
        subgraph "Business Modules"
            AIBiz("AIGC Business - Business Logic"):::ai
            AICore("AIGC Business - AI Core Integration"):::ai
            Auth("Authentication Service"):::auth
            CommonAuth("Common Auth Utilities"):::auth
            UserAPI("User Management API"):::upms
            UserBiz("User Management Business Logic"):::upms
            CommonAI("Common AI Utilities"):::common
            CommonCore("Common Core Utilities"):::common
            CommonOSS("Common OSS Utilities"):::common
        end
        %% Deployment & Configuration
        subgraph "Deployment & Config"
            Docs("Deployment Scripts & Docs"):::deployment
            Config("Configuration Files"):::deployment
        end
    end

    %% External Service
    External("External AI Providers"):::external

    %% Connections between Frontend and Backend
    UI -->|"calls"| APIServer
    APIServer -->|"routes"| AIBiz
    APIServer -->|"routes"| Auth
    APIServer -->|"routes"| UserAPI
    APIServer -->|"reads"| Config

    %% Internal Business Module Interactions
    AIBiz -->|"integrates"| AICore
    AIBiz -->|"uses"| CommonAI
    AIBiz -->|"uses"| CommonCore
    AIBiz -->|"uses"| CommonOSS
    Auth -->|"utilizes"| CommonAuth
    UserAPI -->|"calls"| UserBiz
    AICore -->|"integrates"| External

    %% Click Events
    click UI "https://github.com/tycoding/langchat/tree/main/langchat-ui"
    click APIServer "https://github.com/tycoding/langchat/tree/main/langchat-server"
    click AIBiz "https://github.com/tycoding/langchat/tree/main/langchat-ai/langchat-ai-biz"
    click AICore "https://github.com/tycoding/langchat/tree/main/langchat-ai/langchat-ai-core"
    click Auth "https://github.com/tycoding/langchat/tree/main/langchat-auth"
    click CommonAuth "https://github.com/tycoding/langchat/tree/main/langchat-common/langchat-common-auth"
    click CommonAI "https://github.com/tycoding/langchat/tree/main/langchat-common/langchat-common-ai"
    click CommonCore "https://github.com/tycoding/langchat/tree/main/langchat-common/langchat-common-core"
    click CommonOSS "https://github.com/tycoding/langchat/tree/main/langchat-common/langchat-common-oss"
    click UserAPI "https://github.com/tycoding/langchat/tree/main/langchat-upms/langchat-upms-api"
    click UserBiz "https://github.com/tycoding/langchat/tree/main/langchat-upms/langchat-upms-biz"
    click Docs "https://github.com/tycoding/langchat/tree/main/docs"
    click Config "https://github.com/tycoding/langchat/tree/main/langchat-server/src/main/resources"

    %% Styles and Class Definitions
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef server fill:#FFD699,stroke:#333,stroke-width:2px;
    classDef ai fill:#F7D794,stroke:#333,stroke-width:2px;
    classDef auth fill:#F7A9A8,stroke:#333,stroke-width:2px;
    classDef upms fill:#C2F0C2,stroke:#333,stroke-width:2px;
    classDef common fill:#E6E6FA,stroke:#333,stroke-width:2px;
    classDef deployment fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef external fill:#C0E0FF,stroke:#333,stroke-width:2px;
```
