# fliz-none/capstoneproject architecture

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

- Interactive diagram: https://gitdiagram.com/fliz-none/capstoneproject
- Repository: https://github.com/fliz-none/capstoneproject

## Overview

##### Project Type and Purpose
- This is a composite capstone monorepo containing two major subsystems:
a. LaravelCore – a full-stack Laravel application providing both an administrator dashboard and a customer-facing web shop, including REST endpoints, templated views, real-time chat, and scheduled background jobs.
b. RasaBot – a standalone Rasa NLU/Dialogue microservice that handles conversational queries (e.g., check order, check product, promotions, stock) and custom action logic, often querying the same database.

##### High-Level File-Structure Analysis
- LaravelCore
- app/: Controllers (split into Admin and public controllers), Models, Events, Jobs, Observers, Middleware, Console Commands, Helpers, Rules, Mail, Providers.
- config/, database/ (migrations, seeders), routes/, resources/views/, public/, storage/, tests/
- Integrations: Pusher (real-time chat broadcasts), scheduled tasks (Kernel.php), queued jobs (e.g., ProcessRasaMessage).
- RasaBot
- config.yml, credentials.yml, endpoints.yml – Rasa server configuration
- data/: NLU training data, rules, stories
- domain.yml – intents, entities, slots
- actions/: custom Python code (actions.py, db_helper.py) to query the shared database
- main.py – Rasa runner entrypoint
- models/: trained Rasa model tarball

##### Key README Insights
- Minimal README: project titled “CapstoneProject,” implying a showcase/integration of ecommerce and conversational AI.

##### Main Components
a. Client Layer
- End Users (Web Browsers / Mobile)
- Admin Users (Browser)
- Chat Widgets embedded in both public and admin UIs
b. Web Application Layer (LaravelCore)
- HTTP Controllers (Admin vs Web vs API)
- Middleware (Auth, GlobalSettings, isAdmin, CSRF)
- Business Logic (Services, Jobs, Console Commands)
- Real-time Layer (Pusher channel broadcasting events)
c. Data Layer
- MySQL (or configured relational database) for persistent storage (users, products, orders, conversations, etc.)
- File Storage (local disk under storage/app/public for attachments, images)
d. Conversational AI Layer (RasaBot)
- Rasa Core & NLU Engine – HTTP endpoint (/webhooks/rest/webhook)
- Custom Actions – Python code that connects to the same database via db_helper
- Training Data & Models
e. External Services
- Pusher (for broadcasting chat messages)
- SMTP (Mail::SendMail) for notifications
- Google Drive (GoogleDriveServiceProvider)

##### Relationships and Data Flows
1. User ⇄ LaravelCore Web UI
- Standard HTTP GET/POST (blade templates, JS, CSS)
- Chat UI posts messages to Laravel ChatController
2. LaravelCore ⇄ Database
- Eloquent ORM (app/Models) for CRUD
- Migrations & Seeders for schema and test data
3. LaravelCore ⇄ RasaBot
- ChatController or queued job (ProcessRasaMessage) makes an HTTP request to Rasa HTTP API
- Rasa processes intent via trained model, then calls custom action endpoint (actions.py)
- Custom action queries database and returns a structured reply
- Rasa returns final message payload back to Laravel
4. LaravelCore ⇄ Pusher
- Once Laravel receives Rasa response, it fires PusherBroadcast event
- Clients subscribed to the channel receive real-time updates

##### Architectural Patterns / Principles
- MVC (Laravel’s controllers, models, views)
- Microservice style for AI (RasaBot)
- Event-driven in chat subsystem (Jobs, Events, Pusher)
- Layered separation: Presentation (Views/JS), Application (Controllers/Jobs), Domain (Models/Services), Infrastructure (DB, External APIs)

