# jhpenag95/quickpoll architecture

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

- Interactive diagram: https://gitdiagram.com/jhpenag95/quickpoll
- Repository: https://github.com/jhpenag95/quickpoll

## Overview

##### Project Type and Purpose
- This is a monolithic, full-stack Laravel web application for creating, distributing, and reporting on surveys (encuestas).
- The file tree shows a typical Laravel MVC structure: controllers under app/Http/Controllers, Eloquent models under app/Models, Blade views under resources/views, public assets under public/, and database migrations for tables like encuestas, preguntas, respuesta_encuesta, reporte, and a WhatsApp integration table.

##### Main Components
a. Client Layer
- Web browser (renders HTML, CSS, JS)
- Frontend assets served from public/ (CSS, JS, images)
- Blade templates in resources/views
b. Web Server & Routing
- Apache/Nginx directs requests to public/index.php
- Laravel’s routing (routes/web.php) dispatches to controllers
c. Application Layer
- Controllers (app/Http/Controllers) implement HTTP endpoints: IndexController, LoginController, RegistroEmpresaController, encuestasController, PreguntasController, ReportesController, DashboardController, UserController
- Middleware (registered in app/Http/Kernel.php) for auth, session, CSRF
- Service Providers (app/Providers) boot services and bind dependencies
d. Domain & Data Layer
- Eloquent Models (app/Models): Encuestas, Preguntas, OpcionesRespuesta, RespuestaEncuesta, DetalleRespuesta, Reporte, IntegracionWhatsapp, User, registroEmpresa
- MySQL (or configured DB in config/database.php) with tables created by database/migrations
- Database seeds (database/seeders) for initial data
e. Infrastructure Services
- Cache and session storage (config/cache.php, config/session.php)
- Queue jobs (config/queue.php) for background tasks
- Mail (config/mail.php) and other external services (config/services.php)
- File storage (local, public) under storage/app and storage/app/public
- WhatsApp integration via a dedicated table and likely external API calls

##### Relationships and Data Flow
- Browser → HTTP request → Web server → public/index.php → Laravel Router → Controller action
- Controller uses Models to query/update DB → returns data to Controller → passes to Blade view or JSON response
- Blade view + assets → HTTP response → Browser
- Background jobs (queues) may run asynchronously for tasks like sending survey links via WhatsApp or email
- File uploads/downloads handled via Storage facade, pointing to storage/app/private or storage/app/public

##### Architectural Patterns and Principles
- MVC (Model–View–Controller) separation
- Eloquent ORM for data access and relationships
- Dependency Injection and Service Container (Service Providers)
- Configuration over convention via config/*.php and .env
- PSR-4 autoloading (composer.json)
- Asset bundling via Vite (vite.config.js)
- Database migrations for schema version control

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Web Browser"]:::http
    Assets["Frontend Assets"]:::http
    Templates["Blade Templates"]:::http

    %% Web Server
    WebServer["Nginx/Apache"]:::http
    Entry["public/index.php"]:::http

    %% App Layer
    subgraph "Laravel Application"
        Router["Laravel Router"]:::http
        Controllers["Controllers"]:::app
        Middleware["HTTP Kernel (Middleware)"]:::app
        Providers["Service Providers"]:::app
        Models["Eloquent Models"]:::app
        Migrations["Database Migrations"]:::app
        Seeders["Database Seeders"]:::app
    end

    %% Configuration
    Config["Application Configuration & .env"]:::config

    %% Data Stores
    DB[(MySQL Database)]:::db
    StoragePub[(Storage Public)]:::storage
    StoragePriv[(Storage Private)]:::storage

    %% Background & External
    QueueWorker["Queue Worker"]:::queue
    WhatsApp["WhatsApp API"]:::ext

    %% Flows
    Browser -->|"HTTP Request"| WebServer
    Assets -->|Served| Browser
    Templates -->|Rendered| Browser

    WebServer -->|forwards| Entry
    Entry -->|boots| Router
    Router -->|routes to| Controllers
    Controllers -->|uses| Middleware
    Controllers -->|calls| Providers
    Controllers -->|queries| Models
    Models -->|reads/writes| DB
    Controllers -->|stores files| StoragePriv
    Controllers -->|serves files| StoragePub

    QueueWorker -->|process jobs| Controllers
    QueueWorker -->|reads/writes| DB
    QueueWorker -->|"sends messages"| WhatsApp

    Config -->|configures| Entry
    Config -->|configures| QueueWorker

    %% Click Events
    click Assets "https://github.com/jhpenag95/quickpoll/tree/main/public/css/"
    click Assets "https://github.com/jhpenag95/quickpoll/tree/main/public/js/"
    click Templates "https://github.com/jhpenag95/quickpoll/tree/main/resources/views/"
    click Entry "https://github.com/jhpenag95/quickpoll/blob/main/public/index.php"
    click Router "https://github.com/jhpenag95/quickpoll/blob/main/routes/web.php"
    click Controllers "https://github.com/jhpenag95/quickpoll/tree/main/app/Http/Controllers/"
    click Middleware "https://github.com/jhpenag95/quickpoll/blob/main/app/Http/Kernel.php"
    click Providers "https://github.com/jhpenag95/quickpoll/tree/main/app/Providers/"
    click Models "https://github.com/jhpenag95/quickpoll/tree/main/app/Models/"
    click Migrations "https://github.com/jhpenag95/quickpoll/tree/main/database/migrations/"
    click Seeders "https://github.com/jhpenag95/quickpoll/tree/main/database/seeders/"
    click Config "https://github.com/jhpenag95/quickpoll/blob/main/config/app.php"
    click Config "https://github.com/jhpenag95/quickpoll/blob/main/config/database.php"
    click Config "https://github.com/jhpenag95/quickpoll/blob/main/.env.example"
    click StoragePriv "https://github.com/jhpenag95/quickpoll/tree/main/storage/app/private/"
    click StoragePub "https://github.com/jhpenag95/quickpoll/tree/main/storage/app/public/"
    click Config "https://github.com/jhpenag95/quickpoll/blob/main/config/cache.php"
    click Config "https://github.com/jhpenag95/quickpoll/blob/main/config/session.php"
    click Config "https://github.com/jhpenag95/quickpoll/blob/main/config/queue.php"
    click Config "https://github.com/jhpenag95/quickpoll/blob/main/config/mail.php"
    click Config "https://github.com/jhpenag95/quickpoll/blob/main/config/services.php"
    click Config "https://github.com/jhpenag95/quickpoll/blob/main/vite.config.js"
    click Config "https://github.com/jhpenag95/quickpoll/tree/main/tests/"

    %% Styles
    classDef http fill:#ADD8E6,stroke:#000
    classDef db fill:#90EE90,stroke:#000
    classDef queue fill:#FFD580,stroke:#000
    classDef ext fill:#E6E6FA,stroke:#000
    classDef storage fill:#FFFFE0,stroke:#000
    classDef config fill:#D3D3D3,stroke:#000
    classDef app fill:#FFFFFF,stroke:#000
```
