Overview
ServITech is a REST API backend built with Laravel 12 that manages quotations for technology and anime products, as well as technical support requests. The system follows a three-tier architecture pattern with clear separation of concerns.System Components
Architecture Layers
1. Client Layer
The system is designed to be consumed by:- Android Mobile Application: Built with Kotlin, provides the user interface
- Third-party clients: Any HTTP client can interact with the API using standard REST conventions
2. API Layer (Laravel Backend)
The core backend is organized into several key components:Controllers
Located inapp/Http/Controllers/, controllers handle incoming requests:
- AuthController (
app/Http/Controllers/Auth/AuthController.php:35) - User authentication (login, register, password reset) - UserController (
app/Http/Controllers/UserController.php:18) - User profile management - ArticleController - Technology and anime product management
- CategoryController - Product category management (admin only)
- SubcategoryController - Product subcategory management
- SupportRequestController - Technical support ticket handling
- RepairRequestController - Repair request management (admin only)
Responses
Standardized response classes inapp/Http/Responses/:
- ApiResponse (
app/Http/Responses/ApiResponse.php:8) - Unified JSON response format for success and error states - MessageResponse (
app/Http/Responses/MessageResponse.php:5) - User-facing message formatting
Routing
API routes are defined inroutes/api.php:27 with the following structure:
- Public routes: Authentication endpoints, article browsing
- Protected routes (
auth:apimiddleware): User profile, support requests - Admin routes (
role:adminmiddleware): Category management, repair requests
All routes are localized using the
localizedGroup() helper, automatically adapting responses to the client’s preferred language.3. Data Layer
The system supports two database engines:- MySQL: Recommended for production deployments
- SQLite: Used for development and testing
- Eloquent ORM: Laravel’s database abstraction layer
- Migrations: Version-controlled database schema
- Seeders: Initial data population
Key Technologies
| Technology | Version | Purpose |
|---|---|---|
| PHP | 8+ | Server-side language |
| Laravel | 12 | Web application framework |
| JWT Auth | Latest | Token-based authentication |
| Spatie Permission | Latest | Role and permission management |
| Scramble (Dedoc) | Latest | API documentation generation |
| MySQL/SQLite | Latest | Data persistence |
Authentication Flow
Request/Response Flow
- Client sends request with optional
Accept-Languageheader - Localization middleware sets the application locale based on:
- URL parameter
- Cookie value
- Session value
Accept-Languageheader (e.g.,en,es)
- Authentication middleware (if protected route) validates JWT token
- Authorization middleware (if admin route) checks user role
- Controller processes the request and calls business logic
- Response is formatted using
ApiResponseand returned as JSON
Configuration Files
Key configuration files inconfig/:
app.php- Application settings, locale configurationauth.php- Authentication guards and providersjwt.php- JWT authentication settingspermission.php- Spatie permission package configurationlocalization.php- Multi-language routing and translation settingsdatabase.php- Database connection configuration
Development Environment
The project uses:- Composer: PHP dependency management
- NPM: Frontend asset management
- Artisan: Laravel’s command-line tool
- Git Flow: Branching strategy (
mainfor production,devfor development)
The application uses environment variables (
.env file) for configuration. Never commit sensitive credentials to version control.Scalability Considerations
The architecture supports:- Horizontal scaling: Stateless JWT authentication allows multiple API servers
- Caching: Laravel’s cache system for permissions and translations (24-hour default)
- Queue system: Background job processing for emails and notifications
- Database replication: Support for read/write splitting
API Documentation
Live API documentation is automatically generated at${APP_URL}/docs/api using Scramble, providing:
- Interactive endpoint testing
- Request/response examples
- Authentication requirements
- Validation rules
Next Steps
Authorization
Learn about the role-based access control system
Localization
Understand multi-language support
Error Handling
Explore error response formats
Authentication
Deep dive into JWT authentication