# tarrekosama/pc-builder-serverside architecture

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

- Interactive diagram: https://gitdiagram.com/tarrekosama/pc-builder-serverside
- Repository: https://github.com/tarrekosama/pc-builder-serverside

## Overview

##### Project type and purpose
- This is a full-stack e-commerce web application (“PC Builder”) with:
– An Angular SPA frontend serving the UI and invoking RESTful endpoints
– A Laravel backend exposing an API, handling business logic, data access, authentication, and admin operations
– A MySQL database for persistent storage
– Integration with external payment providers (Stripe, PayPal)

##### File structure
- Top-level folders:
– app/Http/Controllers/API: REST controllers (MotherboardController, PsuController, etc.)
– app/Models: Eloquent models representing Users, Orders, Components, Builds, Reviews, Notifications, etc.
– routes/api.php & routes/web.php: define API endpoints vs. any server-side rendered pages
– resources/js & resources/css: assets for the frontend (if Angular code sits here or in a separate frontend/ folder)
– database/migrations & seeders: DB schema definitions and sample data loaders
– config/ & bootstrap/: framework configuration and bootstrapping
– public/index.php: entry point for HTTP requests
– vendor/ & composer.json: PHP dependencies
– package.json, vite.config.js, tailwind.config.js: Node build and asset tooling

##### README for additional insights
- Frontend: Angular (likely in a separate frontend/ folder or integrated via resources/)
- Backend: Laravel 9+, Sanctum for API auth, uses Stripe/PayPal SDKs
- Features: real-time compatibility checks, shopping cart, guest checkout, order tracking, admin dashboards

a. Main components
– Browser (Angular SPA)
– Web server (Nginx/Apache)
– API layer (Laravel controllers + request validation)
– Business logic layer (Services, FormRequests, Resource transformers)
– Data access layer (Eloquent models, Repositories)
– Relational database (MySQL)
– External payment gateways (Stripe, PayPal)
– Optional: Queue worker for sending notifications, processing long-running tasks
– Admin console (part of Angular or Laravel Blade)
– File storage (local or S3 for uploads)
b. Relationships and interactions
– Users → Angular UI → HTTP(S) → Web server → Laravel’s public/index.php → Router → Controller → Service → Model → MySQL
– Checkout flow: Controller invokes payment SDK → Webhook listeners → Update Order status → Notification job queued
– Admin → Authenticated API calls → Inventory/Order management endpoints
– Real-time compatibility: Angular polls or WebSocket (if implemented) to API → Controller runs compatibility logic → returns suggestions
c. Architectural patterns & design principles
– RESTful API separation between UI and backend
– MVC pattern within Laravel (Controllers, Models, Views/Resources)
– Form request validation (app/Http/Requests) for strong typing
– Database migrations and seeders for reproducible schema
– Queues (config/queue.php) for async tasks
– Use of environment config (.env) for secrets
d. Key technologies
– Laravel, PHP 8+, Composer
– Angular, TypeScript, Node/NPM
– MySQL, Eloquent ORM
– Stripe & PayPal SDKs
– Tailwind CSS / PostCSS / Vite for asset bundling
– Laravel Sanctum for API authentication

