feat: add config module with environment variable handling

Implements Step 1.1 config.py with Pydantic Settings:
- PORT (default 3366), DB_PATH, BASE_PATH
- AUTH_HEADER_NAME, TRUSTED_PROXY_IPS (comma-separated)
- CSRF_SECRET (required), CSRF_COOKIE_NAME
- SEED_ON_START, LOG_LEVEL (validated), METRICS_ENABLED

Includes 28 TDD tests covering defaults, overrides, and validation.
Also fixes pytest pythonpath configuration.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-27 17:54:21 +00:00
parent d213abf9d9
commit 61f704c68d
5 changed files with 369 additions and 13 deletions

12
PLAN.md
View File

@@ -7,12 +7,12 @@ Check off items as completed. Each phase builds on the previous.
## Phase 1: Foundation
### Step 1.1: Project Structure & Configuration
- [ ] Create Python package structure (`src/animaltrack/`)
- [ ] Create `pyproject.toml` with dependencies
- [ ] Create `flake.nix` with dev environment
- [ ] Create `.envrc`, `.gitignore`
- [ ] Implement `config.py` with all env vars from spec §18
- [ ] Write tests for config loading and validation
- [x] Create Python package structure (`src/animaltrack/`)
- [x] Create `pyproject.toml` with dependencies
- [x] Create `flake.nix` with dev environment
- [x] Create `.envrc`, `.gitignore`
- [x] Implement `config.py` with all env vars from spec §18
- [x] Write tests for config loading and validation
- [ ] **Commit checkpoint**
### Step 1.2: Database Connection & Pragmas