# miguelcarmona00/inafinder architecture

> Architecture diagram of the GitHub repository miguelcarmona00/inafinder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/miguelcarmona00/inafinder
- Repository: https://github.com/miguelcarmona00/inafinder

## Overview

1. **What this repository is**
   - InaFinder is a PHP 8.2 MVC application, built without a framework, for searching Inazuma Eleven players and managing a transfer market.
   - The architecture is centered around a classic server-rendered web app with a MariaDB backend and a thin custom application layer.

2. **Runtime and deployment boundary**
   - The app runs in Docker, with a dedicated image under `inafinder/` and Compose files under `compose/inafinder/`.
   - Development uses a Compose override that bind-mounts the source code and exposes MariaDB on the host; production runs from the built image and keeps the database internal.
   - Apache is the web server layer inside the container, with `public/` as the web root.

3. **Request entrypoint**
   - HTTP requests land in `public/index.php`, which is the front controller.
   - `public/.htaccess` likely rewrites routes into that entrypoint, so the application uses clean URLs rather than direct PHP file access.
   - `bootstrap.php` initializes shared configuration and wiring, including environment loading from `.env`.

4. **Routing and application control flow**
   - `app/Core/Router.php` is the custom routing layer that maps URLs to controller actions.
   - `app/Controllers/BaseController.php` provides shared controller behavior, while the rest of the controllers implement feature-specific endpoints.
   - The main flow is: request -> router -> controller -> model/data access -> view rendering.

5. **Controller boundaries**
   - The controllers are organized by domain: `Jugadores`, `Entrenadores`, `Talentos`, `Tecnicas`, `Tiros`, `Regates`, `Paradas`, `Bloqueos`, plus `User` and `Default`.
   - `TecnicaCrudController` suggests a dedicated administrative flow for technique management that differs from normal browsing.
   - This indicates a split between public-facing browsing/search and admin-style CRUD operations.

6. **Domain/data model layer**
   - `app/Models/DBAbstractModel.php` is the shared database access base class.
   - Concrete models mirror the business domain: `Jugadores`, `Equipos`, `Entrenadores`, `Fichajes`, `Monederos`, `Usuarios`, `LoginIntentos`, `Talentos`, `Tecnicas`, `JugadoresTalentos`, and `JugadoresSupertecnicas`.
   - The model layer is where the app’s main relationships live: players, teams, skills, transfers, wallets/credits, and login security records.

7. **Database as a core subsystem**
   - MariaDB is the persistent system of record, seeded from `bds/inafinderprod.sql` on first startup.
   - The dump contains both schema and seed data, so the repository includes a reproducible initial dataset for development and testing.
   - The app’s database credentials are injected through container environment variables and `.env` files, not hardcoded in the codebase.

8. **View layer and server-rendered UI**
   - Views live in `app/views/` and are split by feature area, matching the controllers and models.
   - There are dedicated views for list/edit/create flows, plus higher-level pages like `index_view.php`, `login_view.php`, `mercado_view.php`, and `jugador_view.php`.
   - Shared UI fragments live in `app/views/partials/` for the navbar, block messages, and SweetAlert integration.

9. **Client-side behavior**
   - The frontend is mostly traditional server-rendered HTML with supplemental JavaScript in `public/js/`.
   - Scripts such as `mercado.js`, `monedero.js`, `reembolso.js`, `filtros.js`, `confirmDelete.js`, `csrf.js`, and `loginTimer.js` support form UX, filtering, security tokens, confirmation dialogs, and market interactions.
   - This means some user interactions are handled client-side, but the system remains primarily backend-driven.

10. **Assets and media storage**
   - Static assets are served from `public/css`, `public/js`, and `public/imgs`.
   - Uploaded images are organized under `public/imgs/uploads/` by entity type, such as jugadores, entrenadores, regates, tiros, paradas, bloqueos, escudos, and more.
   - That structure implies the app stores uploaded media on the filesystem rather than in the database.

11. **Security and session-related concerns**
   - `app/Core/Csrf.php` and `public/js/csrf.js` show CSRF protection as a first-class part of the app.
   - `LoginIntentos` indicates tracking for failed login attempts, and `loginTimer.js` suggests session or login timeout behavior.
   - `scripts/migrar_passwords.php` is a one-off maintenance script for password migration, separating operational data tasks from the runtime app.

12. **Architecture boundaries to show in a diagram**
   - One boundary is the container/runtime boundary: browser -> Apache/PHP app -> MariaDB.
   - Another is the application boundary: routing/controller/view layer vs. database-backed domain models.
   - A third is the filesystem boundary for uploads and static assets, which is important because media and CSS/JS are served directly from `public/`.

