# locnguyensgu/calligo architecture

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

- Interactive diagram: https://gitdiagram.com/locnguyensgu/calligo
- Repository: https://github.com/locnguyensgu/calligo

## Overview

##### Main System Components Identification
The project is a microservices architecture with the following key services:
- API Gateway Service
- Discovery Service (Eureka)
- User Service
- Chat Service
- Friend Service
- Notification Service
- Common Service

##### Specific Component Details

API Gateway:
- Security filter chain
- Routing paths to microservices
- Authentication/authorization flow

User Service:
- Account management
- Security components (JWT)
- Role-based access control
- Refresh token management

Chat Service:
- WebSocket connections
- Real-time message handling
- Different chat types (1-1, group)
- Message status tracking
- Media handling components

Friend Service:
- Friend request management
- Relationship tracking
- Status management

Notification Service:
- Kafka consumer setup
- Real-time notification dispatch
- Event handling system

##### Connection Types

- Double lines: WebSocket connections

##### Additional Elements

Include:
- Database symbols for each service's persistence layer
- Load balancer symbol at the gateway
- Kafka topics for async communication
- WebSocket endpoints for real-time features
- Security tokens flow
- Service discovery registration/lookup paths

##### Specific Implementation Details

Show:
- WebSocket configuration for chat
- Kafka integration for notifications
- JWT token flow through API Gateway
- Friend request state machine
- Message delivery status tracking
- File storage for media content

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "System Overview"
        API["API Gateway"]:::gateway
        click API "https://github.com/LocNguyenSGU/Calligo/blob/main/apigateway/src/main/java/com/example/apigateway/filter/KeyAuthFilter.java"
        
        DISC["Discovery Service (Eureka)"]:::discovery
        click DISC "https://github.com/LocNguyenSGU/Calligo/blob/main/discoveryservice/src/main/java/com/example/discoveryservice/DiscoveryserviceApplication.java"
        
        subgraph "Core Services"
            US["User Service"]:::service
            click US "https://github.com/LocNguyenSGU/Calligo/blob/main/userservice/src/main/java/com/example/userservice/controller/AuthController.java"
            
            CS["Chat Service"]:::service
            click CS "https://github.com/LocNguyenSGU/Calligo/blob/main/chatservice/src/main/java/com/example/chatservice/controller/WebsocketController.java"
            
            FS["Friend Service"]:::service
            click FS "https://github.com/LocNguyenSGU/Calligo/blob/main/friendservice/src/main/java/com/example/friendservice/service/FriendService.java"
            
            NS["Notification Service"]:::service
            click NS "https://github.com/LocNguyenSGU/Calligo/blob/main/notificationservice/src/main/java/com/example/notificationservice/event/ConsumerEvent.java"
            
            COMMON["Common Service"]:::service
            click COMMON "https://github.com/LocNguyenSGU/Calligo/blob/main/commonservice/src/main/java/com/example/commonservice/service/KafkaService.java"
        end
        
        subgraph "Security"
            JWT["JWT Provider"]:::security
            click JWT "https://github.com/LocNguyenSGU/Calligo/blob/main/userservice/src/main/java/com/example/userservice/security/JwtTokenProvider.java"
            AUTH["Auth Service"]:::security
            click AUTH "https://github.com/LocNguyenSGU/Calligo/blob/main/apigateway/src/main/java/com/example/apigateway/service/AuthService.java"
        end
        
        subgraph "Communication"
            WS["WebSocket Config"]:::communication
            click WS "https://github.com/LocNguyenSGU/Calligo/blob/main/chatservice/src/main/java/com/example/chatservice/config/WebsocketConfig.java"
            KAFKA["Kafka Message Broker"]:::communication
            click KAFKA "https://github.com/LocNguyenSGU/Calligo/blob/main/commonservice/src/main/java/com/example/commonservice/config/KafkaConfig.java"
        end
        
        subgraph "Data Layer"
            CONV["Conversations"]:::data
            click CONV "https://github.com/LocNguyenSGU/Calligo/blob/main/chatservice/src/main/java/com/example/chatservice/entity/Conversation.java"
            ACC["Accounts"]:::data
            click ACC "https://github.com/LocNguyenSGU/Calligo/blob/main/userservice/src/main/java/com/example/userservice/entity/Account.java"
            FR["Friend Requests"]:::data
            click FR "https://github.com/LocNguyenSGU/Calligo/blob/main/friendservice/src/main/java/com/example/friendservice/entity/FriendRequest.java"
        end
        
        %% Connections
        API --> DISC
        API --> US
        API --> CS
        API --> FS
        API --> NS
        
        US --> JWT
        API --> AUTH
        
        CS --> WS
        NS --> KAFKA
        FS --> KAFKA
        
        CS --> CONV
        US --> ACC
        FS --> FR
        
        COMMON --> KAFKA
        
        %% WebSocket and async connections
        WS -.-> CS
        KAFKA -.-> NS
        KAFKA -.-> COMMON
        
        %% Service Discovery
        US --> DISC
        CS --> DISC
        FS --> DISC
        NS --> DISC
        
    end
    
    %% Styles
    classDef gateway fill:#gray,stroke:#333,stroke-width:2px
    classDef discovery fill:#lightgray,stroke:#333
    classDef service fill:#lightblue,stroke:#333
    classDef security fill:#yellow,stroke:#333
    classDef communication fill:#lightgreen,stroke:#333
    classDef data fill:#pink,stroke:#333
    
    %% Legend
    subgraph Legend
        L1["Gateway"]:::gateway
        L2["Discovery"]:::discovery
        L3["Service"]:::service
        L4["Security"]:::security
        L5["Communication"]:::communication
        L6["Data Store"]:::data
    end
```
