How guiilopes97/countries_and_capitals works
Project Type and Purpose
• This is a monolithic, full-stack web application built with Laravel 12.x.
• It implements an MVC quiz game (Countries & Capitals) that delivers pages via Blade, tracks answers in session or storage, and renders results.
File Structure
• Top-level directories:
• app/ (Controllers, View Components, Providers)
• resources/ (Blade views, CSS/JS assets)
• public/ (entry point index.php, compiled assets)
• config/, bootstrap/, storage/ (framework config, cache, sessions)
• No separate microservices—single codebase with MVC pattern.
• app/app_data.php is the in-memory data provider for questions.
• Sessions are file-based by default (storage/framework/sessions).
README
• Confirms MVC, Laravel Components, Bootstrap for UI.
• No external APIs or databases explicitly used—game history likely in session or could be persisted via Laravel’s database if configured.
Main Components
a. Client Browser (UI Layer)
• Blade templates + Bootstrap CSS/JS
• User actions (start game, answer question)
b. Web Server (Apache/Nginx)
• Serves public/index.php and static assets (public/assets)
c. Laravel Application Layer
• HTTP Kernel & Middleware
• Router (routes/web.php → MainController)
• Controllers (app/Http/Controllers/MainController.php)
• View Components (app/View/Components/*.php and Blade files)
• Service Providers (AppServiceProvider)
• app_data.php (question data provider)
d. Persistence Layer
• Session Store (file driver in storage/framework/sessions)
• (Optional) Database (if later enabled in config/database.php)
• File Storage (logs in storage/logs)
e. Static Asset Store
• CSS, JS, images served from public/assets & resources
Relationships & Data Flows
1. Client → Web Server: HTTP GET / POST requests
2. Web Server → Laravel front controller (public/index.php)
3. Kernel → Router → MainController
4. MainController reads app_data.php for questions, reads/writes session, applies business rules
5. Controller → Blade templating engine renders HTML (injects View Components)
6. Laravel response → Web Server → Browser
7. Browser loads CSS/JS/images directly from public/assets
8. On user interactions, repeat the cycle for form POSTs to /answer or /history endpoints
Architectural Patterns & Principles
• MVC separation: Controllers handle HTTP logic, Views (Blade + Components) handle presentation.
• Single Responsibility: each View Component (Answer, Question, MainLayout) encapsulates its HTML + data.
• Service Container & Providers for dependency injection and bootstrapping.