How sergiovegam41/lego works
Project type and purpose
• This is a full-stack, component-based PHP web framework (“Lego Framework”) packaged as a modular application.
• Purpose: Enable developers to build reusable, self-contained UI components (PHP+CSS+JS) and assemble them into web apps, with built-in routing, auth, database, caching, and asset management.
High-level file-structure analysis
• Top-level “public/index.php”: HTTP entrypoint served by Nginx + PHP-FPM.
• Core/: Framework engine – bootstrap, routing discovery, controller base classes, DTOs, response, service abstractions.
• App/: Consumer’s application code – Controllers (Auth, API), Models, Utilities (Redis client).
• Views/: Component library – organized under Core/ (framework UI pieces) and App/ (application-specific components), each folder with .php, .css, .js.
• Routes/: API, Web, Views routing definitions.
• database/: Migration & seed scripts (PostgreSQL), plus migrations.json.
• Dockerfile & docker-compose.yml: Container definitions for PHP, Postgres, MongoDB, Redis, PgAdmin.
• assets/ & public/: Static assets (CSS/JS/images) served directly.
Core architectural patterns
• Component-based MVC/MVP hybrid: Controllers handle HTTP ➔ call Services/Models ➔ return data to Views (Components).
• Convention-over-configuration: auto-discovery of routes & components via folder structure and attributes.
• Layered services: Core services (routing, auth), App services (business logic), Utils (Redis), Data access (Models), and templated components (Views).
• Micro-frontend feel: each UI component is self-contained.
Main components & relationships
a. Client Layer
• Browser (HTML/CSS/JS) requests to Nginx (or Docker-NGINX).
b. Web Server & Runtime
• Nginx → PHP-FPM → public/index.php → Core/bootstrap
c. Routing Layer
• Core/Services/ApiRouteDiscovery reads Routes/*.php → dispatch to App/Controllers or Core/Controller
d. Controller Layer
• Controllers (App/Controllers/Auth, other controllers) orchestrate requests: validate via DTOs, call Services/Core/AuthServicesCore, Util/RedisClient.
e. Service/Model Layer
• Core models (ResponseDTO, StatusCodes), App models (User, UserSession), database access.
• Database adapters: PostgreSQL (primary), MongoDB (if used), Redis (session/cache).
f. View Component Layer
• Components under Views/Core and Views/App render HTML + include CSS/JS.
• Assets served from /assets or public directory.
g. External Services
• PostgreSQL container, MongoDB container, Redis container, PgAdmin for management.