How supabase/auth works
Main Components
a. Core Service Components:
• API Server (Main Auth Service)
• Database Layer (PostgreSQL)
• External Provider Integration Layer
• Email/SMS Service Layer
• JWT Management System
• Admin Interface
b. External Components:
• OAuth Providers (GitHub, Google, etc.)
• SMTP Services
• SMS Providers
• CAPTCHA Services
Key Architectural Elements
a. API Layer Structure:
• Public Endpoints (/signup, /token, /verify, etc.)
• Protected Endpoints (/user, /logout)
• Admin Endpoints (/admin/*)
• OAuth Endpoints (/authorize, /callback)
b. Internal Services:
• Authentication Flow Manager
• Token Manager (JWT)
• User Manager
• Mail/SMS Manager
• Rate Limiter
• Audit Logger
Client Layer
API Gateway Layer
Core Service Layer
Integration Layer
Storage Layer
Key Flows to Highlight
a. Authentication Flows:
• Email/Password Sign-in
• OAuth Sign-in
• Magic Link
• Phone Authentication
• Token Refresh
b. User Management Flows:
• User Registration
• Password Recovery
• Email Verification
• Account Updates
Important Relationships
• JWT token flow between components
• Database interactions
• External service communications
• Security boundary demarcations
Technical Details
a. Infrastructure Components:
• Rate Limiting
• CAPTCHA Protection
• Audit Logging
• Observability (Metrics/Tracing)
b. Security Features:
• Password Hashing
• Token Management
• Rate Limiting
• Reauthentication
Implementation Notes
• Clear separation between public and admin APIs
• Security boundaries
• Stateless nature of the JWT implementation
• Database schema relationships
• External service integration points
Specific Architectural Patterns
• Command Pattern (cmd/ directory structure)
• Repository Pattern (models/ directory)
• Middleware Pattern (api/middleware.go)
• Provider Pattern (api/provider/ directory)