Skip to content

Commit e368bcd

Browse files
Merge pull request #178 from codante-io/add-claude-md-documentation
Add CLAUDE.md documentation for AI code assistance
2 parents d7a3b26 + 9ae7b23 commit e368bcd

2 files changed

Lines changed: 215 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
description: Comprehensive Laravel PHP Cursor Rules: Best Practices and Key Principles.
3+
globs:
4+
alwaysApply: false
5+
---
6+
You are an expert in Laravel, PHP, and related web development technologies.
7+
8+
Core Principles
9+
- Write concise, technical responses with accurate PHP/Laravel examples.
10+
- Prioritize SOLID principles for object-oriented programming and clean architecture.
11+
- Follow PHP and Laravel best practices, ensuring consistency and readability.
12+
- Design for scalability and maintainability, ensuring the system can grow with ease.
13+
- Prefer iteration and modularization over duplication to promote code reuse.
14+
- Use consistent and descriptive names for variables, methods, and classes to improve readability.
15+
16+
Dependencies
17+
- Composer for dependency management
18+
- PHP 8.3+
19+
- Laravel 11.0+
20+
21+
PHP and Laravel Standards
22+
- Leverage PHP 8.3+ features when appropriate (e.g., typed properties, match expressions).
23+
- Adhere to PSR-12 coding standards for consistent code style.
24+
- Always use strict typing: declare(strict_types=1);
25+
- Utilize Laravel's built-in features and helpers to maximize efficiency.
26+
- Follow Laravel's directory structure and file naming conventions.
27+
- Implement robust error handling and logging:
28+
> Use Laravel's exception handling and logging features.
29+
> Create custom exceptions when necessary.
30+
> Employ try-catch blocks for expected exceptions.
31+
- Use Laravel's validation features for form and request data.
32+
- Implement middleware for request filtering and modification.
33+
- Utilize Laravel's Eloquent ORM for database interactions.
34+
- Use Laravel's query builder for complex database operations.
35+
- Create and maintain proper database migrations and seeders.
36+
37+
38+
Laravel Best Practices
39+
- Use Eloquent ORM and Query Builder over raw SQL queries when possible
40+
- Implement Repository and Service patterns for better code organization and reusability
41+
- Utilize Laravel's built-in authentication and authorization features (Sanctum, Policies)
42+
- Leverage Laravel's caching mechanisms (Redis, Memcached) for improved performance
43+
- Use job queues and Laravel Horizon for handling long-running tasks and background processing
44+
- Implement comprehensive testing using PHPUnit and Laravel Dusk for unit, feature, and browser tests
45+
- Use API resources and versioning for building robust and maintainable APIs
46+
- Implement proper error handling and logging using Laravel's exception handler and logging facade
47+
- Utilize Laravel's validation features, including Form Requests, for data integrity
48+
- Implement database indexing and use Laravel's query optimization features for better performance
49+
- Use Laravel Telescope for debugging and performance monitoring in development
50+
- Leverage Laravel Nova or Filament for rapid admin panel development
51+
- Implement proper security measures, including CSRF protection, XSS prevention, and input sanitization
52+
53+
Code Architecture
54+
* Naming Conventions:
55+
- Use consistent naming conventions for folders, classes, and files.
56+
- Follow Laravel's conventions: singular for models, plural for controllers (e.g., User.php, UsersController.php).
57+
- Use PascalCase for class names, camelCase for method names, and snake_case for database columns.
58+
* Controller Design:
59+
- Controllers should be final classes to prevent inheritance.
60+
- Make controllers read-only (i.e., no property mutations).
61+
- Avoid injecting dependencies directly into controllers. Instead, use method injection or service classes.
62+
* Model Design:
63+
- Models should be final classes to ensure data integrity and prevent unexpected behavior from inheritance.
64+
* Services:
65+
- Create a Services folder within the app directory.
66+
- Organize services into model-specific services and other required services.
67+
- Service classes should be final and read-only.
68+
- Use services for complex business logic, keeping controllers thin.
69+
* Routing:
70+
- Maintain consistent and organized routes.
71+
- Create separate route files for each major model or feature area.
72+
- Group related routes together (e.g., all user-related routes in routes/user.php).
73+
* Type Declarations:
74+
- Always use explicit return type declarations for methods and functions.
75+
- Use appropriate PHP type hints for method parameters.
76+
- Leverage PHP 8.3+ features like union types and nullable types when necessary.
77+
* Data Type Consistency:
78+
- Be consistent and explicit with data type declarations throughout the codebase.
79+
- Use type hints for properties, method parameters, and return types.
80+
- Leverage PHP's strict typing to catch type-related errors early.
81+
* Error Handling:
82+
- Use Laravel's exception handling and logging features to handle exceptions.
83+
- Create custom exceptions when necessary.
84+
- Use try-catch blocks for expected exceptions.
85+
- Handle exceptions gracefully and return appropriate responses.
86+
87+
Key points
88+
- Follow Laravel’s MVC architecture for clear separation of business logic, data, and presentation layers.
89+
- Implement request validation using Form Requests to ensure secure and validated data inputs.
90+
- Use Laravel’s built-in authentication system, including Laravel Sanctum for API token management.
91+
- Ensure the REST API follows Laravel standards, using API Resources for structured and consistent responses.
92+
- Leverage task scheduling and event listeners to automate recurring tasks and decouple logic.
93+
- Implement database transactions using Laravel's database facade to ensure data consistency.
94+
- Use Eloquent ORM for database interactions, enforcing relationships and optimizing queries.
95+
- Implement API versioning for maintainability and backward compatibility.
96+
- Optimize performance with caching mechanisms like Redis and Memcached.
97+
- Ensure robust error handling and logging using Laravel’s exception handler and logging features.

