Skip to content

Feature/identificador da feature - #17

Merged
p3drobitencourt merged 3 commits into
mainfrom
feature/identificador-da-feature
Jun 2, 2026
Merged

Feature/identificador da feature#17
p3drobitencourt merged 3 commits into
mainfrom
feature/identificador-da-feature

Conversation

@p3drobitencourt

@p3drobitencourt p3drobitencourt commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Atualização da documentação e docker

Summary by CodeRabbit

  • New Features

    • Implemented fully functional betting platform with wallet management and real-time balance tracking
    • Added role-based authentication system with admin and client profiles
    • Created admin dashboard with statistics, match management, and game settlement features
    • Implemented match liquidation workflow for processing game results and payouts
    • Added user registration with automatic client account creation
  • Refactor

    • Migrated application from mock data to live database with Entity-Model architecture
    • Reorganized routes with explicit authentication filters for admin and client roles
    • Replaced legacy procedural code with service-based business logic layer
  • Documentation

    • Updated setup instructions with Docker Compose and environment variable configuration

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b6749f22-e7ec-4e6b-a6b8-0c4da8967929

📥 Commits

Reviewing files that changed from the base of the PR and between df3941a and d779169.

⛔ Files ignored due to path filters (1)
  • writable/image.png is excluded by !**/*.png
📒 Files selected for processing (93)
  • .env
  • Dockerfile
  • README.md
  • app/Config/Database.php
  • app/Config/Routes.php
  • app/Controllers/AdminController.php
  • app/Controllers/AuthController.php
  • app/Controllers/BaseController.php
  • app/Controllers/CampeonatoController.php
  • app/Controllers/ClienteController.php
  • app/Controllers/JogoController.php
  • app/Controllers/LiquidacaoController.php
  • app/Controllers/TimeController.php
  • app/Controllers/UsuarioController.php
  • app/Database/Migrations/2026-05-22-000001_AddJogoLiquidacaoFields.php
  • app/Database/Seeds/AdminSeeder.php
  • app/Entities/Aposta.php
  • app/Entities/Campeonato.php
  • app/Entities/Cliente.php
  • app/Entities/Jogo.php
  • app/Entities/Time.php
  • app/Entities/Usuario.php
  • app/Filters/AdminFilter.php
  • app/Filters/AuthFilter.php
  • app/Filters/ClienteFilter.php
  • app/Filters/GuestFilter.php
  • app/Models/ApostaModel.php
  • app/Models/CampeonatoModel.php
  • app/Models/ClienteModel.php
  • app/Models/JogoModel.php
  • app/Models/ResolucaoModel.php
  • app/Models/TimeModel.php
  • app/Models/UsuarioModel.php
  • app/Services/ApostaService.php
  • app/Services/AuthService.php
  • app/Views/admin/campeonatos/form.php
  • app/Views/admin/campeonatos/index.php
  • app/Views/admin/dashboard.php
  • app/Views/admin/jogos/form.php
  • app/Views/admin/jogos/index.php
  • app/Views/admin/liquidacao/debug.php
  • app/Views/admin/liquidacao/index.php
  • app/Views/admin/times/form.php
  • app/Views/admin/times/index.php
  • app/Views/admin/usuarios/form.php
  • app/Views/admin/usuarios/index.php
  • app/Views/auth/cadastro.php
  • app/Views/auth/login.php
  • app/Views/cliente/adicionar_saldo.php
  • app/Views/cliente/dashboard.php
  • app/Views/layouts/master.php
  • backup_old_system/public/apostar.php
  • backup_old_system/public/cadastro.php
  • backup_old_system/public/campeonatos.php
  • backup_old_system/public/index_old.php
  • backup_old_system/public/jogos.php
  • backup_old_system/public/login.php
  • backup_old_system/public/resolver.php
  • backup_old_system/public/times.php
  • backup_old_system/public/usuarios.php
  • backup_old_system/src/Application/Controllers/ApostaController.php
  • backup_old_system/src/Application/Controllers/AuthController.php
  • backup_old_system/src/Application/Controllers/CampeonatoController.php
  • backup_old_system/src/Application/Controllers/ClienteController.php
  • backup_old_system/src/Application/Controllers/JogoController.php
  • backup_old_system/src/Application/Controllers/ResolucaoController.php
  • backup_old_system/src/Application/Controllers/TimeController.php
  • backup_old_system/src/Application/Controllers/UsuarioController.php
  • backup_old_system/src/Application/Services/CampeonatoService.php
  • backup_old_system/src/Application/Services/DashboardService.php
  • backup_old_system/src/Application/Services/JogoService.php
  • backup_old_system/src/Application/Services/TimeService.php
  • backup_old_system/src/Application/Services/UsuarioService.php
  • backup_old_system/src/Infrastructure/Database/DatabaseConnector.php
  • backup_old_system/src/Infrastructure/Repositories/ApostaRepository.php
  • backup_old_system/src/Infrastructure/Repositories/CampeonatoRepository.php
  • backup_old_system/src/Infrastructure/Repositories/ClienteApostaRepository.php
  • backup_old_system/src/Infrastructure/Repositories/JogoRepository.php
  • backup_old_system/src/Infrastructure/Repositories/ResolucaoRepository.php
  • backup_old_system/src/Infrastructure/Repositories/TimeRepository.php
  • backup_old_system/src/Infrastructure/Repositories/UsuarioRepository.php
  • backup_old_system/views/admin/campeonatos/form.phtml
  • backup_old_system/views/admin/campeonatos/index.phtml
  • backup_old_system/views/admin/jogos/form.phtml
  • backup_old_system/views/admin/jogos/index.phtml
  • backup_old_system/views/admin/resolucao.phtml
  • backup_old_system/views/admin/times/form.phtml
  • backup_old_system/views/admin/times/index.phtml
  • backup_old_system/views/admin/usuarios/form.phtml
  • backup_old_system/views/admin/usuarios/index.phtml
  • backup_old_system/views/cliente/sportsbook.phtml
  • compose.yaml
  • database/schema.sql

📝 Walkthrough

Walkthrough

This PR migrates a PHP betting platform from a legacy procedural architecture to CodeIgniter 4's modern MVC framework. It introduces typed entities with casting, database models with transactional operations, service-layer business logic, refactored controllers with real database backing, Blade view templates with role-based rendering, and removes the entire legacy codebase. The application now manages championships, teams, games, users (admin and client profiles), bets with odds, wallet balances, and game liquidation workflows through a cohesive CI4 architecture.

Changes

Betting Platform CodeIgniter 4 Refactor

Layer / File(s) Summary
Infrastructure and Configuration
\.env, Dockerfile, compose\.yaml, app/Config/Database\.php, app/Database/Migrations/*, database/schema\.sql
Environment variables and MySQL credentials configured; Dockerfile includes mysqli PHP extension; Docker Compose wires services to shared network using parameterized environment variables; database configuration loads credentials from environment; new migration adds status and resultado_final columns to jogo table; schema adds cancelada status to aposta and seeds initial test data.
Entity Definitions
app/Entities/Aposta\.php, app/Entities/Campeonato\.php, app/Entities/Cliente\.php, app/Entities/Jogo\.php, app/Entities/Time\.php, app/Entities/Usuario\.php
Six new entity classes with attribute casting (integers, floats, dates), helper methods for balance checks and formatting (BRL currency), password hashing, profile checks, and computed getters for bet details and status rendering.
Database Models
app/Models/ApostaModel\.php, app/Models/CampeonatoModel\.php, app/Models/ClienteModel\.php, app/Models/JogoModel\.php, app/Models/ResolucaoModel\.php, app/Models/TimeModel\.php, app/Models/UsuarioModel\.php
Seven models with validation rules; query methods for filtering, joining, and paginating records; transaction-wrapped persistence for wallet debit/credit and bet lifecycle; pessimistic locking (FOR UPDATE) for concurrent balance updates; liquidation workflow processing with winner/loser bet status updates; AdminSeeder creates bootstrap admin user from environment variables.
Service Layer
app/Services/AuthService\.php, app/Services/ApostaService\.php
Authentication service validates credentials and creates users with optional cliente wallet initialization via transaction; betting service composes dashboard data, validates and registers bets, handles bet updates and cancellations, maps bet types to odds from game records.
Routes and Filters
app/Config/Routes\.php, app/Filters/AdminFilter\.php, app/Filters/AuthFilter\.php, app/Filters/ClienteFilter\.php, app/Filters/GuestFilter\.php
Auto-routing disabled; explicit cliente and admin route groups with filter guards; filters use flexible session key fallbacks (logado/logged_in, perfil/usuario_perfil) and normalize profile to lowercase; redirects route non-admin users to /cliente/dashboard instead of sportsbook; guest filter redirects already-logged-in users based on profile.
Controllers with Database Backing
app/Controllers/AdminController\.php, app/Controllers/AuthController\.php, app/Controllers/BaseController\.php, app/Controllers/CampeonatoController\.php, app/Controllers/ClienteController\.php, app/Controllers/JogoController\.php, app/Controllers/LiquidacaoController\.php, app/Controllers/TimeController\.php, app/Controllers/UsuarioController\.php
All controllers refactored to query models instead of using mock data; AuthController delegates to AuthService and bootstraps admin on first login; ClienteController uses ApostaService for betting and ClienteModel for wallet top-ups; CRUD controllers validate input, check record existence, handle exceptions with logging, use try/catch for error reporting; new LiquidacaoController processes game results and credits winners; BaseController adds helpers (isAdmin, isCliente, getClienteSaldo) and flexible session profile handling.
View Layer and Templates
app/Views/layouts/master\.php, app/Views/admin/dashboard\.php, app/Views/admin/campeonatos/form\.php, app/Views/admin/campeonatos/index\.php, app/Views/admin/jogos/*, app/Views/admin/liquidacao/index\.php, app/Views/admin/liquidacao/debug\.php, app/Views/admin/times/*, app/Views/admin/usuarios/*, app/Views/auth/cadastro\.php, app/Views/auth/login\.php, app/Views/cliente/dashboard\.php, app/Views/cliente/adicionar_saldo\.php
Master layout updated to use flexible session role fallbacks and normalize profile; admin dashboard redesigned with metric cards, CRUD shortcuts, and recent records from database queries; all admin CRUD forms add hidden _method=PUT for updates and use csrf_field(); admin-only action links (Novo, edit, delete forms) conditional on logged-in user role; client dashboard renders active games, betting form, bet history with status badges, wallet balance with top-up form; login page notes that public registration creates clients only; registration form locked to cliente profile with hidden field; liquidation index and debug views render pending games and related bets with transaction details.
Legacy Code Removal
backup_old_system/public/*, backup_old_system/src/Application/Controllers/*, backup_old_system/src/Application/Services/*, backup_old_system/src/Infrastructure/Database/*, backup_old_system/src/Infrastructure/Repositories/*, backup_old_system/views/*
All procedural PHP entrypoints (apostar.php, cadastro.php, campeonatos.php, index_old.php, jogos.php, login.php, resolver.php, times.php, usuarios.php), controllers with handleRequest() routing, repository-based data access, and old PHTML views are removed, replaced entirely by CodeIgniter 4 framework structure.
Documentation
README\.md
Updated with new Docker Compose workflow, environment variable setup, AdminSeeder invocation, localhost access instructions, and test scenarios covering admin panel CRUD, client login, bet placement, and balance updates.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

This PR involves substantial architectural changes across multiple layers: new entity definitions, seven database models with complex queries and transactions, two business services, refactored controllers with real database integration, Blade template updates with role-based conditionals, and wholesale removal of legacy code. The changes are heterogeneous—each controller and model serves a different domain entity—requiring separate reasoning for session handling, transaction flows, validation rules, and UI rendering. The mix of infrastructure setup, model-layer logic density, transaction semantics, and view-layer conditionals demands careful review to verify data consistency, session security, and bet liquidation correctness.

Possibly related PRs

  • p3drobitencourt/pimbastic_esports#16: Both PRs implement the same core CodeIgniter 4 refactor with overlapping entity, model, service, and controller changes for the betting platform.

Suggested reviewers

  • EnrLobo
  • kkjaokk

🐰 A rabbit hops through code with glee,
Old PHP scripts now wild and free,
CodeIgniter's frame, a home so neat,
Bets and wallets, liquidation complete!
Models, services, entities divine—
The refactor shines, line after line.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/identificador-da-feature

@p3drobitencourt
p3drobitencourt merged commit 54ef1ec into main Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant