# pdanielfg/tfg-wallamotop architecture

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

- Interactive diagram: https://gitdiagram.com/pdanielfg/tfg-wallamotop
- Repository: https://github.com/pdanielfg/tfg-wallamotop

## Overview

##### Project type and purpose
- Wallamotop is a monolithic, full-stack web application offering second-hand motorcycle auctions.
- Backend: Laravel (PHP MVC framework).
- Frontend: Blade templates + Tailwind, Bootstrap, custom CSS/JS.
- Deployed via Docker on an AWS VM, using Docker Compose to orchestrate containers.

##### Key directories and their roles
- app/           → Laravel application code (Models, Controllers, Middleware).
- resources/     → Blade view templates (HTML + Tailwind/Bootstrap).
- public/        → Static assets (CSS, JS, images, entry point index.php).
- config/        → Laravel configuration (database, mail, cache, queue, services).
- database/      → Migrations, seeders, factories.
- routes/        → API/web routing definitions.
- storage/       → Logs, cache, file uploads.
- stripe/        → Payment secrets for Stripe integration.
- docker-compose.yml & Dockerfile → Container definitions: PHP-FPM, web server, database, cache, queue.

##### Main components
A. Clients (Web browsers/mobile)
B. Load Balancer (optional AWS ELB)
C. Docker network hosting:
1. Reverse Proxy / Web Server container (Nginx or Apache)
2. PHP-FPM container running Laravel
3. MySQL (or MariaDB) container for relational data
4. Redis container for caching, session storage, queues
5. Queue Worker container (Laravel Horizon / Artisan queue:work)
6. SMTP Mail Server (external or containerized)
7. Stripe Payment API (external service)
8. AWS EBS or local filesystem for uploads

##### Component relationships and data flows
- Clients → HTTP/HTTPS → Load Balancer → Nginx
- Nginx → passes PHP requests to PHP-FPM → Laravel routing → Controllers → Models → MySQL (CRUD)
- Laravel → writes cache/sessions/jobs to Redis
- Queue Worker → pulls jobs from Redis → sends emails via SMTP or processes long tasks
- Laravel → invokes Stripe API for payment processing (uses keys from stripe/secrets.php)
- Laravel → serves static assets directly from public/ (optionally via CDN)
- Uploads (moto images) → stored in storage/app/public → symlinked to public/storage

##### Architectural patterns and principles
- MVC (Model-View-Controller) in Laravel.
- Containerized micro-services via Docker Compose (not true microservices but isolated services).
- Asynchronous job queues for email verification, notifications, auction closing logic.
- Role-based access control (middleware guards Admin vs User).
- Real-time countdown relies on front-end JS polling or websockets (could be a future enhancement).

