- Update decision-log with UI layout decisions (Feb 18, 2026) - Update architecture with frontend layout patterns - Update config.yaml with TDD, documentation, UI standards rules - Create p00-api-documentation change (Scribe annotations) - Create p01-ui-foundation change (types, stores, Lucide) - Create p02-app-layout change (AppLayout, Sidebar, TopBar) - Create p03-dashboard-enhancement change (PageHeader, StatCard) - Create p04-content-patterns change (DataTable, FilterBar) - Create p05-page-migrations change (page migrations) - Fix E2E auth tests (11/11 passing) - Add JWT expiry validation to dashboard guard
4.0 KiB
4.0 KiB
Design: API Documentation with Scribe
Technical Approach
Scribe Configuration
File: config/scribe.php
return [
'title' => 'Headroom API',
'description' => 'Resource planning and capacity management API',
'base_url' => env('APP_URL') . '/api',
'auth' => [
'enabled' => true,
'default' => true,
'in' => 'bearer',
'use_value' => 'Bearer {token}',
],
'routes' => [
[
'match' => ['api/*'],
'include' => [],
'exclude' => [],
],
],
];
Annotation Patterns
Authentication Endpoint Example
/**
* @group Authentication
*
* Authenticate user and issue JWT tokens.
*
* @bodyParam email string required User's email address. Example: user@example.com
* @bodyParam password string required User's password. Example: secret123
*
* @response 200 {
* "data": {
* "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...",
* "refresh_token": "abc123def456...",
* "token_type": "bearer",
* "expires_in": 3600
* }
* }
* @response 401 {
* "message": "Invalid credentials",
* "errors": {
* "email": ["These credentials do not match our records."]
* }
* }
* @response 422 {
* "message": "Validation failed",
* "errors": {
* "email": ["The email field is required."],
* "password": ["The password field is required."]
* }
* }
*/
public function login(LoginRequest $request): JsonResponse
CRUD Endpoint Example
/**
* @group Team Members
* @authenticated
*
* List all team members with optional filters.
*
* @queryParam active boolean Filter by active status. Example: true
* @queryParam role_id int Filter by role ID. Example: 1
*
* @response 200 {
* "data": [
* {
* "id": "550e8400-e29b-41d4-a716-446655440000",
* "name": "Alice Johnson",
* "role": {"id": 1, "name": "Frontend Dev"},
* "hourly_rate": 75.00,
* "active": true
* }
* ],
* "meta": {"total": 10}
* }
*/
public function index(Request $request): JsonResponse
Group Organization
| Group | Controller | Endpoints |
|---|---|---|
| Authentication | AuthController | 5 |
| Team Members | TeamMemberController | 5 |
| Projects | ProjectController | 8 |
| Allocations | AllocationController | 6 |
| Actuals | ActualController | 5 |
| Capacity | CapacityController | 6 |
| Reports | ReportController | 5 |
| Master Data | MasterDataController | 9 |
Authentication Documentation
Include a dedicated section explaining:
- How to obtain tokens (login endpoint)
- How to use tokens (Authorization: Bearer {token})
- Token refresh flow
- Token expiration (60 min access, 7 day refresh)
Implementation Order
- Configure Scribe (
config/scribe.php) - Annotate AuthController (most critical, used by all)
- Annotate TeamMemberController
- Annotate ProjectController
- Annotate AllocationController
- Annotate ActualController
- Annotate CapacityController
- Annotate ReportController
- Annotate MasterDataController
- Generate documentation (
php artisan scribe:generate) - Verify SwaggerUI at
/api/documentation
File Changes
New Files
config/scribe.php- Scribe configuration
Modified Files
backend/app/Http/Controllers/Api/AuthController.phpbackend/app/Http/Controllers/Api/TeamMemberController.phpbackend/app/Http/Controllers/Api/ProjectController.phpbackend/app/Http/Controllers/Api/AllocationController.phpbackend/app/Http/Controllers/Api/ActualController.phpbackend/app/Http/Controllers/Api/CapacityController.phpbackend/app/Http/Controllers/Api/ReportController.phpbackend/app/Http/Controllers/Api/MasterDataController.php
Testing
- Run
php artisan scribe:generate- must complete without errors - Verify generated docs at
/api/documentation - Test "Try it out" functionality for login endpoint