How authcompanion/authcompanion2 works
Main System Components
a) Client Layer:
• Web Forms (Authentication UI)
• Admin Dashboard UI
• Two distinct client interfaces (/auth and /admin directories)
b) API Layer:
• Authentication API endpoints
• Admin API endpoints
• WebAuthn services
c) Service Layer:
• Authentication Services
• Admin Services
• WebAuthn Services
d) Data Layer:
• Database (showing both PostgreSQL and SQLite support)
• Schema management
Component Relationships
[Client Layer]
• ↓↑
[API Routes Layer (auth.routes.js, admin.routes.js, ui.routes.js)]
• ↓↑
[Service Layer]
• ↓↑
[Data Access Layer]
Specific Implementation Details
• Blue: Client-facing components
• Green: API/Route handlers
• Yellow: Service layer components
• Red: Security components (JWT, WebAuthn)
• Purple: Database components
Key Architectural Elements
Specific components:
┌─ Authentication Flow ─────┐ ┌─ Admin Flow ──────────┐
• Login │ │ - User Management │
• Registration │ │ - Admin Dashboard │
• Profile Management │ │ - User CRUD Ops │
• Account Recovery │ └─────────────────────┘
• ┘
┌─ Security Layer ──────────┐ ┌─ Database Layer ────────┐
• JWT Management │ │ - PostgreSQL │
• WebAuthn │ │ - SQLite │
• Cookie Handling │ │ - Schema Management │
• ┘ └─────────────────────────┘
Important Flows to Highlight
a) Authentication Flows:
• Traditional Login (username/password)
• Passwordless (WebAuthn)
• Account Recovery
• Token Refresh
b) Admin Flows:
• User Management Operations
• Dashboard Access
• Administrative Actions
Integration Points
External integration points:
• Email Service Integration
• JWT Token Usage
• WebAuthn Device Integration
Technical Details
Annotations for:
• Node.js Runtime Environment
• FastifyJS Framework (implied by the structure)
• JWT Token Flow
• Database Connections
• WebAuthn Integration