CLAUDE.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is the Codante.io API backend, a Laravel-based educational platform that provides workshops, mini-projects, and learning tracks for programming education. The platform serves as a comprehensive learning management system with features including user management, challenges, certificates, subscriptions, and content delivery.
8+
9+
## Development Commands
10+
11+
### Essential Commands
12+
13+
- `php artisan serve` - Start development server
14+
- `php artisan test` - Run PHPUnit tests (configured for Feature tests in `tests/Feature/`)
15+
- `composer run pint` or `./vendor/bin/pint` - Run Laravel Pint code formatter (PSR-12 standards)
16+
- `php artisan migrate` - Run database migrations
17+
- `php artisan db:seed` - Run database seeders
18+
- `php artisan queue:work` - Process job queues
19+
- `php artisan cache:clear` - Clear application cache
20+
21+
### Build & Deploy
22+
23+
- `composer install` - Install PHP dependencies
24+
- `npm install` - Install Node.js dependencies (Puppeteer for browser automation)
25+
- Deployment managed via Deployer PHP (`deploy.php`) to production server
26+
27+
## Architecture Overview
28+
29+
### Core Structure
30+
31+
- **Laravel 10.x** with PHP 8.1+ requirement
32+
- **MVC Architecture** with clean separation of concerns
33+
- **API-First Design** with Sanctum authentication
34+
- **Multi-tenant Educational Platform** supporting workshops, challenges, and tracks
35+
36+
### Key Models & Domains
37+
38+
- **User Management**: Users, Instructors, Subscriptions, Plans
39+
- **Content Delivery**: Workshops, Challenges, Lessons, Tracks, TrackItems
40+
- **Community Features**: Comments, Reactions, Certificates
41+
- **Learning Progress**: ChallengeUser, WorkshopUser, lesson completion tracking
42+
- **Content Management**: BlogPosts, Tags, Testimonials
43+
44+
### Services Layer
45+
46+
Important service classes in `app/Services/`:
47+
48+
- `ChallengeRepository.php` - Challenge data operations
49+
- `Discord.php` - Discord integration and notifications
50+
- `ExpiredPlanService.php` - Subscription management
51+
- `VimeoThumbnailService.php` - Video content handling
52+
53+
### Authentication & Authorization
54+
55+
- **Laravel Sanctum** for API token management
56+
- **GitHub OAuth** integration via Laravel Socialite
57+
- **Role-based access** with admin and user permissions
58+
- **Backpack CRUD** for admin panel functionality
59+
60+
### Database Architecture
61+
62+
- **Polymorphic relationships** via `Trackable` interface for flexible content organization
63+
- **Pivot tables** for many-to-many relationships (ChallengeUser, WorkshopUser, etc.)
64+
- **Soft deletes** implemented on major entities
65+
- **MySQL database** with comprehensive migration system
66+
67+
### API Design
68+
69+
- **RESTful API** structure with resource controllers
70+
- **API Resources** for consistent JSON responses
71+
- **Request validation** using Form Requests
72+
- **Middleware-based** authentication and permission checks
73+
74+
## Development Guidelines
75+
76+
### Code Style
77+
78+
- Follow **PSR-12** coding standards (enforced by Laravel Pint)
79+
- Use **strict typing**: `declare(strict_types=1)`
80+
- Controllers and Models should be **final classes**
81+
- Prefer **dependency injection** and service classes over fat controllers
82+
83+
### Key Patterns
84+
85+
- **Repository pattern** for data access (see `ChallengeRepository`)
86+
- **Event-driven architecture** with Laravel Events/Listeners
87+
- **Observer pattern** for model lifecycle management
88+
- **Service classes** for complex business logic
89+
90+
### Testing
91+
92+
- PHPUnit configuration in `phpunit.xml`
93+
- Focus on **Feature tests** in `tests/Feature/`
94+
- Test database: `codante_test`
95+
- Current test coverage includes major controllers and services
96+
97+
### Third-Party Integrations
98+
99+
- **Backpack CRUD** for admin interface
100+
- **Pagarme** for payment processing (Brazilian market)
101+
- **GitHub API** for repository management
102+
- **Discord webhooks** for community notifications
103+
- **Vimeo** for video content
104+
- **Laravel Pulse** for application monitoring
105+
106+
### Package Management
107+
108+
- **Composer** for PHP dependencies
109+
- Key packages: Backpack, Sanctum, Socialite, Image Intervention, Spatie packages
110+
- **NPM** for Node.js dependencies (primarily Puppeteer)
111+
112+
## Important Notes
113+
114+
- This is a **Brazilian-focused platform** (Portuguese language in many areas)
115+
- **Educational domain** with specific requirements for progress tracking and certification
116+
- **Production deployment** uses Supervisor for queue management
117+
- **Horizon** may be used for queue monitoring (check for Redis configuration)
118+
- **Backup system** configured via Spatie Laravel Backup

0 commit comments

Comments
 (0)