# jsnmrs/aggro architecture

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

- Interactive diagram: https://gitdiagram.com/jsnmrs/aggro
- Repository: https://github.com/jsnmrs/aggro

## Overview

The Aggro project is a full-stack web application built with the CodeIgniter 4 PHP framework. It powers BMXfeed – a BMX news aggregator and video discovery platform – and integrates with YouTube, Vimeo, and RSS feeds to collect and display BMX-related content. The project leverages a containerized development environment (Docksal), utilizes MySQL/MariaDB as the backend database, and uses Vanilla CSS with PostCSS for frontend styling.

##### Main Components
- Backend: The core of the application is built with PHP using the CodeIgniter 4 framework. The “app” directory contains controllers (e.g., Home.php, Aggro.php), models (e.g., AggroModels.php, NewsModels.php), configuration files (in app/Config), libraries, helpers, and views.
- Frontend: The “public” directory holds the static assets including the main index.php entry point, CSS files (with PostCSS processing), and other public resources.
- Database: Aggro uses MySQL/MariaDB, and the SQL dump (aggro-db.sql) outlines the structure. Database configuration is managed within CodeIgniter’s config (app/Config/Database.php) and via environment variables.
- External Services: Integration with YouTube and Vimeo APIs for video details, as well as SimplePie for RSS feed parsing.
- Docksal / Dev Environment: The project uses Docksal for local development. The “.docksal” directory contains commands, environment configuration (docksal.env and docksal.yml), and custom scripts to facilitate various tasks (e.g., testing, deployment, frontend build).
- Additional Components: CRON jobs (using .crontab) for scheduled tasks such as news feed updates, video checks, archiving, and cache clearing.

##### Establish Relationships and Interactions
- The Frontend (public/) requests data served by the PHP backend in response to user interactions.
- Controllers in the CodeIgniter framework process requests, interact with Models (app/Models) to fetch or update data from the MySQL/MariaDB database, and then hand off responses to Views (in app/Views) for rendering the UI.
- The backend communicates with external APIs (YouTube, Vimeo) to fetch video metadata and parse RSS feeds through SimplePie.
- Scheduled tasks executed from the system’s CRON (defined in .crontab) interact with the backend logic to maintain updated feeds, perform video checks, and manage the archive.
- Docksal orchestrates the containers needed for development and testing. Custom Docksal commands (e.g., fin test, fin deploy, fin frontend) encapsulate build, maintenance, and deployment processes.

##### Architectural Patterns and Technologies
- MVC Pattern: The directory structure (with separate folders for Controllers, Models, Views, Config, etc.) clearly reflects a Model-View-Controller architecture.
- Containerized Development: The use of Docksal ensures that developers run the application in a consistent containerized environment.
- CI/CD: GitHub workflows for automated deployment and testing indicate a continuous integration and deployment pipeline.
- Separation of Concerns: Different components (backend logic, frontend assets, database interaction, scheduling) are separated into distinct directories and configuration files, ensuring modularity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    FE["Frontend (public/)"]:::frontend

    %% Backend/Application Layer
    BE["Backend/Application Layer (app/) - CodeIgniter 4, PHP 8.2+"]:::backend

    %% Database Section
    DB["Database (MySQL/MariaDB)"]:::database
    DB_Config["Database Config (app/Config/Database.php)"]:::database

    %% External Services
    YT["YouTube API"]:::externalSub
    VM["Vimeo API"]:::externalSub
    RSS["RSS Parsing (SimplePie)"]:::externalSub

    %% Dev Environment and CI/CD
    DE["Dev Environment (Docksal)"]:::dev
    CI["CI/CD Pipelines (.github/workflows/)"]:::dev

    %% CRON jobs
    CRON["CRON Jobs (Scheduled Tasks) (.crontab)"]:::cron

    %% Relationships
    FE -->|"HTTPRequests"| BE
    BE -->|"DataQueries"| DB
    BE -->|"Uses"| DB_Config
    BE -->|"Calls"| YT
    BE -->|"Calls"| VM
    BE -->|"Parses"| RSS
    CRON -->|"Triggers"| BE
    DE -->|"Manages"| FE
    DE -->|"Manages"| BE
    CI ---|"AutomatedDeployTest"| DE

    %% Click Events
    click BE "https://github.com/jsnmrs/aggro/tree/main/app/"
    click FE "https://github.com/jsnmrs/aggro/tree/main/public/"
    click DB "https://github.com/jsnmrs/aggro/blob/main/aggro-db.sql"
    click DB_Config "https://github.com/jsnmrs/aggro/blob/main/app/Config/Database.php"
    click YT "https://github.com/jsnmrs/aggro/blob/main/app/Helpers/youtube_helper.php"
    click VM "https://github.com/jsnmrs/aggro/blob/main/app/Helpers/vimeo_helper.php"
    click DE "https://github.com/jsnmrs/aggro/tree/main/.docksal/"
    click CRON "https://github.com/jsnmrs/aggro/blob/main/.crontab"
    click CI "https://github.com/jsnmrs/aggro/tree/main/.github/workflows/"

    %% Styles
    classDef backend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef frontend fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#ABEBC6,stroke:#1D8348,stroke-width:2px;
    classDef externalSub fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef dev fill:#D2B4DE,stroke:#7D3C98,stroke-width:2px;
    classDef cron fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
