App Logo
Introduction

Architecture

Clean Architecture and design principles

GoBetterAuth follows Clean Architecture principles with built-in HTTP handlers:

┌─────────────────────────────────────────────────────────────┐
│ GoBetterAuth Library                                        │
├─────────────────────────────────────────────────────────────┤
│ Standalone HTTP Handlers                                    │
│ • Built-in http.Handler implementation                      │
│ • auth.Handler() returns ready-to-use handler               │
│ • Mount on any standard Mux HTTP server                     │
├─────────────────────────────────────────────────────────────┤
│ Database Adapters                                           │
│ • SQLite                                                    │
│ • PostgreSQL                                                │
│ • MySQL                                                     │
│ • Extensible                                                │
└─────────────────────────────────────────────────────────────┘

Key Design Principles

  1. Framework-Agnostic Core: Clean separation between business logic and HTTP concerns
  2. Standard Library First: Handlers implement net/http.Handler interface

Component Layers

Models Layer

  • Entities: User, Account, Session, Verification and more

Handler Layer

  • Entrypoint for API endpoints, delegates logic to services
  • Integrated with middleware

Services Layer

  • Use cases (interfaces) and services (business logic) for authentication workflows

Database Layer

  • GORM 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

On this page