Files
Gondulf/docs/decisions/0005-phase1-database-schema.md
Phil Skentelbery bebd47955f feat(core): implement Phase 1 foundation infrastructure
Implements Phase 1 Foundation with all core services:

Core Components:
- Configuration management with GONDULF_ environment variables
- Database layer with SQLAlchemy and migration system
- In-memory code storage with TTL support
- Email service with SMTP and TLS support (STARTTLS + implicit TLS)
- DNS service with TXT record verification
- Structured logging with Python standard logging
- FastAPI application with health check endpoint

Database Schema:
- authorization_codes table for OAuth 2.0 authorization codes
- domains table for domain verification
- migrations table for tracking schema versions
- Simple sequential migration system (001_initial_schema.sql)

Configuration:
- Environment-based configuration with validation
- .env.example template with all GONDULF_ variables
- Fail-fast validation on startup
- Sensible defaults for optional settings

Testing:
- 96 comprehensive tests (77 unit, 5 integration)
- 94.16% code coverage (exceeds 80% requirement)
- All tests passing
- Test coverage includes:
  - Configuration loading and validation
  - Database migrations and health checks
  - In-memory storage with expiration
  - Email service (STARTTLS, implicit TLS, authentication)
  - DNS service (TXT records, domain verification)
  - Health check endpoint integration

Documentation:
- Implementation report with test results
- Phase 1 clarifications document
- ADRs for key decisions (config, database, email, logging)

Technical Details:
- Python 3.10+ with type hints
- SQLite with configurable database URL
- System DNS with public DNS fallback
- Port-based TLS detection (465=SSL, 587=STARTTLS)
- Lazy configuration loading for testability

Exit Criteria Met:
✓ All foundation services implemented
✓ Application starts without errors
✓ Health check endpoint operational
✓ Database migrations working
✓ Test coverage exceeds 80%
✓ All tests passing

Ready for Architect review and Phase 2 development.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-20 12:21:42 -07:00

1.4 KiB

0005. Phase 1 Database Schema

Date: 2024-11-20

Status

Accepted

Context

Phase 1 requires database storage for authorization codes and domain verification. We need to determine which tables to create initially while avoiding over-engineering for future needs.

Decision

Phase 1 will create exactly three tables:

  1. authorization_codes - Temporary storage for OAuth authorization codes

    • Required by IndieAuth authorization flow
    • Short-lived (10 minutes expiry)
    • Contains: code, client_id, redirect_uri, state, code_challenge, code_challenge_method, scope, created_at
  2. domains - Verified domain ownership records

    • Required for domain verification flow
    • Stores verification codes and status
    • Contains: domain, email, verification_code, verified, created_at, verified_at
  3. migrations - Schema version tracking

    • Simple migration tracking
    • Contains: version, applied_at, description

We will NOT create in Phase 1:

  • Audit/logging tables (use structured logging to files instead)
  • Token storage table (tokens are handled in Phase 2)
  • Client registration table (Phase 3 feature)

Consequences

Positive

  • Minimal schema focused on immediate Phase 1 needs
  • Easy to understand and test
  • Fast database operations with minimal tables
  • Can add tables in later phases as features require them

Negative

  • No audit trail in database (rely on application logs)
  • Will need migration for Phase 2 token storage