docs: update README files across layers to enhance clarity and consistency

- Added detailed guidelines for Markdown file formatting in CLAUDE.md.
- Improved README files in the Application, Domain, and Infrastructure layers to include additional context and examples.
- Ensured all README files follow a consistent structure and style for better readability.
- Updated documentation for Forum, Tracker, and User domains to reflect recent architectural changes.

These updates aim to provide clearer guidance for developers and maintainers, aligning with the project's focus on modern architecture and clean code practices.
This commit is contained in:
Yury Pikhtarev 2025-06-21 21:02:33 +04:00
commit 3fe99a1623
No known key found for this signature in database
49 changed files with 86 additions and 1 deletions

View file

@ -137,3 +137,23 @@ The TorrentPier 3.0 release represents a major architectural shift focused on:
- **Language system**: Update global $lang usage to new Language singleton methods - **Language system**: Update global $lang usage to new Language singleton methods
When working with this codebase, prioritize modern architecture patterns and clean code practices. Focus on the new systems in `/src/` directory rather than maintaining legacy compatibility. When working with this codebase, prioritize modern architecture patterns and clean code practices. Focus on the new systems in `/src/` directory rather than maintaining legacy compatibility.
## Markdown File Guidelines
When creating or editing `.md` files in this project, follow these linting rules:
### MD032 - Lists surrounded by blank lines
Always add blank lines before and after lists:
```markdown
Some text here.
- First item
- Second item
- Third item
More text here.
```
### MD047 - Files should end with a single newline
Ensure every markdown file ends with exactly one newline character at the end of the file.

View file

