# davidbonfill/docplanner-task architecture

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

- Interactive diagram: https://gitdiagram.com/davidbonfill/docplanner-task
- Repository: https://github.com/davidbonfill/docplanner-task

## Overview

##### Project Type & Purpose
- This is a Laravel-based web application with both API and a basic frontend UI layer. It is built following TDD principles using PestPHP.
- It leverages Docker containers for both development and production environments, with a dedicated MySQL service. The project also integrates continuous integration through GitHub Actions.
- Additionally, API documentation is generated using Scribe, making the architecture supportive of both interactive UI and RESTful endpoints.

##### Main Components
a. Docker & Deployment Environment:
- Docker Compose configuration and Dockerfile.
- Persistent volume (_db_volume_data) ensuring MySQL data persistence.
b. Laravel Application Backend:
- Core application logic in the “app” directory, including sub-components:
⁃ Controllers (API endpoints and UI controller)
⁃ Models and Eloquent ORM setup (Task, User, etc.)
⁃ Services & Repositories layers implementing business logic and DB access.
⁃ Policies, Requests, and Resources supporting authorization, validation, and API responses.
- Configuration management (config directory) and bootstrap initialization.
c. Database:
- MySQL database managed by Docker and schema migrations & SQL scripts (from the schema/ directory).
d. API Documentation & Frontend:
- API documentation generated via Scribe (files in .scribe and views in resources/views/scribe).
- Public views/UI (resources/views/ui.blade.php and public assets) that consume API endpoints.
e. Testing and Quality:
- Unit and Feature tests (tests directory) running via PestPHP.
- Static analysis tools like Larastan and Laravel Pint integrated via CI/CD pipelines.
f. CI/CD Pipeline:
- GitHub Actions workflows (.github/workflows/) which run tests and code quality checks automatically on push.

##### Relationships & Interactions
- The Laravel application (core backend) receives HTTP requests through routes (routes/api.php and routes/web.php) and dispatches them to controllers.
- Controllers invoke services which in turn interact with the repositories to handle data, which is stored or retrieved from the MySQL database.
- The Docker container provides an isolated runtime environment for the Laravel app (with PHP) and a separate container for MySQL.
- Static analysis tools and tests run in the CI/CD pipeline to enforce code quality before deployments.
- Scribe generates API documentation by introspecting API endpoints and is exposed to the users via a separate route (/docs).

##### Architectural Patterns and Design Principles
- Layered (N-tier) architecture: A clear separation between controllers, services, and repositories.
- Test-Driven Development (TDD) is central, as seen in the tests directory.
- Use of environment isolation via Docker.
- CI/CD pipeline enforces quality gates (style checks, static analysis, tests).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    U["User Browser"]:::user

    %% Docker Environment
    subgraph "Docker Environment"
        D1["Docker Compose"]:::infra
        D2["Dockerfile"]:::infra
        D3["MySQL Container"]:::db
        D4["Persistent Volume"]:::infra
    end

    %% Laravel Application
    subgraph "Laravel Application"
        L7["Routes"]:::app
        L1["Controllers"]:::app
        L2["Services"]:::app
        L3["Repositories"]:::app
        L4["Models"]:::app
        L5["Policies/Requests/Resources"]:::app
        L6["Configuration & Bootstrap"]:::app
    end

    %% API Documentation & Frontend
    subgraph "API Documentation & Frontend"
        F1["API Documentation (Scribe)"]:::doc
        F2["Scribe Views"]:::doc
        F3["UI Layer"]:::doc
        F4["Public Assets"]:::doc
    end

    %% CI/CD Pipeline & Testing
    subgraph "CI/CD Pipeline & Testing"
        C1["GitHub Actions"]:::cicd
        C2["Tests (PestPHP)"]:::cicd
        C3["Static Analysis"]:::cicd
    end

    %% Connections
    U -->|"accesses"| F3
    U -->|"accesses"| F1

    U -->|"sends_request"| L7
    L7 -->|"routes_to"| L1
    L1 -->|"calls"| L2
    L2 -->|"invokes"| L3
    L3 -->|"queries"| D3

    C1 -->|"deploys_via"| D1
    C2 -->|"checks"| L1
    C3 -->|"analyzes"| L1

    %% Styles
    classDef infra fill:#f9e79f,stroke:#f39c12,stroke-width:2px;
    classDef db fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef app fill:#d6eaf8,stroke:#3498db,stroke-width:2px;
    classDef doc fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef cicd fill:#f5cba7,stroke:#e67e22,stroke-width:2px;
    classDef user fill:#f7dc6f,stroke:#f1c40f,stroke-width:2px;

    %% Click Events
    click D1 "https://github.com/davidbonfill/docplanner-task/blob/main/docker-compose.yml"
    click D2 "https://github.com/davidbonfill/docplanner-task/tree/main/Dockerfile"
    click D4 "https://github.com/davidbonfill/docplanner-task/tree/main/_db_volume_data"
    click L1 "https://github.com/davidbonfill/docplanner-task/tree/main/app/Http/Controllers"
    click L4 "https://github.com/davidbonfill/docplanner-task/tree/main/app/Models"
    click L2 "https://github.com/davidbonfill/docplanner-task/blob/main/app/Services/TaskService.php"
    click L3 "https://github.com/davidbonfill/docplanner-task/blob/main/app/Repositories/TaskRepository.php"
    click L5 "https://github.com/davidbonfill/docplanner-task/blob/main/app/Policies/TaskPolicy.php"
    click L6 "https://github.com/davidbonfill/docplanner-task/tree/main/config"
    click L7 "https://github.com/davidbonfill/docplanner-task/blob/main/routes/api.php"
    click F1 "https://github.com/davidbonfill/docplanner-task/blob/main/.scribe"
    click F2 "https://github.com/davidbonfill/docplanner-task/blob/main/resources/views/scribe/index.blade.php"
    click F3 "https://github.com/davidbonfill/docplanner-task/blob/main/resources/views/ui.blade.php"
    click F4 "https://github.com/davidbonfill/docplanner-task/tree/main/public"
    click C1 "https://github.com/davidbonfill/docplanner-task/blob/main/.github/workflows/laravel.yml"
    click C2 "https://github.com/davidbonfill/docplanner-task/tree/main/tests"
    click C3 "https://github.com/davidbonfill/docplanner-task/blob/main/phpstan.neon"
```