- Component boundaries with labels

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Client Layer"
        direction TB
        EndUser["End Users (Web/Mobile)"]:::clients
        AdminUser["Admin Users (Browser)"]:::clients
        ChatWidget["Chat Widget"]:::clients
    end

    %% LaravelCore Application
    subgraph "LaravelCore (Administrator & Web Shop)" 
        direction TB
        subgraph "HTTP Controllers"
            direction TB
            CtrlAdmin["Admin Controllers"]:::laravel
            CtrlPublic["Public/Web/API Controllers"]:::laravel
        end
        Middleware["Middleware (Auth, CSRF, isAdmin)"]:::laravel
        subgraph "Business Logic"
            direction TB
            JobProcRasa["Job: ProcessRasaMessage"]:::laravel
            EventPusher["Event: PusherBroadcast"]:::laravel
            ConsoleCmds["Console Commands"]:::laravel
        end
        Models["Models (Eloquent ORM)"]:::laravel
        Observers["Observers"]:::laravel
        ProviderGoogle["GoogleDriveServiceProvider"]:::laravel
        MailSend["Mail: SendMail (SMTP)"]:::laravel
        Config["Configuration Files"]:::laravel
        Routes["Routes (web, api, channels, console)"]:::laravel
        subgraph "Views & Assets"
            direction TB
            ViewsAdmin["Admin Blade Views"]:::laravel
            ViewsWeb["Public Blade Views"]:::laravel
            PublicDir["Public Assets (CSS/JS/Images)"]:::laravel
        end
        Kernel["Kernel (Scheduled Tasks)"]:::laravel
    end

    %% Data Layer
    DB[(MySQL Database)]:::db
    Storage[[File Storage]]:::storage

    %% RasaBot Service
    subgraph "RasaBot (Conversational AI Microservice)"
        direction TB
        RasaServer["Rasa HTTP API (port 5005)"]:::rasa
        subgraph "Configuration & Data"
            direction TB
            RasaConfig["config.yml, credentials.yml, endpoints.yml, domain.yml"]:::rasa
            RasaData["Training Data (data/)"]:::rasa
            RasaModels["Trained Models (models/)"]:::rasa
        end
        subgraph "Custom Actions"
            direction TB
            ActionsPy["actions.py"]:::rasa
            DBHelper["db_helper.py"]:::rasa
        end
        RasaServer --> ActionsPy
        RasaServer --> DBHelper
    end

    %% External Services
    subgraph "External Services"
        direction TB
        Pusher["Pusher (Real-time)"]:::ext
        SMTP["SMTP Mail"]:::ext
        GoogleDrive["Google Drive API"]:::ext
    end

    %% Relationships
    EndUser -->|"HTTP GET/POST"| CtrlPublic
    AdminUser -->|"HTTP GET/POST"| CtrlAdmin
    ChatWidget -->|"postMessage"| CtrlPublic
    ChatWidget -->|"postMessage"| CtrlAdmin

    CtrlPublic -->|uses| Middleware
    CtrlAdmin -->|uses| Middleware
    CtrlPublic -->|calls| Models
    CtrlAdmin -->|calls| Models

    CtrlPublic -->|dispatch| JobProcRasa
    JobProcRasa -->|HTTP| RasaServer
    RasaServer -->|responds| JobProcRasa
    JobProcRasa -->|fires| EventPusher
    EventPusher -->|publish| Pusher
    Pusher -->|pushEvents| ChatWidget

    RasaServer -->|queries| DB
    ActionsPy -->|queries| DB
    DBHelper -->|queries| DB

    Models -->|CRUD| DB
    Observers -->|listen| Models
    ConsoleCmds -->|scheduled via| Kernel
    Kernel -->|runs| ConsoleCmds

    MailSend -->|sends| SMTP
    ProviderGoogle -->|uploads| GoogleDrive
    Config -->|configures| DB
    Config -->|configures| Pusher
    Config -->|configures| MailSend
    Config -->|configures| GoogleDrive

    ViewsAdmin -->|render| AdminUser
    ViewsWeb -->|render| EndUser
    PublicDir -->|serves assets to| EndUser
    PublicDir -->|serves assets to| AdminUser

    %% Storage
    Storage -->|stores attachments| PublicDir

    %% Click Events
    click CtrlAdmin "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/app/Http/Controllers/Admin/"
    click CtrlPublic "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/app/Http/Controllers/"
    click Middleware "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/app/Http/Middleware/"
    click JobProcRasa "https://github.com/fliz-none/capstoneproject/blob/main/LaravelCore/app/Jobs/ProcessRasaMessage.php"
    click EventPusher "https://github.com/fliz-none/capstoneproject/blob/main/LaravelCore/app/Events/PusherBroadcast.php"
    click ConsoleCmds "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/app/Console/Commands/"
    click Models "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/app/Models/"
    click Observers "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/app/Observers/"
    click ProviderGoogle "https://github.com/fliz-none/capstoneproject/blob/main/LaravelCore/app/Providers/GoogleDriveServiceProvider.php"
    click MailSend "https://github.com/fliz-none/capstoneproject/blob/main/LaravelCore/app/Mail/SendMail.php"
    click Config "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/config/"
    click Routes "https://github.com/fliz-none/capstoneproject/blob/main/LaravelCore/routes/web.php"
    click ViewsAdmin "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/resources/views/admin/"
    click ViewsWeb "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/resources/views/web/"
    click PublicDir "https://github.com/fliz-none/capstoneproject/tree/main/LaravelCore/public/"
    click Kernel "https://github.com/fliz-none/capstoneproject/blob/main/LaravelCore/app/Console/Kernel.php"
    click RasaServer "https://github.com/fliz-none/capstoneproject/blob/main/RasaBot/main.py"
    click RasaConfig "https://github.com/fliz-none/capstoneproject/blob/main/RasaBot/config.yml"
    click RasaData "https://github.com/fliz-none/capstoneproject/tree/main/RasaBot/data/"
    click RasaModels "https://github.com/fliz-none/capstoneproject/tree/main/RasaBot/models/"
    click ActionsPy "https://github.com/fliz-none/capstoneproject/blob/main/RasaBot/actions/actions.py"
    click DBHelper "https://github.com/fliz-none/capstoneproject/blob/main/RasaBot/actions/db_helper.py"

    %% Styles
    classDef clients fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef laravel fill:#90EE90,stroke:#333,stroke-width:1px
    classDef rasa fill:#FFA500,stroke:#333,stroke-width:1px
    classDef db fill:#CCCCCC,stroke:#333,stroke-width:1px,shape:cylinder
    classDef storage fill:#E0E0E0,stroke:#333,stroke-width:1px,shape:rect
    classDef ext fill:#D3D3D3,stroke:#333,stroke-width:1px,shape:cloud
```
