# lucasnvs/siboon architecture

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

- Interactive diagram: https://gitdiagram.com/lucasnvs/siboon
- Repository: https://github.com/lucasnvs/siboon

## Overview

##### Project Type and Purpose
- The project is an e-commerce platform for a skate shop. It follows the MVC pattern and is designed as a full-stack web application with distinct modules for API endpoints, administrative interfaces, and public-facing web/app views.
- Key functionalities include user authentication, shopping cart management (with LocalStorage), integration with external services (simulated Payment and Shipment via MockWebService), and a well-structured database backend (MySQL).
- The README also notes the usage of PHP, Composer for dependency management, CoffeeCode Router for routing, Plates Template Engine for templating, and Firebase JWT for authentication.

##### Analyzing the File Structure
- Top-level Files/Directories:
- .env.example (environment configuration), .htaccess files (URL rewriting/security), index.php (entry point).
- "api" directory: Contains its own .htaccess, README, and index.php – this indicates a dedicated API layer for service integration.
- "db" directory: Holds SQL schema and test initialization scripts indicating database setup and population.
- "source" directory: Houses the core PHP application logic (Boot, Controller, Core, Exceptions, Models, etc.). This is the backbone following the MVC pattern.
- The "themes" directory is well organized into subdirectories such as admin, app, shared, and web. They represent different presentation layers for various user interfaces:
- "admin" for administration,
- "app" for mobile or a specialized shopping experience,
- "web" for the public website,
- "shared" for common scripts and component libraries managed by the frontend.

##### Key Components
a. Backend (Server-Side):
- Application Core: Represent the "source" directory split into modules such as Controllers (AdminController, Api Controllers, WebController), Models (handling business logic for Company, Faq, Inventory, Order, Product, User, Website), and Core utilities (API Controller, TokenJWT, configuration, exception handling).
- API Module: Show the dedicated "api" directory and its interactions with API controllers located under the source (e.g., Api controllers in source/Controller/Api) and with external clients.
- External Services Integration: Include the "MockWebService" components for Payment and Shipment. Indicate that these simulate external integrations.

b. Frontend (Client-Side):

c. Database:
- MySQL Database: Represented by the "db" components, with SQL schema (siboon_schemas.sql) and initialization/test scripts. Indicate data flow between Models and the database.

d. External Libraries & Frameworks:

##### Illustrating Relationships and Interactions
- From the client (different themes) to the web controllers.
- From the API endpoints (api directory and its controllers) to any external client (e.g., mobile apps or third-party integrations).
- From Controllers to Models – outlining how the MVC pattern processes user requests.
- From Models to the Database (MySQL) to indicate CRUD operations.

##### Emphasizing Architectural Patterns and Design Principles
- Separation of concerns: the API layer is explicitly separated from the main web app while sharing common business logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend (Client-Side)
    subgraph "Frontend (Client-Side)"
        FE_Admin["Admin Interface (themes/admin)"]:::frontend
        FE_App["App Interface (themes/app)"]:::frontend
        FE_Web["Public Website (themes/web)"]:::frontend
        FE_Shared["Shared Assets (themes/shared)"]:::frontend
    end

    %% Backend (Server-Side)
    subgraph "Backend (Server-Side)"
        BE_Core["Application Core (MVC)"]:::backend
        subgraph "Boot & Configuration"
            BE_Boot["Boot & Configuration"]:::backend
        end
        subgraph "Controllers"
            BE_AdminController["Admin Controller"]:::backend
            BE_WebController["Web Controller"]:::backend
            BE_APIControllers["API Controllers"]:::backend
        end
        subgraph "Models"
            BE_Models["Business Logic Models"]:::backend
        end
        BE_Token["Token Authentication"]:::backend
        subgraph "External Services Integration"
            BE_Payment["Mock Payment Service"]:::backend
            BE_Shipment["Mock Shipment Service"]:::backend
        end
    end

    %% API Module
    subgraph "API Module"
        API_EP["API Entry Point (api)"]:::backend
    end

    %% Database
    DB["MySQL Database"]:::database

    %% External Libraries & Tools
    subgraph "External Libraries & Tools"
        EX_Composer["Composer & Dependencies"]:::external
        EX_Libraries["CoffeeCode Router, Plates, Firebase JWT"]:::external
    end

    %% Relationships
    %% Frontend to Controllers
    FE_Web -->|"sends request"| BE_WebController
    FE_Admin -->|"sends request"| BE_AdminController
    FE_App -->|"sends API call"| API_EP

    %% API Module to API Controllers
    API_EP -->|"routes to"| BE_APIControllers

    %% Application Core hierarchy
    BE_Core --> BE_Boot
    BE_Boot --> BE_AdminController
    BE_Boot --> BE_WebController
    BE_Boot --> BE_APIControllers
    BE_Core --> BE_Token
    BE_Core --> BE_Models
    BE_Core --> BE_Payment
    BE_Core --> BE_Shipment

    %% Controllers interactions with Models and External Services
    BE_AdminController -->|"CRUD operations"| BE_Models
    BE_WebController -->|"CRUD operations"| BE_Models
    BE_APIControllers -->|"CRUD operations"| BE_Models

    BE_AdminController -->|"integrates"| BE_Payment
    BE_AdminController -->|"integrates"| BE_Shipment
    BE_WebController -->|"integrates"| BE_Payment
    BE_WebController -->|"integrates"| BE_Shipment
    BE_APIControllers -->|"integrates"| BE_Payment
    BE_APIControllers -->|"integrates"| BE_Shipment

    %% Models to Database
    BE_Models -->|"persists data"| DB

    %% Token usage by Controllers
    BE_Token -->|"authenticates"| BE_AdminController
    BE_Token -->|"authenticates"| BE_WebController
    BE_Token -->|"authenticates"| BE_APIControllers

    %% External Libraries support Application Core
    EX_Composer -->|"manages"| BE_Core
    EX_Libraries -->|"supports"| BE_Core

    %% Click Events
    click BE_Core "https://github.com/lucasnvs/siboon/tree/main/source/"
    click BE_Boot "https://github.com/lucasnvs/siboon/blob/main/source/Boot/Config.php"
    click BE_AdminController "https://github.com/lucasnvs/siboon/blob/main/source/Controller/AdminController.php"
    click BE_WebController "https://github.com/lucasnvs/siboon/blob/main/source/Controller/WebController.php"
    click BE_APIControllers "https://github.com/lucasnvs/siboon/tree/main/source/Controller/Api/"
    click BE_Models "https://github.com/lucasnvs/siboon/tree/main/source/Models/"
    click BE_Token "https://github.com/lucasnvs/siboon/blob/main/source/Core/TokenJWT.php"
    click BE_Payment "https://github.com/lucasnvs/siboon/tree/main/source/MockWebService/"
    click BE_Shipment "https://github.com/lucasnvs/siboon/tree/main/source/MockWebService/"
    click API_EP "https://github.com/lucasnvs/siboon/tree/main/api/"
    click DB "https://github.com/lucasnvs/siboon/tree/main/db/"
    click FE_Admin "https://github.com/lucasnvs/siboon/tree/main/themes/admin/"
    click FE_App "https://github.com/lucasnvs/siboon/tree/main/themes/app/"
    click FE_Web "https://github.com/lucasnvs/siboon/tree/main/themes/web/"
    click FE_Shared "https://github.com/lucasnvs/siboon/tree/main/themes/shared/"
    click EX_Composer "https://github.com/lucasnvs/siboon/blob/main/composer.json"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef database fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