##### Detailed elements
- Clients → ELB (if used) → Nginx container
- Nginx → PHP-FPM → Laravel MVC
- Laravel → MySQL (Eloquent ORM)
- Laravel → Redis (cache/session/queue)
- Queue Worker → Redis → SMTP mail server
- Laravel → Stripe API (HTTPS)
- Public/storage mount for uploaded images
- Docker Compose YAML as orchestration layer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Tier
    subgraph "Presentation Tier"
        direction TB
        Client["Clients (Web/Mobile)"]:::external
        ELB["AWS ELB (optional)"]:::infra
    end

    %% Application Stack
    subgraph "Application Stack (Docker Network)"
        direction TB

        subgraph "Web Tier"
            direction TB
            Nginx["Nginx/Apache\nReverse Proxy"]:::web
            PHPFPM["PHP-FPM Container\nLaravel 10 (PHP 8.x)"]:::web
        end

        subgraph "Laravel App"
            direction TB
            Controllers["Controllers"]:::infra
            Models["Models"]:::infra
            Views["Blade Views"]:::infra
            RoutesWeb["routes/web.php"]:::infra
            RoutesAPI["routes/api.php"]:::infra
            ConfigDir["config/"]:::infra
            Migrations["database/migrations"]:::infra
            Seeders["database/seeders"]:::infra
            CacheConfig["config/cache.php"]:::infra
            QueueConfig["config/queue.php"]:::infra
            MailConfig["config/mail.php"]:::infra
            Middleware["Http Middleware"]:::infra
            ArtisanCLI["artisan & Console Kernel"]:::infra
            Bootstrap["bootstrap/app.php & .env"]:::infra
            StripeSecrets["stripe/secrets.php"]:::infra
        end

        subgraph "Data Tier"
            direction TB
            MySQL["MySQL/MariaDB\n(8.x)"]:::data
            Redis["Redis\n(6.x)"]:::data
        end

        subgraph "Workers"
            direction TB
            QueueWorker["Queue Worker\n(artisan queue:work)"]:::web
        end

        subgraph "Integration Tier"
            direction TB
            SMTP["SMTP Mail Server"]:::integration
            StripeAPI["Stripe Payment API"]:::integration
        end

        Storage["Uploads Storage\n(storage/app/public)"]:::data
    end

    %% Connections
    Client -->|HTTP/HTTPS| ELB
    ELB -->|HTTP/HTTPS| Nginx
    Nginx -->|FastCGI| PHPFPM
    PHPFPM -->|"Eloquent ORM"| MySQL
    PHPFPM -->|"Redis (cache/session/queue)"| Redis
    PHPFPM -->|"HTTPS API"| StripeAPI
    PHPFPM -->|"Serves static"| Storage
    PHPFPM --> Controllers
    PHPFPM --> Models
    PHPFPM --> Views
    PHPFPM --> RoutesWeb
    PHPFPM --> RoutesAPI
    PHPFPM --> ConfigDir
    PHPFPM --> Migrations
    PHPFPM --> Seeders
    PHPFPM --> CacheConfig
    PHPFPM --> QueueConfig
    PHPFPM --> MailConfig
    PHPFPM --> Middleware
    PHPFPM --> ArtisanCLI
    PHPFPM --> Bootstrap
    PHPFPM --> StripeSecrets

    QueueWorker -->|"pulls jobs"| Redis
    QueueWorker -->|"sends emails"| SMTP

    %% Click Events
    click Controllers "https://github.com/pdanielfg/tfg-wallamotop/tree/master/app/app/Http/Controllers"
    click Models "https://github.com/pdanielfg/tfg-wallamotop/tree/master/app/app/Models"
    click Views "https://github.com/pdanielfg/tfg-wallamotop/tree/master/app/resources/views"
    click RoutesWeb "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/routes/web.php"
    click RoutesAPI "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/routes/api.php"
    click ConfigDir "https://github.com/pdanielfg/tfg-wallamotop/tree/master/app/config"
    click Migrations "https://github.com/pdanielfg/tfg-wallamotop/tree/master/app/database/migrations"
    click Seeders "https://github.com/pdanielfg/tfg-wallamotop/tree/master/app/database/seeders"
    click CacheConfig "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/config/cache.php"
    click QueueConfig "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/config/queue.php"
    click MailConfig "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/config/mail.php"
    click StripeSecrets "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/stripe/secrets.php"
    click SMTP "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/config/mail.php"
    click Storage "https://github.com/pdanielfg/tfg-wallamotop/tree/master/app/storage/app/public"
    click Nginx "https://github.com/pdanielfg/tfg-wallamotop/tree/master/Dockerfile"
    click PHPFPM "https://github.com/pdanielfg/tfg-wallamotop/tree/master/Dockerfile"
    click ELB "https://github.com/pdanielfg/tfg-wallamotop/blob/master/docker-compose.yml"
    click QueueWorker "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/entrypoint.sh"
    click ArtisanCLI "https://github.com/pdanielfg/tfg-wallamotop/tree/master/app/artisan"
    click ArtisanCLI "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/app/Console/Kernel.php"
    click Middleware "https://github.com/pdanielfg/tfg-wallamotop/tree/master/app/app/Http/Middleware"
    click Bootstrap "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/bootstrap/app.php"
    click Bootstrap "https://github.com/pdanielfg/tfg-wallamotop/blob/master/app/.env"

    %% Styles
    classDef web fill:#D0E7FF,stroke:#333,stroke-width:1px
    classDef data fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef integration fill:#FFE7C4,stroke:#333,stroke-width:1px
    classDef infra fill:#F0F0F0,stroke:#333,stroke-width:1px
    classDef external fill:#E2E2FF,stroke:#333,stroke-width:1px
```
