Documentation Index
Fetch the complete documentation index at: https://try.materi.app/llms.txt
Use this file to discover all available pages before exploring further.
API Architecture
SDD Classification: L3-Technical
Authority: Engineering Team
Review Cycle: Quarterly
Component Architecture
Layer Responsibilities
HTTP Layer (Middleware)
| Middleware | Order | Purpose |
|---|---|---|
| Recovery | 1 | Panic recovery with stack trace |
| Request ID | 2 | Generate/propagate correlation ID |
| Logger | 3 | Request/response logging |
| CORS | 4 | Cross-origin request handling |
| Rate Limit | 5 | Request throttling |
| Auth | 6 | JWT validation and user context |
| Tracing | 7 | OpenTelemetry span creation |
Controller Layer
Controllers handle HTTP concerns only:- Request parsing and validation
- Response formatting
- HTTP status code selection
- No business logic
Service Layer
Services contain business logic:- Domain operations
- Transaction management
- Cross-service coordination
- Event publishing
Repository Layer
Repositories handle data access:- Database queries
- Query building
- Result mapping
- No business logic
Data Models
Database Schema
Domain Models
Request Flow
Authenticated Request
Document Update with Event
Caching Strategy
Cache Layers
Cache Keys
| Pattern | TTL | Purpose |
|---|---|---|
doc:{id} | 5 min | Document content |
doc:{id}:meta | 15 min | Document metadata only |
perm:{user_id}:{doc_id} | 2 min | Permission decision |
perm:{user_id}:ws:{ws_id} | 5 min | Workspace permissions |
user:{id} | 10 min | User profile |
ws:{id}:members | 5 min | Workspace members list |
rate:{user_id}:{endpoint} | 1 min | Rate limit counter |
Cache Invalidation
Error Handling
Error Types
Error Middleware
Circuit Breaker Pattern
Implementation
Circuit Breaker Config
| Service | Failure Threshold | Timeout | Half-Open Max |
|---|---|---|---|
| Shield | 5 | 60s | 2 |
| AI Provider | 3 | 30s | 1 |
| Relay | 5 | 30s | 2 |
| MinIO | 3 | 60s | 2 |
Dependency Injection
Wire Configuration
Related Documentation
- Overview - Service overview
- Endpoints - API endpoint reference
- Authentication - JWT and authorization
- Testing - Test strategies
- Deployment - Container configuration
Document Status: Complete Version: 2.0