# kudzeri/wear-shop-api architecture

> Architecture diagram of the GitHub repository kudzeri/wear-shop-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kudzeri/wear-shop-api
- Repository: https://github.com/kudzeri/wear-shop-api

## Overview

##### Main Components
- Client/Frontend: Although the public directory holds static assets and possibly a client-side application (using Vite, Tailwind, and JavaScript frameworks), the primary focus is on an API-layer that serves both public endpoints (e.g., product listing) and authenticated user endpoints.
- Admin Panel (Filament): Represent the dedicated Filament admin panel module – including its resources and pages to manage products, categories, users, promos, etc.
- Models and Database: Include the core models (User, Product, Order, Category, etc.) which interact with the SQL-based database (migrations, seeders) to manage persistent data.
- Services and Business Logic: Include separate service layers (LoyaltyService, OrderService, RussianPostService, SdekService, YooKassaService) which encapsulate core business logic and integrate with external systems.
- External Integrations: Show external components like payment gateways (YooKassa), shipping services (RussianPost, Sdek), and integration with 1C via specialized export functionality (Excel exporters and Report1CController).

##### Relationships and Interactions
- Flow from Client Requests → API Routes (documented endpoints) → Controllers. Then have controllers use Services (like OrderService or LoyaltyService) that manipulate Models and persist data to the Database.
- For administrative tasks, show a separate incoming channel from the /admin link which feeds into the Filament admin panel. Components inside Filament (Resources and Widgets) interact with the same underlying Models and Services.
- Data flows back from the Database to the API layer ensuring consistency and returning responses to the client.

##### Architectural Patterns and Design Principles
- Model-View-Controller (MVC): Highlight the separation of concerns – Models for data, Controllers for handling HTTP requests, and Views/Resources (in admin and public pages) for rendering.
- Service Layer: Emphasize the distinct business logic encapsulated in the Services directory.
- Use of Middleware: Note that middleware (like CheckAdminRole) enforces authentication and authorization on routes.
- Extensibility with Filament: Outline how the admin panel itself is modular with separate Filament resources for each domain entity.

##### Technologies and Frameworks
- Laravel PHP Framework is the backbone.
- Filament for the administration interface.
- Composer for dependency management and npm/Vite for asset bundling.
- L5 Swagger for API documentation.
- Docker for containerization.
- Various PHP packages for authentication, permissions, file storage, etc.

##### Elements
- “Client/Frontend (Static Assets & API Consumers)”
- “API Layer & Controllers”
- “Business Logic / Services Layer”
- “Models & Database Layer”
- “Admin Panel (Filament)”
- “External Integrations (YooKassa, RussianPost, Sdek, 1C Exporters)”
- “Documentation (Swagger)”
- From Clients to API Controllers via routes.
- Controllers calling Services: Services interacting with Models and Database.
- Admin Panel interacting with same backend services.
- External services triggered by PaymentService or ShippingService.
- External integrations distinctively marked.
- Component is clearly labeled and interconnected based on dependency and data flow.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client & Frontend"
        StaticAssets["Static Assets"]:::frontend
        ClientAssets["Client Assets"]:::frontend
    end

    subgraph "API Layer"
        APIRoutes["API Routes"]:::api
        Controllers["Controllers"]:::api
    end

    subgraph "Business Logic / Services Layer"
        Services["Services"]:::service
    end

    subgraph "External Integrations - Controllers"
        YPC["YooKassaPaymentController"]:::integrations
        RPC["RussianPostController"]:::integrations
        SC["SdekController"]:::integrations
        R1C["Report1CController"]:::integrations
    end

    subgraph "External Integrations - Services"
        YS["YooKassaService"]:::integrations
        RS["RussianPostService"]:::integrations
        SS["SdekService"]:::integrations
    end

    subgraph "Models & Database Layer"
        Models["Models"]:::models
        Database["Database (Migrations&Seeders)"]:::models
    end

    subgraph "Admin Panel (Filament)"
        FilamentCore["Filament Core"]:::admin
        FilamentResources["Filament Resources"]:::admin
    end

    subgraph "Documentation & Configuration"
        SwaggerDocs["Swagger Docs"]:::docs
        DeveloperTools["Developer Tools"]:::docs
    end

    %% Data flow connections
    StaticAssets --> APIRoutes
    ClientAssets --> APIRoutes
    APIRoutes --> Controllers
    Controllers --> Services
    Services --> Models
    Models --> Database
    Services --> YS
    Services --> RS
    Services --> SS
    %% External integration controllers triggering their services (dashed connections)
    YPC -.-> YS
    RPC -.-> RS
    SC -.-> SS
    %% Admin Panel interactions
    FilamentCore --> Services
    FilamentResources --> Services
    %% API documentation link from API layer
    APIRoutes --> SwaggerDocs
    %% Developer tools overview connection (bidirectional)
    DeveloperTools --- Services

    %% Click Events
    click StaticAssets "https://github.com/kudzeri/wear-shop-api/tree/main/public/"
    click ClientAssets "https://github.com/kudzeri/wear-shop-api/tree/main/resources/"
    click APIRoutes "https://github.com/kudzeri/wear-shop-api/blob/main/routes/api.php"
    click Controllers "https://github.com/kudzeri/wear-shop-api/tree/main/app/Http/Controllers/"
    click Services "https://github.com/kudzeri/wear-shop-api/tree/main/app/Services/"
    click Models "https://github.com/kudzeri/wear-shop-api/tree/main/app/Models/"
    click Database "https://github.com/kudzeri/wear-shop-api/tree/main/database/migrations/"
    click FilamentCore "https://github.com/kudzeri/wear-shop-api/tree/main/app/Filament/"
    click FilamentResources "https://github.com/kudzeri/wear-shop-api/tree/main/filament/Resources/"
    click YPC "https://github.com/kudzeri/wear-shop-api/blob/main/app/Http/Controllers/YooKassaPaymentController.php"
    click RPC "https://github.com/kudzeri/wear-shop-api/blob/main/app/Http/Controllers/RussianPostController.php"
    click SC "https://github.com/kudzeri/wear-shop-api/blob/main/app/Http/Controllers/SdekController.php"
    click R1C "https://github.com/kudzeri/wear-shop-api/blob/main/app/Http/Controllers/Report1CController.php"
    click YS "https://github.com/kudzeri/wear-shop-api/blob/main/app/Services/YooKassaService.php"
    click RS "https://github.com/kudzeri/wear-shop-api/blob/main/app/Services/RussianPostService.php"
    click SS "https://github.com/kudzeri/wear-shop-api/blob/main/app/Services/SdekService.php"
    click SwaggerDocs "https://github.com/kudzeri/wear-shop-api/blob/main/config/l5-swagger.php"
    click DeveloperTools "https://github.com/kudzeri/wear-shop-api/tree/main/Dockerfile"
    click DeveloperTools "https://github.com/kudzeri/wear-shop-api/blob/main/composer.json"
    click DeveloperTools "https://github.com/kudzeri/wear-shop-api/tree/main/storage/api-docs/"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef api fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef service fill:#FFFF99,stroke:#000,stroke-width:1px;
    classDef integrations fill:#DDA0DD,stroke:#000,stroke-width:1px,stroke-dasharray: 5,5;
    classDef models fill:#FFB6C1,stroke:#000,stroke-width:1px;
    classDef admin fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef docs fill:#D3D3D3,stroke:#000,stroke-width:1px;
```
