# vinh412/chat-apps architecture

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

- Interactive diagram: https://gitdiagram.com/vinh412/chat-apps
- Repository: https://github.com/vinh412/chat-apps

## Overview

1. chat-api – A Spring Boot-based REST API service that handles authentication, user management, channel management, and other business logic.
2. chat-server – Another Spring Boot application that acts as the real-time messaging service using WebSocket configurations and a Cassandra database for storing chat messages.
3. ui – A React-based front-end that provides the chat interface and interacts with both backend services.

##### Main Components
- Frontend/UI Component (React App)
- REST API Service (chat-api)
- Chat Server (WebSocket Service)
- Databases / Persistence Layers
– Although the chat-api might use a relational or ORM-based persistence layer (given the repository package structure), the chat-server clearly integrates with Cassandra (via CassandraConfiguration). Include both “Relational DB” (or “Primary Data Store”) for chat-api (if not explicitly defined, assume its own persistence) and “Cassandra DB” for the chat-server.
- Supporting Infrastructure

##### Relationships and Interactions
- The “UI” also communicates with the “Chat Server” for real-time chat messaging via WebSockets. Indicate bi-directional messaging flow between UI and chat-server.

##### Architectural Patterns and Technologies
- Both backend services follow a modular, layered approach (evidenced by packages for config, controllers, service, repository, model, payload, etc.) using principles such as separation of concerns and dependency injection common in Spring Boot applications.
- The chat-server uses WebSocket for real-time communication, and its handling of events and configuration should be distinctly represented.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        UI["UI / Frontend"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["Chat API Service (Spring Boot)"]:::backend
        SERVER["Chat Server (WebSocket)"]:::backend
    end

    %% Data Storage
    subgraph "Data Storage"
        REL_DB["Relational DB"]:::database
        CASS_DB["Cassandra DB"]:::database
    end

    %% Deployment/Orchestration
    subgraph "Deployment/Orchestration"
        DOCKER["Docker/Deployment"]:::deployment
    end

    %% Connections
    UI -->|"REST"| API
    UI <-->|"WS"| SERVER
    API -->|"accessDB"| REL_DB
    SERVER -->|"persistMsg"| CASS_DB

    DOCKER -->|"Containers"| UI
    DOCKER -->|"Containers"| API
    DOCKER -->|"Containers"| SERVER

    %% Click Events
    click UI "https://github.com/vinh412/chat-apps/tree/master/ui/"
    click API "https://github.com/vinh412/chat-apps/tree/master/chat-api/"
    click SERVER "https://github.com/vinh412/chat-apps/tree/master/chat-server/"
    click CASS_DB "https://github.com/vinh412/chat-apps/blob/master/chat-server/src/main/java/com/vinhdd/chatserver/config/CassandraConfiguration.java"
    click REL_DB "https://github.com/vinh412/chat-apps/tree/master/chat-api/src/main/java/com/vinhdd/chatapi/repository/"
    click DOCKER "https://github.com/vinh412/chat-apps/blob/master/compose.yml"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef database fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef deployment fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
