How shubhamranswal/ciphergate works
CipherGate is an interactive CLI authentication system. Users register, log in with password and optionally TOTP, receive a managed session, and can inspect their account, manage MFA, or log out. Services enforce user and session rules over PostgreSQL-backed repositories; startup wires those components and runs migrations. The graph follows the supplied excerpts and README; unshown implementation details are represented only where documented, and uncertain links are omitted.
Main entry points: shell.go Command Shell · user/service.go User Service · main.go Application Startup · session/service.go Session Service
Components 20
Interactive CLI
- Command Shell
internal/cli/shell.go - Registration
internal/cli/register.go - Login Flow
internal/cli/login.go - MFA Commands
internal/cli/enable_2fa.go - Logout
internal/cli/logout.go - Session Guard
internal/cli/session_guard.go - Account Details
internal/cli/whoami.go
Identity Services
- Auth Context
internal/auth/context.go - User Service
internal/user/service.go - Session Service
internal/session/service.go - TOTP Service
internal/mfa/service.go
Persistence
- User Repository
internal/user/postgres_repository.go - Session Repository
internal/session/postgres_repository.go - PostgreSQL Connection
internal/database/postgres.go - PostgreSQL
- Migration Runner
internal/migration/runner.go - Database Schema
migrations/001_create_users.sql
Runtime Setup
- Application Startup
main.go - Runtime Configuration
internal/config/config.go
Other components
- CLI User
Connections 38
- CLI User → Command Shell: enters commands
README.md - Command Shell → Registration: dispatches register
internal/cli/shell.go - Command Shell → Login Flow: dispatches login
internal/cli/shell.go - Command Shell → MFA Commands: dispatches MFA
internal/cli/shell.go - Command Shell → Logout: dispatches logout
internal/cli/shell.go - Command Shell → Session Guard: validates session
internal/cli/shell.go - Command Shell → Account Details: dispatches details
internal/cli/shell.go - Registration → User Service: registers user
internal/cli/register.go - Login Flow → User Service: authenticates password
internal/cli/login.go - Login Flow → TOTP Service: verifies TOTP
internal/cli/login.go - Login Flow → Session Service: creates MFA session
internal/cli/login.go - Login Flow → User Service: updates login times
internal/cli/login.go - Login Flow → Auth Context: sets authenticated state
internal/cli/login.go - MFA Commands → TOTP Service: generates and verifies
internal/cli/enable_2fa.go - MFA Commands → User Service: updates MFA settings
internal/cli/enable_2fa.go - Logout → Session Service: deactivates session
internal/cli/logout.go - Logout → Auth Context: clears auth state
internal/cli/logout.go - Session Guard → Auth Context: checks and clears state
internal/cli/session_guard.go - Session Guard → Session Service: validates and deactivates
internal/cli/session_guard.go - Account Details → Auth Context: reads user details
internal/cli/whoami.go - User Service → User Repository: reads and updates users
internal/user/service.go - User Service → Session Service: creates login session
internal/user/service.go - Session Service → Session Repository: creates and validates
internal/session/service.go - User Service → Runtime Configuration: reads lockout settings
internal/user/service.go - Session Service → Runtime Configuration: reads session timeout
internal/session/service.go - User Repository → PostgreSQL Connection: uses database connection
- Session Repository → PostgreSQL Connection: uses database connection
- PostgreSQL Connection → PostgreSQL: connects to
README.md - Application Startup → Runtime Configuration: loads settings
main.go - Application Startup → PostgreSQL Connection: connects
main.go - Application Startup → Migration Runner: runs migrations
main.go - Application Startup → User Service: wires user service
main.go - Application Startup → Session Service: wires session service
main.go - Application Startup → TOTP Service: wires MFA service
main.go - Application Startup → Command Shell: starts CLI
main.go - Migration Runner → Database Schema: applies schema
- User Repository → PostgreSQL: persists user data
README.md - Session Repository → PostgreSQL: persists sessions
README.md