Introduction
Architecture
Clean Architecture and design principles
Authula follows Clean Architecture principles with built-in HTTP handlers:
┌─────────────────────────────────────────────────────────────┐
│ Authula Library │
├─────────────────────────────────────────────────────────────┤
│ Standalone HTTP Handlers │
│ • Built-in http.Handler implementation │
│ • auth.Handler() returns ready-to-use handler │
│ • Mount on any standard Mux HTTP server │
│ • Uses Chi router under the hood │
├─────────────────────────────────────────────────────────────┤
│ Database Adapters │
│ • SQLite │
│ • PostgreSQL │
│ • MySQL │
│ • Extensible │
└─────────────────────────────────────────────────────────────┘Key Design Principles
- Framework-Agnostic Core: Clean separation between business logic and HTTP concerns
- Standard Library First: Handlers implement
net/http.Handlerinterface
Component Layers
Models Layer
- Entities: User, Account, Session, Verification and more
Handler Layer
- Entrypoint for API endpoints, delegates logic to use cases which uilise services that use repositories providing clear separation of concerns.
- Integrated with middleware and hooks for extensibility
Use Cases Layer
- Use cases (interfaces), services (business logic), repositories (database access) for authentication workflows
Database Layer
- Bun ORM based adapters for multiple databases
Extensibility
- Various hooks into the authentication flow for customisation
- Plugin system for custom logic and extensions
- Event Bus for event-driven architecture
