# aymanelh/lakarte architecture

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

- Interactive diagram: https://gitdiagram.com/aymanelh/lakarte
- Repository: https://github.com/aymanelh/lakarte

## Overview

##### Project Type and Purpose
- This is a full-stack web application comprising:
- A Laravel-powered backend (REST API + Filament admin panel)
- A React SPA public frontend
- A MySQL (or compatible) database plus cache/session stores
- Purpose: manage and display “packs,” “pack offers,” blogs, testimonials and orders, with a secure admin interface (Filament) and a public-facing marketing/payment flow.

##### Main Components
a. Public Frontend (React SPA)
- Directory: `react/`
- Key files: `src/pages/*`, `src/components/*`, `src/services/*`, `vite.config.ts`
- Responsibilities: render pages (Home, Blog, Packs, Templates, Testimonials), handle user auth (login/register), call backend API.
b. Backend API (Laravel)
- Entry point: `public/index.php`, `routes/api.php`, `routes/web.php`
- Layers:
- Controllers (`app/Http/Controllers/Api/*`)
- Request validation (`app/Http/Requests/Auth/*`)
- Service layer (`app/Services/*`)
- Eloquent models (`app/Models/*`)
- Resources/transformers (`app/Http/Resources/*`)
- Responsibilities: authenticate (Sanctum/Passport), CRUD for packs, orders, blogs, testimonials; business rules, payment validation.
c. Admin Panel (Filament)
- Directory: `app/Filament/*`, `resources/views/filament/*`
- Provides CRUD UI for all entities via PHP classes (`Resources`, `Widgets`).
d. Data Stores
- Relational database (MySQL/Postgres): tables for users, packs, orders, blogs, testimonials, etc.
- Cache/session driver (Redis/file)
- File storage (local or S3) for uploads.
e. External Services
- Payment gateway (configured in `config/services.php`)
- Email/SMS providers (mail drivers in `config/mail.php`)
- Third-party analytics or logging if used.
f. DevOps / Infrastructure
- Docker (`Dockerfile`, `docker-compose.yml`)
- CI pipeline (GitHub Actions badge in README)
- Env management (`.env.example`)

##### Relationships and Data Flows
- User ⇄ React SPA (HTTPS)
- React SPA → Laravel API (REST calls with JWT/Sanctum tokens)
- API → Database (CRUD via Eloquent)
- API → Cache/Session (for rate-limiting, sessions)
- API → External Payment Service (HTTP webhooks/callbacks)
- Admin User ⇄ Filament UI → Laravel backend (Blade templates, controllers)
- Migrations/Seeders → Database (init / test data)

##### Architectural Patterns and Design Principles
- MVC on backend + Service Layer for business logic (`app/Services`)
- Single-Page Application on frontend with Context API for auth and hooks for data fetching
- RESTful API contracts using Laravel Resources
- Filament Admin: code-driven CRUD panels and widgets (component-based pattern)
- 12-factor app principles (env config, stateless processes, separate build & run)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Presentation Layer"
        FR["React SPA"]:::frontend
        FA["Filament Admin"]:::frontend
    end

    subgraph "Backend Layer"
        subgraph "Entry & Routing"
            EP["public/index.php"]:::backend
            AR["routes/api.php"]:::backend
            WR["routes/web.php"]:::backend
        end
        subgraph "Controllers & Validation"
            CTRL["app/Http/Controllers/Api/"]:::backend
            REQ["app/Http/Requests/Auth/"]:::backend
        end
        subgraph "Business Logic"
            SRV["app/Services/"]:::backend
        end
        subgraph "Data Models & Transformers"
            MOD["app/Models/"]:::backend
            RES["app/Http/Resources/"]:::backend
        end
    end

    subgraph "Data Stores"
        DB["MySQL Database"]:::datastore
        CACHE["Redis/File Cache & Sessions"]:::datastore
        STORAGE["File Storage (Local/S3)"]:::datastore
    end

    subgraph "External Services"
        PAY["Payment Gateway"]:::external
        MAIL["Email/SMS Provider"]:::external
        ANALYTICS["Analytics/Logging"]:::external
    end

    %% Flows
    FR -->|HTTPS / REST API| AR
    AR -->|routes to| CTRL
    WR -->|routes to| CTRL
    EP -->|bootstraps| AR
    EP -->|bootstraps| WR
    CTRL -->|validates via| REQ
    CTRL -->|calls| SRV
    SRV -->|uses| MOD
    CTRL -->|transforms via| RES
    MOD -->|persists| DB
    SRV -->|caches| CACHE
    SRV -->|stores files| STORAGE
    SRV -->|calls| PAY
    SRV -->|calls| MAIL
    CTRL -->|logs to| ANALYTICS
    FA -->|Blade UI / HTTP| WR

    %% Click Events
    click FR "https://github.com/aymanelh/lakarte/tree/develop/react/"
    click EP "https://github.com/aymanelh/lakarte/blob/develop/public/index.php"
    click AR "https://github.com/aymanelh/lakarte/blob/develop/routes/api.php"
    click WR "https://github.com/aymanelh/lakarte/blob/develop/routes/web.php"
    click CTRL "https://github.com/aymanelh/lakarte/tree/develop/app/Http/Controllers/Api/"
    click REQ "https://github.com/aymanelh/lakarte/tree/develop/app/Http/Requests/Auth/"
    click SRV "https://github.com/aymanelh/lakarte/tree/develop/app/Services/"
    click MOD "https://github.com/aymanelh/lakarte/tree/develop/app/Models/"
    click RES "https://github.com/aymanelh/lakarte/tree/develop/app/Http/Resources/"
    click FA "https://github.com/aymanelh/lakarte/tree/develop/app/Filament/"

    %% Styles
    classDef frontend fill:#D0E9FF,stroke:#0366D6,color:#0366D6;
    classDef backend fill:#E6F4EA,stroke:#22863A,color:#22863A;
    classDef datastore fill:#FFF5B1,stroke:#D29922,color:#735C0F;
    classDef external fill:#F0F0F0,stroke:#6A737D,color:#6A737D;
```