@ -375,26 +375,31 @@ return [
## Implementation Order ## Implementation Order
1. **Phase 1: Foundation** 1. **Phase 1: Foundation**
- Create directory structure - Create directory structure
- Set up base classes in Domain/Shared - Set up base classes in Domain/Shared
- Configure dependency injection - Configure dependency injection
2. **Phase 2: Domain Modeling** 2. **Phase 2: Domain Modeling**
- Implement core aggregates - Implement core aggregates
- Create value objects - Create value objects
- Define repository interfaces - Define repository interfaces
3. **Phase 3: Application Services** 3. **Phase 3: Application Services**
- Create commands and queries - Create commands and queries
- Implement handlers - Implement handlers
- Set up event dispatching - Set up event dispatching
4. **Phase 4: Infrastructure** 4. **Phase 4: Infrastructure**
- Implement repositories - Implement repositories
- Configure database adapter - Configure database adapter
- Set up caching - Set up caching
5. **Phase 5: Presentation** 5. **Phase 5: Presentation**
- Create controllers - Create controllers
- Implement middleware - Implement middleware
- Build CLI commands - Build CLI commands

View file

@ -1,6 +1,7 @@
# Forum Commands # Forum Commands
Commands representing write operations: Commands representing write operations:
- `CreateThreadCommand`: Start new discussion - `CreateThreadCommand`: Start new discussion
- `CreatePostCommand`: Reply to thread - `CreatePostCommand`: Reply to thread
- `EditPostCommand`: Modify existing post - `EditPostCommand`: Modify existing post

View file

@ -1,6 +1,7 @@
# Forum Handlers # Forum Handlers
Command and query handlers for forum operations: Command and query handlers for forum operations:
- `CreateThreadHandler`: Handles thread creation - `CreateThreadHandler`: Handles thread creation
- `CreatePostHandler`: Handles post creation - `CreatePostHandler`: Handles post creation
- `GetThreadListHandler`: Retrieves thread listings - `GetThreadListHandler`: Retrieves thread listings

View file

@ -1,6 +1,7 @@
# Forum Queries # Forum Queries
Read-only queries for forum data: Read-only queries for forum data:
- `GetThreadListQuery`: Paginated thread listing - `GetThreadListQuery`: Paginated thread listing
- `GetPostsByThreadQuery`: Thread posts with pagination - `GetPostsByThreadQuery`: Thread posts with pagination
- `SearchPostsQuery`: Full-text post search - `SearchPostsQuery`: Full-text post search

View file

@ -1,11 +1,13 @@
# Application Layer # Application Layer
Contains application services that orchestrate domain objects to fulfill use cases. Contains application services that orchestrate domain objects to fulfill use cases.
- Commands: Write operations that change state - Commands: Write operations that change state
- Queries: Read operations for data retrieval - Queries: Read operations for data retrieval
- Handlers: Process commands and queries - Handlers: Process commands and queries
This layer should: This layer should:
- Coordinate domain objects - Coordinate domain objects
- Handle transactions - Handle transactions
- Dispatch domain events - Dispatch domain events

View file

@ -1,11 +1,13 @@
# Tracker Commands # Tracker Commands
Commands representing write operations: Commands representing write operations:
- `RegisterTorrentCommand`: Register new torrent - `RegisterTorrentCommand`: Register new torrent
- `UpdateTorrentCommand`: Modify torrent details - `UpdateTorrentCommand`: Modify torrent details
- `DeleteTorrentCommand`: Remove torrent from tracker - `DeleteTorrentCommand`: Remove torrent from tracker
Example: Example:
```php ```php
final class RegisterTorrentCommand final class RegisterTorrentCommand
{ {

View file

@ -1,6 +1,7 @@
# Tracker Handlers # Tracker Handlers
Command and query handlers for tracker operations: Command and query handlers for tracker operations:
- `RegisterTorrentHandler`: Processes torrent registration - `RegisterTorrentHandler`: Processes torrent registration
- `GetTorrentDetailsHandler`: Retrieves torrent information - `GetTorrentDetailsHandler`: Retrieves torrent information
- `UpdateTorrentHandler`: Handles torrent updates - `UpdateTorrentHandler`: Handles torrent updates

View file

@ -1,6 +1,7 @@
# Tracker Queries # Tracker Queries
Read-only queries for tracker data: Read-only queries for tracker data:
- `GetTorrentDetailsQuery`: Single torrent information - `GetTorrentDetailsQuery`: Single torrent information
- `GetPeerListQuery`: Active peers for torrent - `GetPeerListQuery`: Active peers for torrent
- `GetTorrentStatsQuery`: Download/upload statistics - `GetTorrentStatsQuery`: Download/upload statistics

View file

@ -1,6 +1,7 @@
# User Commands # User Commands
Commands for user management operations: Commands for user management operations:
- `RegisterUserCommand`: New user registration - `RegisterUserCommand`: New user registration
- `ChangePasswordCommand`: Password update - `ChangePasswordCommand`: Password update
- `UpdateProfileCommand`: Profile modifications - `UpdateProfileCommand`: Profile modifications

View file

@ -1,6 +1,7 @@
# User Handlers # User Handlers
Command and query handlers for user operations: Command and query handlers for user operations:
- `RegisterUserHandler`: Processes user registration - `RegisterUserHandler`: Processes user registration
- `ChangePasswordHandler`: Handles password changes - `ChangePasswordHandler`: Handles password changes
- `GetUserProfileHandler`: Retrieves user profiles - `GetUserProfileHandler`: Retrieves user profiles

View file

@ -1,6 +1,7 @@
# User Queries # User Queries
Read operations for user data: Read operations for user data:
- `GetUserProfileQuery`: User profile details - `GetUserProfileQuery`: User profile details
- `SearchUsersQuery`: User search with filters - `SearchUsersQuery`: User search with filters
- `GetUserStatisticsQuery`: Upload/download stats - `GetUserStatisticsQuery`: Upload/download stats

View file

@ -1,6 +1,7 @@
# Forum Domain Exceptions # Forum Domain Exceptions
Domain-specific exceptions for forum operations: Domain-specific exceptions for forum operations:
- `ThreadLockedException`: Attempt to post in locked thread - `ThreadLockedException`: Attempt to post in locked thread
- `PostEditTimeExpiredException`: Edit time limit exceeded - `PostEditTimeExpiredException`: Edit time limit exceeded
- `ForumAccessDeniedException`: Insufficient permissions - `ForumAccessDeniedException`: Insufficient permissions

View file

@ -1,12 +1,14 @@
# Forum Domain Models # Forum Domain Models
Contains aggregate roots and entities for the forum system: Contains aggregate roots and entities for the forum system:
- `Forum`: Forum category aggregate - `Forum`: Forum category aggregate
- `Thread`: Discussion thread aggregate root - `Thread`: Discussion thread aggregate root
- `Post`: Individual post entity - `Post`: Individual post entity
- `Attachment`: File attachment entity - `Attachment`: File attachment entity
Business rules enforced at this level: Business rules enforced at this level:
- Post editing time limits - Post editing time limits
- Thread locking rules - Thread locking rules
- Forum access permissions - Forum access permissions

View file

@ -1,6 +1,7 @@
# Forum Repository Interfaces # Forum Repository Interfaces
Repository interfaces for forum aggregates: Repository interfaces for forum aggregates:
- `ForumRepositoryInterface`: Forum aggregate persistence - `ForumRepositoryInterface`: Forum aggregate persistence
- `ThreadRepositoryInterface`: Thread aggregate persistence - `ThreadRepositoryInterface`: Thread aggregate persistence
- `PostRepositoryInterface`: Post queries (read-only) - `PostRepositoryInterface`: Post queries (read-only)

View file

@ -1,6 +1,7 @@
# Forum Value Objects # Forum Value Objects
Immutable objects representing forum concepts: Immutable objects representing forum concepts:
- `PostId`: Unique post identifier - `PostId`: Unique post identifier
- `ThreadTitle`: Thread title with validation - `ThreadTitle`: Thread title with validation
- `PostContent`: Formatted post content - `PostContent`: Formatted post content

View file

@ -1,12 +1,14 @@
# Domain Layer # Domain Layer
This directory contains the core business logic of TorrentPier. Code here should: This directory contains the core business logic of TorrentPier. Code here should:
- Have no dependencies on frameworks or infrastructure - Have no dependencies on frameworks or infrastructure
- Represent pure business rules and domain models - Represent pure business rules and domain models
- Be testable in isolation - Be testable in isolation
- Use only PHP language features and domain concepts - Use only PHP language features and domain concepts
## Bounded Contexts ## Bounded Contexts
- **Forum**: Discussion forums, posts, threads - **Forum**: Discussion forums, posts, threads
- **Tracker**: BitTorrent tracking, peers, torrents - **Tracker**: BitTorrent tracking, peers, torrents
- **User**: User management, authentication, profiles - **User**: User management, authentication, profiles

View file

@ -1,11 +1,13 @@
# Domain Events # Domain Events
Base classes and interfaces for domain event system: Base classes and interfaces for domain event system:
- `DomainEvent`: Base event interface - `DomainEvent`: Base event interface
- `EventRecording`: Trait for aggregate event recording - `EventRecording`: Trait for aggregate event recording
- `AggregateHistory`: Event sourcing support - `AggregateHistory`: Event sourcing support
Example events: Example events:
- `UserRegisteredEvent` - `UserRegisteredEvent`
- `TorrentUploadedEvent` - `TorrentUploadedEvent`
- `ThreadCreatedEvent` - `ThreadCreatedEvent`

View file

@ -1,6 +1,7 @@
# Shared Domain Exceptions # Shared Domain Exceptions
Base exception classes used across all bounded contexts: Base exception classes used across all bounded contexts:
- `DomainException`: Base domain exception - `DomainException`: Base domain exception
- `InvalidArgumentException`: Invalid input validation - `InvalidArgumentException`: Invalid input validation
- `EntityNotFoundException`: Generic entity not found - `EntityNotFoundException`: Generic entity not found

View file

@ -1,6 +1,7 @@
# Shared Domain Models # Shared Domain Models
Base classes and interfaces used across bounded contexts: Base classes and interfaces used across bounded contexts:
- `AggregateRoot`: Base class for all aggregates - `AggregateRoot`: Base class for all aggregates
- `Entity`: Base class for entities - `Entity`: Base class for entities
- `DomainEvent`: Interface for domain events - `DomainEvent`: Interface for domain events

View file

@ -1,9 +1,9 @@
# Shared Repository Interfaces # Shared Repository Interfaces
Common repository patterns and base interfaces: Common repository patterns and base interfaces:
- `RepositoryInterface`: Base repository contract - `RepositoryInterface`: Base repository contract
- `ReadOnlyRepositoryInterface`: Query-only operations - `ReadOnlyRepositoryInterface`: Query-only operations
- `AggregateRepositoryInterface`: Aggregate-specific methods - `AggregateRepositoryInterface`: Aggregate-specific methods
- `Specification`: Query specification pattern
These define common persistence patterns without implementation details. These define common persistence patterns without implementation details.

View file

@ -1,6 +1,7 @@
# Shared Value Objects # Shared Value Objects
Common value objects used across contexts: Common value objects used across contexts:
- `Id`: Generic identifier base class - `Id`: Generic identifier base class
- `DateTime`: Immutable datetime wrapper - `DateTime`: Immutable datetime wrapper
- `Money`: Monetary value representation - `Money`: Monetary value representation

View file

@ -1,6 +1,7 @@
# Tracker Domain Exceptions # Tracker Domain Exceptions
Domain-specific exceptions for tracker operations: Domain-specific exceptions for tracker operations:
- `InvalidInfoHashException`: Malformed info hash - `InvalidInfoHashException`: Malformed info hash
- `InactiveTorrentException`: Torrent not active - `InactiveTorrentException`: Torrent not active
- `PeerLimitExceededException`: Too many peers - `PeerLimitExceededException`: Too many peers

View file

@ -1,11 +1,13 @@
# Tracker Domain Models # Tracker Domain Models
Contains aggregate roots and entities for the BitTorrent tracker: Contains aggregate roots and entities for the BitTorrent tracker:
- `Torrent`: Aggregate root for torrent management - `Torrent`: Aggregate root for torrent management
- `Peer`: Entity representing a BitTorrent peer - `Peer`: Entity representing a BitTorrent peer
- `TorrentStatistics`: Value object for torrent stats - `TorrentStatistics`: Value object for torrent stats
Example: Example:
```php ```php
class Torrent extends AggregateRoot class Torrent extends AggregateRoot
{ {

View file

@ -1,6 +1,7 @@
# Tracker Repository Interfaces # Tracker Repository Interfaces
Repository interfaces for tracker aggregates: Repository interfaces for tracker aggregates:
- `TorrentRepositoryInterface`: Torrent aggregate persistence - `TorrentRepositoryInterface`: Torrent aggregate persistence
- `PeerRepositoryInterface`: Peer data access - `PeerRepositoryInterface`: Peer data access
- `TrackerStatsRepositoryInterface`: Statistics queries - `TrackerStatsRepositoryInterface`: Statistics queries

View file

@ -1,12 +1,14 @@
# Tracker Value Objects # Tracker Value Objects
Immutable objects representing domain concepts: Immutable objects representing domain concepts:
- `InfoHash`: 20-byte torrent identifier - `InfoHash`: 20-byte torrent identifier
- `PeerId`: Peer client identifier - `PeerId`: Peer client identifier
- `Port`: Network port (1-65535) - `Port`: Network port (1-65535)
- `BytesTransferred`: Upload/download bytes - `BytesTransferred`: Upload/download bytes
Example: Example:
```php ```php
final class InfoHash final class InfoHash
{ {

View file

@ -1,6 +1,7 @@
# User Domain Exceptions # User Domain Exceptions
Domain-specific exceptions for user operations: Domain-specific exceptions for user operations:
- `UserNotFoundException`: User not found - `UserNotFoundException`: User not found
- `DuplicateUsernameException`: Username already taken - `DuplicateUsernameException`: Username already taken
- `InvalidCredentialsException`: Authentication failed - `InvalidCredentialsException`: Authentication failed

View file

@ -1,12 +1,14 @@
# User Domain Models # User Domain Models
Contains user management aggregates and entities: Contains user management aggregates and entities:
- `User`: User aggregate root - `User`: User aggregate root
- `UserProfile`: User profile information - `UserProfile`: User profile information
- `UserCredentials`: Authentication credentials - `UserCredentials`: Authentication credentials
- `UserPermissions`: Authorization rules - `UserPermissions`: Authorization rules
Business rules: Business rules:
- Password complexity requirements - Password complexity requirements
- Username uniqueness - Username uniqueness
- Email verification workflow - Email verification workflow

View file

@ -1,6 +1,7 @@
# User Repository Interface # User Repository Interface
Repository interface for user aggregate: Repository interface for user aggregate:
- `UserRepositoryInterface`: User persistence and retrieval - `UserRepositoryInterface`: User persistence and retrieval
- `findById(UserId $id): ?User` - `findById(UserId $id): ?User`
- `findByUsername(Username $username): ?User` - `findByUsername(Username $username): ?User`

View file

@ -1,6 +1,7 @@
# User Value Objects # User Value Objects
Immutable objects for user domain: Immutable objects for user domain:
- `UserId`: Unique user identifier - `UserId`: Unique user identifier
- `Username`: Username with validation - `Username`: Username with validation
- `Email`: Email address with format validation - `Email`: Email address with format validation

View file

@ -1,6 +1,7 @@
# File Cache Adapter # File Cache Adapter
File system-based caching implementation: File system-based caching implementation:
- Simple file-based storage - Simple file-based storage
- Suitable for single-server deployments - Suitable for single-server deployments
- Directory structure optimization - Directory structure optimization

View file

@ -1,6 +1,7 @@
# Memcached Cache Adapter # Memcached Cache Adapter
Memcached-based caching implementation: Memcached-based caching implementation:
- Simple key-value caching - Simple key-value caching
- Distributed cache support - Distributed cache support
- Automatic key expiration - Automatic key expiration

View file

@ -1,6 +1,7 @@
# Redis Cache Adapter # Redis Cache Adapter
Redis-based caching implementation: Redis-based caching implementation:
- High-performance key-value storage - High-performance key-value storage
- Support for data structures (lists, sets, hashes) - Support for data structures (lists, sets, hashes)
- TTL management - TTL management

View file

@ -1,6 +1,7 @@
# Email Templates # Email Templates
Email template management: Email template management:
- HTML and plain text templates - HTML and plain text templates
- Template variables and placeholders - Template variables and placeholders
- Multi-language support - Multi-language support
@ -8,6 +9,7 @@ Email template management:
- Preview functionality - Preview functionality
Common templates: Common templates:
- User registration confirmation - User registration confirmation
- Password reset - Password reset
- Torrent notifications - Torrent notifications

View file

@ -1,6 +1,7 @@
# Email Transport # Email Transport
Email delivery mechanisms: Email delivery mechanisms:
- `SmtpTransport`: Traditional SMTP delivery - `SmtpTransport`: Traditional SMTP delivery
- `SendgridTransport`: SendGrid API integration - `SendgridTransport`: SendGrid API integration
- `MailgunTransport`: Mailgun API integration - `MailgunTransport`: Mailgun API integration

View file

@ -1,6 +1,7 @@
# Local File Storage # Local File Storage
Local filesystem storage implementation: Local filesystem storage implementation:
- Direct disk storage - Direct disk storage
- Directory structure management - Directory structure management
- File permissions handling - File permissions handling

View file

@ -1,6 +1,7 @@
# S3 File Storage # S3 File Storage
Amazon S3 (or compatible) storage implementation: Amazon S3 (or compatible) storage implementation:
- Cloud object storage - Cloud object storage
- Pre-signed URLs for direct uploads - Pre-signed URLs for direct uploads
- CDN integration support - CDN integration support

View file

@ -1,6 +1,7 @@
# Database Adapter # Database Adapter
Database connection and query building layer: Database connection and query building layer:
- `DatabaseAdapterInterface`: Common database operations - `DatabaseAdapterInterface`: Common database operations
- `QueryBuilder`: Fluent query construction - `QueryBuilder`: Fluent query construction
- `ConnectionPool`: Connection management - `ConnectionPool`: Connection management

View file

@ -1,6 +1,7 @@
# Database Migrations # Database Migrations
Schema version control and migration management: Schema version control and migration management:
- Migration files for schema changes - Migration files for schema changes
- Seed data for initial setup - Seed data for initial setup
- Rollback support - Rollback support

View file

@ -1,12 +1,14 @@
# Repository Implementations # Repository Implementations
Concrete implementations of domain repository interfaces: Concrete implementations of domain repository interfaces:
- Uses database adapter for persistence - Uses database adapter for persistence
- Implements caching strategies - Implements caching strategies
- Handles query optimization - Handles query optimization
- Supports multiple database backends - Supports multiple database backends
Example: Example:
```php ```php
class TorrentRepository implements TorrentRepositoryInterface class TorrentRepository implements TorrentRepositoryInterface
{ {

View file

@ -1,6 +1,7 @@
# Infrastructure Layer # Infrastructure Layer
Technical implementations and external service adapters: Technical implementations and external service adapters:
- Database persistence - Database persistence
- Caching mechanisms - Caching mechanisms
- Email services - Email services

View file

@ -1,6 +1,7 @@
# CLI Commands # CLI Commands
Console commands for administrative tasks: Console commands for administrative tasks:
- `UserCreateCommand`: Create users from CLI - `UserCreateCommand`: Create users from CLI
- `CacheClearCommand`: Clear cache stores - `CacheClearCommand`: Clear cache stores
- `MigrateCommand`: Run database migrations - `MigrateCommand`: Run database migrations

View file

@ -1,12 +1,14 @@
# Admin Panel Controllers # Admin Panel Controllers
Administrative interface controllers with enhanced security: Administrative interface controllers with enhanced security:
- Role-based access control (RBAC) - Role-based access control (RBAC)
- Audit logging for all actions - Audit logging for all actions
- Additional authentication checks - Additional authentication checks
- Administrative dashboards and reports - Administrative dashboards and reports
Example: Example:
```php ```php
class AdminUserController class AdminUserController
{ {

View file

@ -1,12 +1,14 @@
# API Controllers # API Controllers
RESTful API endpoints following OpenAPI specification: RESTful API endpoints following OpenAPI specification:
- JSON request/response format - JSON request/response format
- Proper HTTP status codes - Proper HTTP status codes
- HATEOAS where applicable - HATEOAS where applicable
- Rate limiting aware - Rate limiting aware
Example: Example:
```php ```php
class UserController class UserController
{ {

View file

@ -1,6 +1,7 @@
# Web Controllers # Web Controllers
Traditional web interface controllers: Traditional web interface controllers:
- HTML response generation - HTML response generation
- Template rendering - Template rendering
- Form handling - Form handling
@ -8,6 +9,7 @@ Traditional web interface controllers:
- CSRF protection - CSRF protection
Controllers for: Controllers for:
- Forum browsing and posting - Forum browsing and posting
- Torrent browsing and downloading - Torrent browsing and downloading
- User profiles and settings - User profiles and settings

View file

@ -1,6 +1,7 @@
# HTTP Middleware # HTTP Middleware
Request/response pipeline middleware: Request/response pipeline middleware:
- `AuthenticationMiddleware`: User authentication - `AuthenticationMiddleware`: User authentication
- `AuthorizationMiddleware`: Permission checks - `AuthorizationMiddleware`: Permission checks
- `CsrfProtectionMiddleware`: CSRF token validation - `CsrfProtectionMiddleware`: CSRF token validation

View file

@ -1,6 +1,7 @@
# HTTP Requests # HTTP Requests
Request objects and validation: Request objects and validation:
- Request DTOs with validation rules - Request DTOs with validation rules
- Type-safe access to request data - Type-safe access to request data
- File upload handling - File upload handling
@ -8,6 +9,7 @@ Request objects and validation:
- Custom validation rules - Custom validation rules
Example: Example:
```php ```php
class RegisterRequest extends FormRequest class RegisterRequest extends FormRequest
{ {

View file

@ -1,6 +1,7 @@
# HTTP Responses # HTTP Responses
Response transformation and formatting: Response transformation and formatting:
- Response factories - Response factories
- JSON transformers - JSON transformers
- View presenters - View presenters

View file

@ -1,6 +1,7 @@
# Presentation Layer # Presentation Layer
User interface implementations: User interface implementations:
- HTTP controllers for web and API - HTTP controllers for web and API
- CLI commands for console operations - CLI commands for console operations
- Request/response handling - Request/response handling