# enzoscarpa-fnk/customllm architecture

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

- Interactive diagram: https://gitdiagram.com/enzoscarpa-fnk/customllm
- Repository: https://github.com/enzoscarpa-fnk/customllm

## Overview

##### Project Type and Purpose
- This is a full-stack AI chat web application (“CustomLLM”) built on Laravel 12 with an Inertia/Vue 3 front end and Tailwind CSS.
- It provides authentication (single-user and teams via Fortify & Jetstream), persistent conversation history, real-time streaming from various large language models (OpenAI’s GPT, Google Gemini, Anthropic Claude, etc.), and personalized instruction panels.

##### File Structure Analysis
- Top level:
- config/: Laravel configuration (DB, queues, OpenAI)
- app/: core Laravel MVC code (Controllers, Models, Services, Fortify/Jetstream integration)
- resources/js/: Vue 3 components, pages, composables, Inertia setup
- routes/: web.php & api.php define application endpoints
- database/: migrations, factories, seeders
- public/: index.php entry point + static assets
- storage/: cache, sessions, file uploads
- tests/: feature & unit tests
- Architectural patterns:
- MVC in Laravel (Controllers → Services → Models → DB)
- Inertia bridging Laravel to a SPA-style Vue front end
- Service layer (app/Services/ChatService) orchestrating API calls
- Queued jobs and streaming to support real-time token delivery