Main entry points: [`inafinder/app/Models/DBAbstractModel.php`](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Models/DBAbstractModel.php) (Domain models), [`inafinder/app/Core/Router.php`](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Core/Router.php) (Router), [`inafinder/app/views/index_view.php`](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/views/index_view.php) (Views), [`inafinder/public/index.php`](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/public/index.php) (Public webroot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime & deploy"]
  node_browser(("Browser<br/>client"))
  node_compose["Compose<br/>deployment<br/>[docker-compose.yml]"]
  node_image["PHP image<br/>container image"]
  node_apache["Apache<br/>web server<br/>[000-default.conf]"]
end

subgraph group_app["Application core"]
  node_public["Public webroot<br/>entrypoint<br/>[index.php]"]
  node_bootstrap["Bootstrap<br/>app init<br/>[bootstrap.php]"]
  node_router{{"Router<br/>routing<br/>[Router.php]"}}
  node_csrf{{"CSRF<br/>security<br/>[Csrf.php]"}}
  node_basectl["Base controller<br/>controller base<br/>[BaseController.php]"]
  node_browse["Browse controllers<br/>feature controllers"]
  node_admin["Admin controller<br/>crud controller"]
  node_auth["User controller<br/>auth controller<br/>[UserController.php]"]
  node_models["Domain models<br/>ORM-like models"]
  node_maintenance["Maintenance script<br/>one-off script"]
end

subgraph group_ui["Views & assets"]
  node_views["Views<br/>templates<br/>[index_view.php]"]
  node_partials["Partials<br/>shared templates<br/>[navbar.php]"]
  node_assets["Static assets<br/>frontend assets<br/>[mercado.js]"]
end

subgraph group_data["Data layer"]
  node_uploads[("Uploads<br/>filesystem media")]
  node_database[("MariaDB<br/>relational database<br/>[inafinderprod.sql]")]
  node_seed["SQL dump<br/>schema & seed<br/>[inafinderprod.sql]"]
end

node_browser -->|"runs via"| node_compose
node_compose -->|"builds"| node_image
node_image -->|"hosts"| node_apache
node_apache -->|"serves"| node_public
node_browser -->|"HTTP requests"| node_public
node_public -->|"initializes"| node_bootstrap
node_public -->|"dispatches to"| node_router
node_router -->|"instantiates"| node_basectl
node_router -->|"routes to"| node_browse
node_router -->|"routes to"| node_admin
node_router -->|"routes to"| node_auth
node_browse -->|"reads/writes"| node_models
node_admin -->|"reads/writes"| node_models
node_auth -->|"reads/writes"| node_models
node_browse -->|"renders"| node_views
node_admin -->|"renders"| node_views
node_auth -->|"renders"| node_views
node_views -->|"includes"| node_partials
node_views -->|"loads"| node_assets
node_assets -->|"supports"| node_csrf
node_models -->|"persists to"| node_database
node_database -->|"initialized by"| node_seed
node_models -->|"stores media in"| node_uploads
node_bootstrap -->|"wires"| node_csrf
node_maintenance -.->|"migrates"| node_models

click node_compose "https://github.com/miguelcarmona00/inafinder/blob/main/compose/inafinder/docker-compose.yml"
click node_image "https://github.com/miguelcarmona00/inafinder/tree/main/inafinder/Dockerfile"
click node_apache "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/docker/apache/000-default.conf"
click node_public "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/public/index.php"
click node_bootstrap "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/bootstrap.php"
click node_router "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Core/Router.php"
click node_csrf "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Core/Csrf.php"
click node_basectl "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Controllers/BaseController.php"
click node_browse "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Controllers/JugadoresController.php"
click node_admin "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Controllers/TecnicaCrudController.php"
click node_auth "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Controllers/UserController.php"
click node_models "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Models/DBAbstractModel.php"
click node_views "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/views/index_view.php"
click node_partials "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/views/partials/navbar.php"
click node_assets "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/public/js/mercado.js"
click node_uploads "https://github.com/miguelcarmona00/inafinder/tree/main/inafinder/public/imgs/uploads/jugadores"
click node_database "https://github.com/miguelcarmona00/inafinder/blob/main/bds/inafinderprod.sql"
click node_seed "https://github.com/miguelcarmona00/inafinder/blob/main/bds/inafinderprod.sql"
click node_maintenance "https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/scripts/migrar_passwords.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_compose,node_image,node_apache toneBlue
class node_public,node_bootstrap,node_router,node_csrf,node_basectl,node_browse,node_admin,node_auth,node_models,node_maintenance toneAmber
class node_views,node_partials,node_assets toneMint
class node_uploads,node_database,node_seed toneRose
```

## Components

### Runtime & deploy

Dockerized Apache/PHP application runtime and environment wiring.

- **Browser**: client · User-facing entry to the app.
- [Compose](https://github.com/miguelcarmona00/inafinder/blob/main/compose/inafinder/docker-compose.yml): deployment · Dev/prod container orchestration and environment overrides. · `compose/inafinder/docker-compose.yml`
- [PHP image](https://github.com/miguelcarmona00/inafinder/tree/main/inafinder/Dockerfile): container image · Built Apache/PHP runtime for the application. · `inafinder/Dockerfile`
- [Apache](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/docker/apache/000-default.conf): web server · HTTP server layer inside the container. · `inafinder/docker/apache/000-default.conf`

### Application core

Front controller, routing, controllers, models, and shared security/config.

- [Public webroot](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/public/index.php): entrypoint · Document root and route entry boundary. · `inafinder/public/index.php`
- [Bootstrap](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/bootstrap.php): app init · Shared configuration and environment wiring. · `inafinder/bootstrap.php`
- [Router](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Core/Router.php): routing · Maps URLs to controller actions. · `inafinder/app/Core/Router.php`
- [CSRF](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Core/Csrf.php): security · Cross-site request forgery protection. · `inafinder/app/Core/Csrf.php`
- [Base controller](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Controllers/BaseController.php): controller base · Shared controller behavior. · `inafinder/app/Controllers/BaseController.php`
- [Browse controllers](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Controllers/JugadoresController.php): feature controllers · Public domain controllers for players, skills, and match actions. · `inafinder/app/Controllers/JugadoresController.php`
- [Admin controller](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Controllers/TecnicaCrudController.php): crud controller · Dedicated management flow for technique CRUD. · `inafinder/app/Controllers/TecnicaCrudController.php`
- [User controller](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Controllers/UserController.php): auth controller · Login and user-related endpoints. · `inafinder/app/Controllers/UserController.php`
- [Domain models](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/Models/DBAbstractModel.php): ORM-like models · Database-backed domain objects for players, teams, transfers, wallets, and login records. · `inafinder/app/Models/DBAbstractModel.php`
- [Maintenance script](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/scripts/migrar_passwords.php): one-off script · Password migration utility outside the normal request flow. · `inafinder/scripts/migrar_passwords.php`

### Views & assets

Server-rendered templates, partials, and static client-side resources.

- [Views](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/views/index_view.php): templates · Server-rendered pages for listing, editing, login, and market flows. · `inafinder/app/views/index_view.php`
- [Partials](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/app/views/partials/navbar.php): shared templates · Reusable UI fragments such as navbar, blocks, and alerts. · `inafinder/app/views/partials/navbar.php`
- [Static assets](https://github.com/miguelcarmona00/inafinder/blob/main/inafinder/public/js/mercado.js): frontend assets · CSS, JavaScript, and direct-served browser resources. · `inafinder/public/js/mercado.js`

### Data layer

Database schema, seed data, and upload storage.

- [Uploads](https://github.com/miguelcarmona00/inafinder/tree/main/inafinder/public/imgs/uploads/jugadores): filesystem media · Filesystem storage for entity images and other uploaded media. · `inafinder/public/imgs/uploads/jugadores`
- [MariaDB](https://github.com/miguelcarmona00/inafinder/blob/main/bds/inafinderprod.sql): relational database · Persistent system of record seeded from SQL dump. · `bds/inafinderprod.sql`
- [SQL dump](https://github.com/miguelcarmona00/inafinder/blob/main/bds/inafinderprod.sql): schema & seed · Initial schema and seed dataset. · `bds/inafinderprod.sql`

## Connections

- Browser → Compose: runs via · Development and production deployment are containerized.
- Compose → PHP image: builds · Compose uses the custom PHP/Apache image.
- PHP image → Apache: hosts · Apache serves the application inside the container.
- Apache → Public webroot: serves · Document root points at the public web entrypoint.
- Browser → Public webroot: HTTP requests · All web traffic lands in the front controller.
- Public webroot → Bootstrap: initializes · Shared config and environment are loaded before dispatch.
- Public webroot → Router: dispatches to · Front controller hands off request routing.
- Router → Base controller: instantiates · Controllers share common base behavior.
- Router → Browse controllers: routes to · Public browsing and search endpoints.
- Router → Admin controller: routes to · Administrative technique management endpoints.
- Router → User controller: routes to · Authentication and user endpoints.
- Browse controllers → Domain models: reads/writes · Controllers use domain models for database-backed actions.
- Admin controller → Domain models: reads/writes · CRUD flow persists through the model layer.
- User controller → Domain models: reads/writes · Login and user management interact with user and audit data.
- Browse controllers → Views: renders · Feature controllers return server-rendered pages.
- Admin controller → Views: renders · Admin forms and listings are template-driven.
- User controller → Views: renders · Login and account views are server-rendered.
- Views → Partials: includes · Common UI fragments are shared across pages.
- Views → Static assets: loads · Pages use CSS and JavaScript served from public/ .
- Static assets → CSRF: supports · Client-side CSRF handling complements server protection.
- Domain models → MariaDB: persists to · Domain state is stored in MariaDB.
- MariaDB → SQL dump: initialized by · Database starts from the repository SQL dump.
- Domain models → Uploads: stores media in · Uploaded entity images are filesystem-backed.
- Bootstrap → CSRF: wires · Security utilities are part of app initialization.
- Maintenance script → Domain models: migrates · One-off script operates on stored account data.