##### Diagramming conventions
- Components:
- Data flow:
– UI vs. API vs. Data vs. External
- Labels:
– Name each component clearly (e.g., “Angular SPA,” “API: MotherboardController,” “MySQL: builds table”)
– Annotate key interactions (e.g., “Validate compatibility,” “Charge via Stripe,” “Seed initial data”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Angular SPA Frontend" 
        direction TB
        A1["package.json"]:::frontend
        A2["vite.config.js"]:::frontend
        A3["postcss.config.js"]:::frontend
        A4["tailwind.config.js"]:::frontend
        A5["resources/js/app.js"]:::frontend
        A6["resources/css/app.css"]:::frontend
    end

    %% Web Server Layer
    subgraph "Web Server" 
        direction TB
        WS1["public/index.php"]:::backend
        WS2["public/.htaccess"]:::backend
    end

    %% API Layer
    subgraph "Laravel API Layer" 
        direction TB
        R1["routes/api.php"]:::backend
        R2["routes/web.php"]:::backend
        Controllers["app/Http/Controllers/API"]:::backend
        subgraph "Controllers"
            direction TB
            C1["MotherboardController"]:::backend
            C2["PsuController"]:::backend
        end
        subgraph "Form Requests"
            direction TB
            F1["MotherboardRequest"]:::backend
            F2["PsuRequest"]:::backend
        end
        subgraph "API Resources"
            direction TB
            AR1["MotherboardResource"]:::backend
            AR2["PsuResource"]:::backend
        end
        Providers["AppServiceProvider"]:::backend
        Models["app/Models"]:::backend
        Migrations["database/migrations"]:::data
        Seeders["database/seeders"]:::data
        QueueConfig["config/queue.php"]:::backend
        AuthConfig["config/auth.php"]:::backend
        SanctumConfig["config/sanctum.php"]:::backend
        ServicesConfig["config/services.php"]:::backend
        Bootstrap["bootstrap/app.php"]:::backend
        CLI["artisan"]:::backend
        Tests["tests"]:::backend
    end

    %% Persistence Layer
    MySQL["MySQL Database"]:::data

    %% External Services
    subgraph "External Payment Services" 
        direction TB
        Stripe["Stripe"]:::external
        PayPal["PayPal"]:::external
    end

    %% Data Flow
    A5 -->|"HTTP GET/POST"| WS1
    WS1 -->|"Bootstrap"| Bootstrap
    WS1 -->|"Route Request"| R1
    R1 -->|"Invoke Controller"| C1
    C1 -->|"Validate"| F1
    C1 -->|"Transform"| AR1
    C1 -->|"Service Logic"| Providers
    C1 -->|"Model Access"| Models
    Models -->|"SQL Query"| MySQL
    MySQL -->|"Result Set"| Models
    C1 -->|"Return JSON"| WS1
    WS1 -->|"HTTP Response"| A5

    %% Checkout Flow
    C2 -->|"Charge"| Stripe
    C2 -->|"Charge"| PayPal
    Stripe -->|"Webhook"| C2
    C2 -->|"Queue Job"| QueueConfig
    QueueConfig -->|"Order Update"| Models

    %% Admin & Compatibility
    A5 -->|"Auth API Calls"| R1
    C1 -->|"Compatibility Check"| Providers
    A5 -->|"Polling/WebSocket"| R1

    %% CI & Tests
    CLI -->|"Run Tests"| Tests

    %% Click Events
    click A1 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/package.json"
    click A2 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/vite.config.js"
    click A3 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/postcss.config.js"
    click A4 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/tailwind.config.js"
    click A5 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/resources/js/app.js"
    click A6 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/resources/css/app.css"
    click WS1 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/public/index.php"
    click WS2 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/public/.htaccess"
    click C1 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/app/Http/Controllers/API/MotherboardController.php"
    click C2 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/app/Http/Controllers/API/PsuController.php"
    click F1 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/app/Http/Requests/MotherboardRequest.php"
    click F2 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/app/Http/Requests/PsuRequest.php"
    click AR1 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/app/Http/Resources/MotherboardResource.php"
    click AR2 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/app/Http/Resources/PsuResource.php"
    click Providers "https://github.com/tarrekosama/pc-builder-serverside/blob/main/app/Providers/AppServiceProvider.php"
    click Models "https://github.com/tarrekosama/pc-builder-serverside/tree/main/app/Models"
    click R1 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/routes/api.php"
    click R2 "https://github.com/tarrekosama/pc-builder-serverside/blob/main/routes/web.php"
    click Migrations "https://github.com/tarrekosama/pc-builder-serverside/tree/main/database/migrations"
    click Seeders "https://github.com/tarrekosama/pc-builder-serverside/tree/main/database/seeders"
    click QueueConfig "https://github.com/tarrekosama/pc-builder-serverside/blob/main/config/queue.php"
    click AuthConfig "https://github.com/tarrekosama/pc-builder-serverside/blob/main/config/auth.php"
    click SanctumConfig "https://github.com/tarrekosama/pc-builder-serverside/blob/main/config/sanctum.php"
    click ServicesConfig "https://github.com/tarrekosama/pc-builder-serverside/blob/main/config/services.php"
    click Bootstrap "https://github.com/tarrekosama/pc-builder-serverside/blob/main/bootstrap/app.php"
    click CLI "https://github.com/tarrekosama/pc-builder-serverside/tree/main/artisan"
    click Tests "https://github.com/tarrekosama/pc-builder-serverside/tree/main/tests"

    %% Styles
    classDef frontend fill:#D0E7FF,stroke:#0096FF
    classDef backend fill:#DFF7E1,stroke:#28A745
    classDef data fill:#FFF4D6,stroke:#FFC107
    classDef external fill:#F5E1F7,stroke:#6610F2
```