##### README Insights
- Confirms core tech stack: Laravel, Inertia, Vue Composition API, Tailwind
- Highlights real-time streaming (via a Composable + ChatService)
- Mentions model selector (stateful per-chat model choice) and secure, collaborative features (Fortify & Jetstream)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (Vue & Inertia)" 
        direction TB
        UI["Browser UI"]:::frontend
        subgraph "Entry & Config"
            direction TB
            AppJS["resources/js/app.js"]:::frontend
            BSJS["resources/js/bootstrap.js"]:::frontend
            AppCSS["resources/css/app.css"]:::frontend
            Tailwind["tailwind.config.js"]:::frontend
        end
        subgraph "Vue Components"
            direction TB
            Components["resources/js/Components/"]:::frontend
            ChatPage["resources/js/Pages/Chat/Index.vue"]:::frontend
            ChatArea["resources/js/Pages/Chat/Partials/ChatArea.vue"]:::frontend
            MessageList["resources/js/Pages/Chat/Partials/MessageList.vue"]:::frontend
            MessageInput["resources/js/Pages/Chat/Partials/MessageInput.vue"]:::frontend
            Sidebar["resources/js/Pages/Chat/Partials/Sidebar.vue"]:::frontend
        end
        subgraph "Composables"
            direction TB
            StreamChat["useStreamChat.js"]:::frontend
            UseChat["useChat.js"]:::frontend
        end
        subgraph "Auth & Pages"
            direction TB
            AuthPages["resources/js/Pages/Auth/*.vue"]:::frontend
            ProfilePage["resources/js/Pages/Profile/Show.vue"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Laravel 12)" 
        direction TB
        subgraph "Routes"
            direction TB
            WebRoutes["routes/web.php"]:::backend
            ApiRoutes["routes/api.php"]:::backend
        end
        subgraph "HTTP Layer (Controllers)"
            direction TB
            AskCtrl["AskController.php"]:::backend
            ConvCtrl["ConversationController.php"]:::backend
            InstrCtrl["UserInstructionController.php"]:::backend
        end
        subgraph "Service Layer"
            direction TB
            ChatSvc["ChatService.php"]:::service
        end
        subgraph "Auth Module"
            direction TB
            FortifyProv["FortifyServiceProvider.php"]:::backend
            JetProv["JetstreamServiceProvider.php"]:::backend
        end
        subgraph "Models & DB"
            direction TB
            ConvModel["Conversation.php"]:::datastore
            MsgModel["Message.php"]:::datastore
            UserModel["User.php"]:::datastore
            DB["Relational Database"]:::datastore
        end
        subgraph "Queue & Streaming"
            direction TB
            QueueCfg["config/queue.php"]:::backend
            Jobs["Laravel Queue Jobs"]:::datastore
        end
        subgraph "Config"
            direction TB
            OpenAIConf["config/openai.php"]:::service
            ServicesConf["config/services.php"]:::service
        end
    end

    %% External Services
    subgraph "External AI Providers"
        direction TB
        OpenAI["OpenAI API"]:::external
        Gemini["Google Gemini"]:::external
        Claude["Anthropic Claude"]:::external
    end

    %% Flows
    UI -->|interacts| AppJS
    AppJS -->|bootstrap| BSJS
    UI -->|renders| Components
    UI -->|uses| StreamChat
    UI -->|uses| UseChat
    Components -->|calls| WebRoutes
    BSJS -->|configures Inertia| WebRoutes
    WebRoutes -->|routes to| AskCtrl
    ApiRoutes -->|routes to| AskCtrl
    AskCtrl -->|calls| ChatSvc
    ConvCtrl -->|reads/writes| ConvModel
    AskCtrl -->|stores messages| MsgModel
    ChatSvc -->|loads credentials| OpenAIConf
    ChatSvc -->|calls| OpenAI
    ChatSvc -->|calls| Gemini
    ChatSvc -->|calls| Claude
    ChatSvc -->|dispatches| Jobs
    Jobs -->|streams to| StreamChat
    ConvModel -->|persists| DB
    MsgModel -->|persists| DB
    UserModel -->|persists| DB

    %% Click events
    click AppJS "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/app.js"
    click BSJS "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/bootstrap.js"
    click AppCSS "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/css/app.css"
    click Tailwind "https://github.com/enzoscarpa-fnk/customllm/blob/master/tailwind.config.js"
    click Components "https://github.com/enzoscarpa-fnk/customllm/tree/master/resources/js/Components/"
    click ChatPage "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/Pages/Chat/Index.vue"
    click ChatArea "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/Pages/Chat/Partials/ChatArea.vue"
    click MessageList "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/Pages/Chat/Partials/MessageList.vue"
    click MessageInput "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/Pages/Chat/Partials/MessageInput.vue"
    click Sidebar "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/Pages/Chat/Partials/Sidebar.vue"
    click StreamChat "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/Composables/useStreamChat.js"
    click UseChat "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/Composables/useChat.js"
    click AuthPages "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/Pages/Auth/*.vue"
    click ProfilePage "https://github.com/enzoscarpa-fnk/customllm/blob/master/resources/js/Pages/Profile/Show.vue"
    click WebRoutes "https://github.com/enzoscarpa-fnk/customllm/blob/master/routes/web.php"
    click ApiRoutes "https://github.com/enzoscarpa-fnk/customllm/blob/master/routes/api.php"
    click AskCtrl "https://github.com/enzoscarpa-fnk/customllm/blob/master/app/Http/Controllers/AskController.php"
    click ConvCtrl "https://github.com/enzoscarpa-fnk/customllm/blob/master/app/Http/Controllers/ConversationController.php"
    click InstrCtrl "https://github.com/enzoscarpa-fnk/customllm/blob/master/app/Http/Controllers/UserInstructionController.php"
    click ChatSvc "https://github.com/enzoscarpa-fnk/customllm/blob/master/app/Services/ChatService.php"
    click ConvModel "https://github.com/enzoscarpa-fnk/customllm/blob/master/app/Models/Conversation.php"
    click MsgModel "https://github.com/enzoscarpa-fnk/customllm/blob/master/app/Models/Message.php"
    click UserModel "https://github.com/enzoscarpa-fnk/customllm/blob/master/app/Models/User.php"
    click QueueCfg "https://github.com/enzoscarpa-fnk/customllm/blob/master/config/queue.php"
    click OpenAIConf "https://github.com/enzoscarpa-fnk/customllm/blob/master/config/openai.php"
    click ServicesConf "https://github.com/enzoscarpa-fnk/customllm/blob/master/config/services.php"

    %% Styles
    classDef frontend fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef backend fill:#A0D995,stroke:#333,stroke-width:1px
    classDef service fill:#F7C06B,stroke:#333,stroke-width:1px
    classDef datastore fill:#CDA1F9,stroke:#333,stroke-width:1px
    classDef external fill:#F495AD,stroke:#333,stroke-width:1px
```
