# rokon12/llm-jakarta architecture

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

- Interactive diagram: https://gitdiagram.com/rokon12/llm-jakarta
- Repository: https://github.com/rokon12/llm-jakarta

## Overview

- Frontend → WebSocket → Backend Services
- Backend → Database

- Backend → OpenAI API
- WebSocket message flows

##### Key Architectural Elements to Highlight

a. Multi-layered Architecture:
- [Frontend] → [WebSocket Layer] → [Service Layer] → [External Services]
- → [Database Layer]

b. Feature Progression (Show as connected modules):
- Basic Chat (Step 00-01)
- Persistence (Step 02)
- Project Generation (Step 03)
- RAG Implementation (Step 04-06)

##### Important Technical Details

- Jakarta EE
- WebSocket
- JSF
- LangChain4j
- PostgreSQL
- Docker

b. Configuration Elements:
- Environment Variables (OPENAI_API_KEY, LLM_JAKARTA_DOCUMENTS_DIR)
- MicroProfile Config
- Persistence Configuration

- [User Interface Layer]
- ↓
- [Communication Layer]
- ↓
- [Business Logic Layer]
- ↓
- [Integration Layer]
- ↓
- [Persistence Layer]

##### Additional Elements

- Version/step numbers for different features
- Scaling possibilities
- Configuration points

Remember to:
- Use consistent styling
- Clear labels
- Data flow directions
- Integration points
- Document dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI["User Interface Layer"]
        JSF["JSF Web Interface"]:::frontend
        WS_Client["WebSocket Client"]:::frontend
        CSS["CSS Styling"]:::frontend
    end

    subgraph COMM["Communication Layer"]
        WS_EP["WebSocket Endpoint"]:::backend
    end

    subgraph BL["Business Logic Layer"]
        LC_Service["LangChain Service"]:::backend
        JEE_Agent["Jakarta EE Agent"]:::backend
    end

    subgraph CONFIG["Configuration Layer"]
        App_Config["App Config"]:::config
        Config_Prop["Config Properties"]:::config
        Startup["Startup Bean"]:::config
        MP_Config["MicroProfile Config"]:::config
    end

    subgraph INT["Integration Layer"]
        OpenAI["OpenAI API"]:::external
        RAG["RAG System"]:::backend
        Doc_Store["Document Storage"]:::storage
    end

    subgraph INFRA["Infrastructure Layer"]
        WildFly["WildFly Server"]:::infra
        Docker["Docker Container"]:::infra
        Postgres["PostgreSQL"]:::database
    end

    %% Frontend Connections
    JSF --> WS_Client
    WS_Client --> WS_EP
    CSS --> JSF

    %% Backend Flow
    WS_EP --> LC_Service
    LC_Service --> JEE_Agent
    JEE_Agent --> OpenAI
    JEE_Agent --> RAG
    RAG --> Doc_Store
    LC_Service --> Postgres

    %% Configuration
    App_Config --> LC_Service
    Config_Prop --> LC_Service
    Startup --> LC_Service
    MP_Config --> App_Config

    %% Infrastructure
    WildFly --> Postgres
    Docker --> Postgres

    %% Click Events
    click JSF "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/webapp/chat.xhtml"
    click WS_Client "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/webapp/resources/js/chat.js"
    click CSS "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/webapp/resources/css/chat.css"
    click WS_EP "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/java/learning/jakarta/ai/ChatWebSocket.java"
    click LC_Service "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/java/learning/jakarta/ai/LangChainService.java"
    click JEE_Agent "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/java/learning/jakarta/ai/JakartaEEAgent.java"
    click App_Config "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/java/learning/jakarta/ai/config/AppConfig.java"
    click Config_Prop "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/java/learning/jakarta/ai/config/ConfigProp.java"
    click Startup "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/java/learning/jakarta/ai/config/StartupBean.java"
    click MP_Config "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/src/main/resources/META-INF/microprofile-config.properties"
    click Postgres "https://github.com/rokon12/llm-jakarta/blob/workshop/step-06/scripts/configure-postgresql.cli"
    click Docker "https://github.com/rokon12/llm-jakarta/blob/workshop/deploy/docker-compose.yml"
    click Doc_Store "https://github.com/rokon12/llm-jakarta/tree/workshop/documents/"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef config fill:#FF9800,stroke:#F57C00,color:white
    classDef external fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef infra fill:#757575,stroke:#424242,color:white
    classDef database fill:#607D8B,stroke:#455A64,color:white
    classDef storage fill:#795548,stroke:#5D4037,color:white
```
