# bdsumon4u/hotashshop architecture

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

- Interactive diagram: https://gitdiagram.com/bdsumon4u/hotashshop
- Repository: https://github.com/bdsumon4u/hotashshop

## Overview

##### Project Type and Purpose
- This is a full-stack Laravel-based e-commerce web application with:
- A user-facing storefront (Blade + Livewire)
- An admin dashboard (Blade templates under resources/views/admin)
- A JSON API for mobile/apps (routes/api.php + Api controllers)
- Integration with external courier service (Pathao)
- Background processing (queues, events, listeners)

##### Top-Level System Components
a. Web Layer
- Nginx/Apache (Dockerfile + 7.4 container) serving public/index.php
- Laravel HTTP Kernel dispatching routes:
– routes/web.php & routes/user.php → User controllers & Blade views
– routes/admin.php → Admin controllers & views
– routes/api.php → API controllers returning JSON
- Livewire components for reactive pieces (cart, product detail, etc.)
b. Application Layer
- Controllers/Livewire (app/Http/Controllers, app/Http/Livewire)
- Middleware (app/Http/Middleware)
- Domain models (Eloquent models in app/*.php)
- Repositories (app/Repositories) for data-access abstraction
- Services & Packages (app/Pathao, packages/hotash/laravel-multi-ui)
- Events & Listeners (app/Events, app/Listeners)
c. Data Layer
- MySQL/MariaDB (via config/database.php, managed in Docker Compose)
- Redis or cache store (config/cache.php)
- File storage (local S3 driver, storage/app/public)
- Search (Laravel Scout) if enabled
d. Background/Asynchronous
- Queue workers (supervisord.conf) processing jobs, events
- Scheduler (cron in Docker container invoking artisan schedule:run)
e. External Systems
- Pathao Courier APIs (app/Pathao/Apis)
- Email/SMS gateways (config/mail.php, app/Notifications)
- Third-party analytics (Google Tag Manager middleware)

##### Architectural Patterns & Design Principles
- MVC (Models, Views, Controllers)
- Event-Driven (app/Events → app/Listeners)
- Repository pattern for data access (app/Repositories)
- Service abstraction for external APIs (facade in app/Pathao/Facade)
- Package-based modularity (packages/hotash/laravel-multi-ui)
- Layered separation: Web → Application → Domain → Infrastructure

##### Relationships & Data Flows
1. User/Browser
– Requests to storefront or admin subdomain → Web server → Laravel
– Authenticated → Controller → Model → View/Livewire → Response
2. API Client
– Requests to /api/* → API controllers → JSON response
3. Order Placement
– Controller validates input → fires OrderPlaced event → Listener sends notification & dispatches Pathao job → Queue worker calls Pathao API → updates order status
4. Admin Actions
– Admin UI controllers handle CRUD (brands, products, settings) → Eloquent → DB
5. Background Jobs
– Queued jobs (exports, notifications) consumed by workers

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients"
        direction TB
        UserBrowser["User Browser"]:::client
        AdminBrowser["Admin Browser"]:::client
        APIClient["API Client"]:::client
    end

    %% Ingress
    UserBrowser -->|HTTPS| LB["Load Balancer / Nginx"]:::app
    AdminBrowser -->|HTTPS| LB
    APIClient -->|HTTPS| LB

    %% Laravel Application
    subgraph "Laravel App"  
        direction TB
        HTTPKernel["Laravel HTTP Kernel"]:::app
        Router["Router"]:::app

        HTTPKernel --> Router

        Router --> WebRoutes["routes/web.php"]:::app
        Router --> UserRoutes["routes/user.php"]:::app
        Router --> AdminRoutes["routes/admin.php"]:::app
        Router --> APIRoutes["routes/api.php"]:::app

        WebRoutes --> Controllers["Controllers (app/Http/Controllers)"]:::app
        UserRoutes --> Controllers
        AdminRoutes --> Controllers
        APIRoutes --> Controllers

        Router --> Middleware["Middleware (app/Http/Middleware)"]:::app
        Controllers --> Livewire["Livewire Components"]:::app

        subgraph "Business Logic"
            direction TB
            DomainModels["Eloquent Models"]:::app
            Repositories["Repositories"]:::app
            Events["Events"]:::app
            Listeners["Listeners"]:::app
            Facade["Pathao Facade"]:::app
            PathaoManage["Pathao Manager"]:::app
        end

        Controllers --> DomainModels
        Controllers --> Repositories
        Controllers -->|"dispatch Event"| Events
        Events -.->|triggers| Listeners
        Listeners -.->|dispatch Job| QueueWorker

        Controllers -->|"Redis GET/SET"| Redis
        Controllers -->|"Store/Retrieve"| Storage

        Livewire --> DomainModels

    end

    %% Data Layer
    subgraph "Data & Cache"
        direction TB
        MySQL["MySQL DB"]:::data
        Redis["Redis Cache"]:::data
        Storage["File Storage"]:::data
    end

    DomainModels --> MySQL
    Repositories --> MySQL

    %% Background Processes
    subgraph "Background / Async"
        direction TB
        QueueWorker["Queue Worker (Supervisor)"]:::async
        Scheduler["Scheduler (cron)"]:::async
    end

    QueueWorker -->|Queue:process| MySQL
    QueueWorker -->|calls| PathaoAPI["Pathao API"]:::external
    Scheduler -->|cron| HTTPKernel

    %% External Services
    subgraph "External Services"
        direction TB
        PathaoAPI
        EmailSMS["Email/SMS Gateway"]:::external
        Analytics["Google Tag Manager"]:::external
    end

    Controllers -->|send| EmailSMS
    Middleware -->|inject| Analytics

    %% Click Events
    click LB "https://github.com/bdsumon4u/hotashshop/tree/master/7.4/Dockerfile"
    click HTTPKernel "https://github.com/bdsumon4u/hotashshop/blob/master/app/Http/Kernel.php"
    click WebRoutes "https://github.com/bdsumon4u/hotashshop/blob/master/routes/web.php"
    click UserRoutes "https://github.com/bdsumon4u/hotashshop/blob/master/routes/user.php"
    click AdminRoutes "https://github.com/bdsumon4u/hotashshop/blob/master/routes/admin.php"
    click APIRoutes "https://github.com/bdsumon4u/hotashshop/blob/master/routes/api.php"
    click Controllers "https://github.com/bdsumon4u/hotashshop/tree/master/app/Http/Controllers"
    click Middleware "https://github.com/bdsumon4u/hotashshop/tree/master/app/Http/Middleware/*"
    click Livewire "https://github.com/bdsumon4u/hotashshop/tree/master/app/Http/Livewire/*"
    click DomainModels "https://github.com/bdsumon4u/hotashshop/blob/master/app/*.php"
    click Repositories "https://github.com/bdsumon4u/hotashshop/blob/master/app/Repositories/SettingRepository.php"
    click Events "https://github.com/bdsumon4u/hotashshop/tree/master/app/Events/*"
    click Listeners "https://github.com/bdsumon4u/hotashshop/tree/master/app/Listeners/*"
    click Facade "https://github.com/bdsumon4u/hotashshop/blob/master/app/Pathao/Facade/Pathao.php"
    click PathaoManage "https://github.com/bdsumon4u/hotashshop/blob/master/app/Pathao/Manage/Manage.php"
    click MySQL "https://github.com/bdsumon4u/hotashshop/blob/master/config/database.php"
    click Redis "https://github.com/bdsumon4u/hotashshop/blob/master/config/cache.php"
    click Storage "https://github.com/bdsumon4u/hotashshop/blob/master/config/filesystems.php"
    click QueueWorker "https://github.com/bdsumon4u/hotashshop/blob/master/7.4/supervisord.conf"
    click Scheduler "https://github.com/bdsumon4u/hotashshop/blob/master/app/Console/Kernel.php"
    click PathaoAPI "https://github.com/bdsumon4u/hotashshop/tree/master/app/Pathao/Apis/*"
    click EmailSMS "https://github.com/bdsumon4u/hotashshop/blob/master/config/mail.php"
    click Analytics "https://github.com/bdsumon4u/hotashshop/blob/master/app/Http/Middleware/GoogleTagManagerMiddleware.php"

    %% Styles
    classDef client fill:#E0F7FA,stroke:#0288D1;
    classDef app fill:#E8F5E9,stroke:#388E3C;
    classDef data fill:#FFF3E0,stroke:#F57C00;
    classDef external fill:#F3E5F5,stroke:#8E24AA;
    classDef async stroke-dasharray: 5 5,stroke:#616161;
```
