# furinai/oasys architecture

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

- Interactive diagram: https://gitdiagram.com/furinai/oasys
- Repository: https://github.com/furinai/oasys

## Overview

##### Main Components
- API Gateway – Represented by the “oasys-gateway” module. This acts as the front door to the backend microservices, handling routing, security (including WebFlux security), and cross-cutting concerns.
- Authentication Service – Represented by the “oasys-auth” module, which handles authentication, JWT-based security (with key configurations and jks files), and communicates with user-related components.
- Common Library – The “oasys-common” module contains common utilities (e.g., exception handling, global exception handler, JWT utilities) used by various services.
- Microservices – Each business functionality is split into its own service:
▪ Announcement Service (oasys-announcement)
▪ Attendance Service (oasys-attendance)
▪ Chat Service (oasys-chat) including WebSocket configuration and Pulsar messaging
▪ File Service (oasys-file) integrated with MinIO for file storage and management
▪ Search Service (oasys-search) providing file search via repository abstraction
▪ User Service (oasys-user) managing user, department, role, and permission entities
- External Clients & Integrations – Some services include REST client calls, e.g., Chat and File modules call AuthClient or UserClient, so denote external integrations or inter-service communications.

##### Relationships and Interactions
- The Authentication Service interacts with other services (e.g., via token validation) – illustrate these interactions between “oasys-auth” and other microservices.
- Shared utility functionality in “oasys-common” is used by each service. Indicate this as a common dependency (e.g., via a shared library block) that each backend service consumes.
- For the Chat and File services, include connections to external messaging components (e.g., web sockets in Chat, MinIO in File) and highlight the internal modules like the Interceptors, Containers, and Listeners used to handle real-time messaging.

##### Architectural Patterns and Design Principles
- Microservices Architecture – Emphasize the separation of concerns by breaking business capabilities into individual services.
- API Gateway – Acts as a façade decoupling the frontend from internal microservices.
- Security Layer – Highlight authentication and authorization responsibilities handled by the “oasys-auth” and the security configuration classes in both auth and gateway.
- Shared Library Pattern – Common utilities and exception handling are abstracted into “oasys-common”.
- Integration via REST Clients – Some services call each other using designated client classes (e.g., UserClient in multiple services).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    A["Frontend (Vue3)"]:::frontend

    %% Backend Entry - API Gateway
    B["API Gateway"]:::gateway

    %% Backend Authentication Service
    C["Authentication Service"]:::auth

    %% Shared Utility Library
    D["Common Library"]:::common

    %% Microservices Subgraph
    subgraph "Core Microservices"
        E["Announcement Service"]:::service
        F["Attendance Service"]:::service
        G["Chat Service"]:::service
        H["File Service"]:::service
        I["Search Service"]:::service
        J["User Service"]:::service
    end

    %% External Integrations
    K["WebSocket & Pulsar"]:::external
    L["MinIO"]:::external

    %% Connections from Frontend to API Gateway
    A -->|"sends request"| B

    %% API Gateway routes to Authentication Service and Microservices
    B -->|"routes"| C
    B -->|"routes"| E
    B -->|"routes"| F
    B -->|"routes"| G
    B -->|"routes"| H
    B -->|"routes"| I
    B -->|"routes"| J

    %% Authentication Service interacts with each Microservice
    C -->|"validates token"| E
    C -->|"validates token"| F
    C -->|"validates token"| G
    C -->|"validates token"| H
    C -->|"validates token"| I
    C -->|"validates token"| J

    %% Each Microservice uses the Common Library
    E -->|"uses"| D
    F -->|"uses"| D
    G -->|"uses"| D
    H -->|"uses"| D
    I -->|"uses"| D
    J -->|"uses"| D

    %% External integrations for specific services
    G -->|"integrates"| K
    H -->|"integrates"| L

    %% Styles
    classDef frontend fill:#fceabb,stroke:#e88900,stroke-width:2px;
    classDef gateway fill:#c1e1ec,stroke:#03719c,stroke-width:2px;
    classDef auth fill:#d2e9c9,stroke:#60992d,stroke-width:2px;
    classDef service fill:#f9d5e5,stroke:#c94c8d,stroke-width:2px;
    classDef common fill:#e2e2e2,stroke:#757575,stroke-width:2px,stroke-dasharray: 5 5;
    classDef external fill:#ffe0b2,stroke:#fb8c00,stroke-width:2px,stroke-dasharray: 3 3;

    %% Click Events for Mapped Components
    click B "https://github.com/furinai/oasys/tree/master/oasys-gateway"
    click C "https://github.com/furinai/oasys/tree/master/oasys-auth"
    click D "https://github.com/furinai/oasys/tree/master/oasys-common"
    click E "https://github.com/furinai/oasys/tree/master/oasys-service/oasys-announcement"
    click F "https://github.com/furinai/oasys/tree/master/oasys-service/oasys-attendance"
    click G "https://github.com/furinai/oasys/tree/master/oasys-service/oasys-chat"
    click H "https://github.com/furinai/oasys/tree/master/oasys-service/oasys-file"
    click I "https://github.com/furinai/oasys/tree/master/oasys-service/oasys-search"
    click J "https://github.com/furinai/oasys/tree/master/oasys-service/oasys-user"
```
