Welcome to the Hi.Events backend documentation. This directory contains comprehensive guides on the architecture, patterns, and best practices used throughout the backend codebase.
π¨ These docs are AI generated and are not 100% accurate. Always verify anything important by looking at the actual code.
Start here - High-level overview of the entire backend architecture.
Contents:
- Architectural layers (HTTP, Application, Domain, Infrastructure)
- Core components (Domain Objects, DTOs, Repositories, Events)
- Request flow and data flow
- Key design patterns
- Multi-tenancy architecture
- Best practices summary
Who should read: Everyone working on the backend
Deep dive into the DDD patterns used in Hi.Events.
Contents:
- Application Layer (Handlers)
- Domain Services Layer
- Data Transfer Objects (DTOs)
- Domain Objects (auto-generated)
- Enums and constants
- DTO flow patterns
- Transaction management
- Service composition
- Validation patterns
Who should read: Backend developers implementing new features
Complete database schema architecture and entity relationships.
Contents:
- Core entity hierarchy
- Multi-tenancy architecture
- All database entities (Account, Event, Order, Attendee, etc.)
- Entity relationships and diagrams
- Architectural patterns (soft deletes, JSONB, indexes)
- PostgreSQL-specific features
Who should read: Backend developers, database administrators
Guide to the repository pattern implementation.
Contents:
- Base repository interface (40+ methods)
- Creating new repositories
- Usage in handlers
- Best practices (favor base methods, eager loading)
- Common patterns (pagination, filters, bulk operations)
- Testing with mocks
Who should read: Backend developers working with data access
Event-driven architecture and asynchronous processing.
Contents:
- Application Events vs Infrastructure Events
- Event listeners
- Background jobs
- Event flow examples
- Retry strategies
- Transaction boundaries
- Queue separation
Who should read: Backend developers implementing workflows and integrations
HTTP layer patterns and API design.
Contents:
- BaseAction pattern
- Response methods
- Authorization patterns
- JSON API resources
- Routing patterns
- Request validation
- Exception handling
Who should read: Backend developers building API endpoints
- Read: Architecture Overview - Understand the layers
- Read: Domain-Driven Design - Understand DTOs, Handlers, Services
- Reference: Existing feature in
/promptsdirectory - Implement: Following the established patterns
- Create migration:
php artisan make:migration create_xxx_table - Run migration:
php artisan migrate - Generate domain objects:
php artisan generate-domain-objects - Create repository interface and implementation: See Repository Pattern
- Register repository: Add to
RepositoryServiceProvider - Update database docs: Reference Database Schema
- Create FormRequest: See API Patterns
- Create Action: Extend
BaseAction, see API Patterns - Create DTO: Extend
BaseDataObject, see DDD - Create Handler: See DDD
- Create Domain Service (if needed): See DDD
- Create JSON Resource: See API Patterns
- Add route:
routes/api.php
- Create Event: See Events and Jobs
- Create Job: See Events and Jobs
- Create Listener: See Events and Jobs
- Register (if needed): See Events and Jobs
# Backend (run in Docker container)
cd docker/development
docker compose -f docker-compose.dev.yml exec backend bash
# Generate domain objects
php artisan generate-domain-objects
# Run migrations
php artisan migrate
# Run unit tests
php artisan test --testsuite=Unit
# Run specific test
php artisan test --filter=TestNamebackend/
βββ app/
β βββ DomainObjects/ # Auto-generated domain objects
β β βββ Generated/ # Don't edit these
β β βββ Enums/ # General enums
β β βββ Status/ # Status enums
β βββ Events/ # Application events
β βββ Http/
β β βββ Actions/ # HTTP actions (controllers)
β β βββ Request/ # Form requests
β β βββ Resources/ # JSON API resources
β βββ Jobs/ # Background jobs
β βββ Listeners/ # Event listeners
β βββ Models/ # Eloquent models
β βββ Repository/
β β βββ Interfaces/ # Repository contracts
β β βββ Eloquent/ # Implementations
β βββ Services/
β βββ Application/ # Application handlers
β β βββ Handlers/ # Use case handlers
β βββ Domain/ # Domain services
β βββ Infrastructure/ # External services
βββ database/
β βββ migrations/ # Database migrations
βββ routes/
βββ api.php # API routes
- Domain-Driven Design: Clear separation between domain, application, and infrastructure
- Repository Pattern: All data access through interfaces
- DTO Pattern: Immutable data transfer between layers
- Event-Driven: Decoupled communication via events
- Type Safety: Strong typing with domain objects and DTOs
- Always extend
BaseDataObjectfor new DTOs (notBaseDTO) - Use domain object constants for field names
- Favor base repository methods over custom methods
- Extend
BaseActionfor all HTTP actions - Use enums for domain constants
- Follow PSR-12 coding standards
- Wrap all translatable strings in
__()helper - Create unit tests for new features
- Don't add comments unless absolutely necessary
- Refactor complex code instead of documenting it
- CLAUDE.md - Project guidelines for AI assistants
- Laravel Documentation
- Spatie Laravel Data
- PostgreSQL Documentation
When adding new features or making significant changes:
- Follow the patterns documented here
- Update relevant documentation if patterns change
- Add examples to
/promptsfor reference - Ensure tests pass:
php artisan test --testsuite=Unit
- Start with: Architecture Overview
- Look at examples:
/promptsdirectory contains feature documentation - Check CLAUDE.md: Project-specific guidelines and patterns
- Reference specific guides: Use the documentation index above
Last Updated: 2025-10-29
Documentation Version: 1.0