diff --git a/.scratch/mvp/issues/01-initialize-repository-structure.md b/.scratch/mvp/issues/01-initialize-repository-structure.md new file mode 100644 index 0000000..ea7b84a --- /dev/null +++ b/.scratch/mvp/issues/01-initialize-repository-structure.md @@ -0,0 +1,15 @@ +# 01: Initialize Repository Structure + +**What to build:** Create repository scaffolding for HAPI MVP. + +- Create `.gitignore`, `pyproject.toml`, `docker-compose.yml`, `Makefile` +- Set up basic folder structure for FastAPI app (`models/`, `routers/`, `schemas/`, `services/`, `db/`) +- Add CI/CD configuration files (`.gitea/`, `.github/`) + +**Blocked by:** None (can start immediately). + +**Status:** ready-for-agent + +- [ ] Repository has standard Python project structure +- [ ] Docker Compose setup is in place +- [ ] CI/CD configuration files are committed diff --git a/.scratch/mvp/issues/02-set-up-secrets-management.md b/.scratch/mvp/issues/02-set-up-secrets-management.md new file mode 100644 index 0000000..39904b8 --- /dev/null +++ b/.scratch/mvp/issues/02-set-up-secrets-management.md @@ -0,0 +1,15 @@ +# 02: Set Up Secrets Management + +**What to build:** Configure SOPS with age encryption for secrets. + +- Configure SOPS with age keys (generate key pair, set up SOPS CLI) +- Store age keys in Vaultwarden +- Add encrypted secrets file for initial configuration (DB passwords, API keys) + +**Blocked by:** None (can start immediately). + +**Status:** ready-for-agent + +- [ ] SOPS CLI is configured and working +- [ ] Age key pair is generated and stored in Vaultwarden +- [ ] Encrypted secrets file exists (e.g., `secrets.yaml.enc`) diff --git a/.scratch/mvp/issues/03-terraform:-provision-linode-infrastructure.md b/.scratch/mvp/issues/03-terraform:-provision-linode-infrastructure.md new file mode 100644 index 0000000..60def90 --- /dev/null +++ b/.scratch/mvp/issues/03-terraform:-provision-linode-infrastructure.md @@ -0,0 +1,15 @@ +# 03: Terraform: Provision Linode Infrastructure + +**What to build:** Provision Linode resources for HAPI MVP. + +- Provision Linode resources (VMs, PostgreSQL, Object Storage, LCR) +- Configure Kubernetes cluster with StatefulSet for PostgreSQL +- Set up networking (firewalls, IPs, DNS) + +**Blocked by:** 1, 2. + +**Status:** ready-for-agent + +- [ ] Linode resources are provisioned and accessible +- [ ] Kubernetes cluster is running with StatefulSet for PostgreSQL +- [ ] Networking is configured (firewalls, IPs, DNS) diff --git a/.scratch/mvp/issues/04-terraform:-provision-kubernetes-add-ons.md b/.scratch/mvp/issues/04-terraform:-provision-kubernetes-add-ons.md new file mode 100644 index 0000000..1b026f2 --- /dev/null +++ b/.scratch/mvp/issues/04-terraform:-provision-kubernetes-add-ons.md @@ -0,0 +1,15 @@ +# 04: Terraform: Provision Kubernetes Add-ons + +**What to build:** Deploy Kubernetes add-ons for observability and TLS. + +- Deploy Prometheus stack for metrics (optional, learnable) +- Deploy cert-manager for TLS certificates +- Deploy ingress controller (e.g., Traefik) + +**Blocked by:** 3. + +**Status:** ready-for-agent + +- [ ] Prometheus stack is deployed (metrics available) +- [ ] cert-manager is configured for TLS certificates +- [ ] Ingress controller is deployed and routing traffic diff --git a/.scratch/mvp/issues/05-fastapi:-build-application-skeleton.md b/.scratch/mvp/issues/05-fastapi:-build-application-skeleton.md new file mode 100644 index 0000000..bd77b72 --- /dev/null +++ b/.scratch/mvp/issues/05-fastapi:-build-application-skeleton.md @@ -0,0 +1,15 @@ +# 05: FastAPI: Build Application Skeleton + +**What to build:** Create the FastAPI application skeleton. + +- Create layered architecture (`models/`, `routers/`, `schemas/`, `services/`, `db/`) +- Add basic endpoints (root, health, version) +- Integrate with PostgreSQL (connection, session management) + +**Blocked by:** 1, 2, 3. + +**Status:** ready-for-agent + +- [ ] FastAPI app has layered structure (models, routers, schemas, services, db) +- [ ] Basic endpoints are working (root, health, version) +- [ ] PostgreSQL connection is established and tested diff --git a/.scratch/mvp/issues/06-fastapi:-add-authentication-module.md b/.scratch/mvp/issues/06-fastapi:-add-authentication-module.md new file mode 100644 index 0000000..1417ca8 --- /dev/null +++ b/.scratch/mvp/issues/06-fastapi:-add-authentication-module.md @@ -0,0 +1,15 @@ +# 06: FastAPI: Add Authentication Module + +**What to build:** Implement JWT authentication for the API. + +- Implement JWT authentication (token generation, validation, revocation) +- Add authentication middleware and dependency +- Store secrets (JWT secret, refresh token key) in SOPS + +**Blocked by:** 5. + +**Status:** ready-for-agent + +- [ ] JWT authentication is working (login, token refresh, logout) +- [ ] Authentication middleware is integrated into FastAPI +- [ ] JWT secrets are stored in SOPS and loaded at runtime diff --git a/.scratch/mvp/issues/07-fastapi:-add-rate-limiting-middleware.md b/.scratch/mvp/issues/07-fastapi:-add-rate-limiting-middleware.md new file mode 100644 index 0000000..0b6396d --- /dev/null +++ b/.scratch/mvp/issues/07-fastapi:-add-rate-limiting-middleware.md @@ -0,0 +1,15 @@ +# 07: FastAPI: Add Rate Limiting Middleware + +**What to build:** Add token-based rate limiting to the API. + +- Implement token-based rate limiting (in-memory, Redis-ready) +- Add rate limit headers and error responses +- Configure limits per environment (staging vs production) + +**Blocked by:** 6. + +**Status:** ready-for-agent + +- [ ] Rate limiting middleware is integrated into FastAPI +- [ ] Rate limit headers are included in responses +- [ ] Limits are configured per environment (staging vs production) diff --git a/.scratch/mvp/issues/08-fastapi:-add-structured-logging.md b/.scratch/mvp/issues/08-fastapi:-add-structured-logging.md new file mode 100644 index 0000000..48e4634 --- /dev/null +++ b/.scratch/mvp/issues/08-fastapi:-add-structured-logging.md @@ -0,0 +1,15 @@ +# 08: FastAPI: Add Structured Logging + +**What to build:** Implement structured JSON logging for the API. + +- Implement structured JSON logging (timestamps, levels, context fields) +- Add logging middleware for request context +- Configure log levels per environment + +**Blocked by:** 5. + +**Status:** ready-for-agent + +- [ ] Structured JSON logging is working (timestamps, levels, context) +- [ ] Logging middleware captures request context +- [ ] Log levels are configurable per environment diff --git a/.scratch/mvp/issues/09-fastapi:-integrate-ntfy-alerts.md b/.scratch/mvp/issues/09-fastapi:-integrate-ntfy-alerts.md new file mode 100644 index 0000000..113a5d4 --- /dev/null +++ b/.scratch/mvp/issues/09-fastapi:-integrate-ntfy-alerts.md @@ -0,0 +1,15 @@ +# 09: FastAPI: Integrate NTFY Alerts + +**What to build:** Integrate NTFY for real-time alerts. + +- Add NTFY client for sending error/warning notifications +- Add alert topics (e.g., "Database connection failures", "Upload failures") +- Configure alert severity and context (request ID, user ID) + +**Blocked by:** 5, 8. + +**Status:** ready-for-agent + +- [ ] NTFY client is integrated and sending alerts +- [ ] Alert topics are configured (database, uploads, auth) +- [ ] Alerts include severity and context (request ID, user ID) diff --git a/.scratch/mvp/issues/10-fastapi:-expand-health-endpoint.md b/.scratch/mvp/issues/10-fastapi:-expand-health-endpoint.md new file mode 100644 index 0000000..b5739c0 --- /dev/null +++ b/.scratch/mvp/issues/10-fastapi:-expand-health-endpoint.md @@ -0,0 +1,15 @@ +# 10: FastAPI: Expand Health Endpoint + +**What to build:** Expand the `/health` endpoint to include dependencies. + +- Add dependency checks to `/health` (DB, object storage) +- Add `/health/ready` and `/health/live` endpoints +- Add health check response format (status, dependencies, timestamp) + +**Blocked by:** 5, 8. + +**Status:** ready-for-agent + +- [ ] Health endpoint includes DB and object storage checks +- [ ] Health endpoints (`/health`, `/health/ready`, `/health/live`) are implemented +- [ ] Health response includes status, dependencies, and timestamp diff --git a/.scratch/mvp/issues/11-fastapi:-add-linode-object-storage-integration.md b/.scratch/mvp/issues/11-fastapi:-add-linode-object-storage-integration.md new file mode 100644 index 0000000..237104a --- /dev/null +++ b/.scratch/mvp/issues/11-fastapi:-add-linode-object-storage-integration.md @@ -0,0 +1,15 @@ +# 11: FastAPI: Add Linode Object Storage Integration + +**What to build:** Integrate Linode Object Storage for file uploads. + +- Integrate Linode Object Storage for uploads (upload, download, delete) +- Add upload endpoints with metadata (filename, size, type) +- Configure credentials via SOPS + +**Blocked by:** 3, 5, 8. + +**Status:** ready-for-agent + +- [ ] Linode Object Storage integration is working (upload, download, delete) +- [ ] Upload endpoints include metadata (filename, size, type) +- [ ] Linode credentials are stored in SOPS diff --git a/.scratch/mvp/issues/12-fastapi:-add-nextcloud-backup-integration.md b/.scratch/mvp/issues/12-fastapi:-add-nextcloud-backup-integration.md new file mode 100644 index 0000000..2366dda --- /dev/null +++ b/.scratch/mvp/issues/12-fastapi:-add-nextcloud-backup-integration.md @@ -0,0 +1,15 @@ +# 12: FastAPI: Add NextCloud Backup Integration + +**What to build:** Integrate NextCloud as secondary storage for uploads. + +- Integrate NextCloud as secondary storage for uploads +- Add mirror logic (upload to Linode, then sync to NextCloud) +- Add NextCloud-specific endpoints (e.g., health, sync status) + +**Blocked by:** 3, 5, 8. + +**Status:** ready-for-agent + +- [ ] NextCloud integration is working (upload, sync) +- [ ] Mirror logic uploads to Linode then syncs to NextCloud +- [ ] NextCloud-specific endpoints are available (health, sync status) diff --git a/.scratch/mvp/issues/13-fastapi:-add-pytest-tests.md b/.scratch/mvp/issues/13-fastapi:-add-pytest-tests.md new file mode 100644 index 0000000..6b51531 --- /dev/null +++ b/.scratch/mvp/issues/13-fastapi:-add-pytest-tests.md @@ -0,0 +1,16 @@ +# 13: FastAPI: Add Pytest Tests + +**What to build:** Set up Pytest tests for the API. + +- Set up Pytest with test database (`hapi_test`) +- Add tests for API endpoints (auth, health, uploads) +- Add tests for auth module (token generation, validation) +- Configure CI to run tests (pytest + coverage) + +**Blocked by:** 5, 8. + +**Status:** ready-for-agent + +- [ ] Pytest is configured with test database +- [ ] Tests cover API endpoints (auth, health, uploads) +- [ ] Tests cover auth module (token generation, validation) diff --git a/.scratch/mvp/issues/14-docker-compose:-configure-local-development-stack.md b/.scratch/mvp/issues/14-docker-compose:-configure-local-development-stack.md new file mode 100644 index 0000000..0dad85a --- /dev/null +++ b/.scratch/mvp/issues/14-docker-compose:-configure-local-development-stack.md @@ -0,0 +1,15 @@ +# 14: Docker Compose: Configure Local Development Stack + +**What to build:** Configure Docker Compose for local development. + +- Set up Docker Compose for local stack (FastAPI, PostgreSQL, Adminer) +- Configure hot reload for FastAPI (volume mounts, `uvicorn --reload`) +- Add optional Redis for caching (ready for rate limiting expansion) + +**Blocked by:** 1, 2, 5. + +**Status:** ready-for-agent + +- [ ] Docker Compose stack is running (FastAPI, PostgreSQL, Adminer) +- [ ] FastAPI has hot reload configured (volume mounts, uvicorn --reload) +- [ ] Optional Redis is available for caching diff --git a/.scratch/mvp/issues/15-ci/cd:-set-up-gitea-actions-pipeline.md b/.scratch/mvp/issues/15-ci/cd:-set-up-gitea-actions-pipeline.md new file mode 100644 index 0000000..710d88f --- /dev/null +++ b/.scratch/mvp/issues/15-ci/cd:-set-up-gitea-actions-pipeline.md @@ -0,0 +1,16 @@ +# 15: CI/CD: Set Up Gitea Actions Pipeline + +**What to build:** Set up Gitea Actions CI/CD pipeline. + +- Configure Gitea Actions with act_runner for local execution +- Add build workflow (Docker buildx, push to LCR) +- Add test workflow (pytest, coverage report) +- Add deploy workflow (Kubernetes apply, staging auto, prod on tag) + +**Blocked by:** 1, 2, 3, 11, 12. + +**Status:** ready-for-agent + +- [ ] Gitea Actions is configured with act_runner +- [ ] Build workflow runs (Docker buildx, push to LCR) +- [ ] Test workflow runs (pytest, coverage report) diff --git a/MVP-TICKETS.md b/MVP-TICKETS.md new file mode 100644 index 0000000..be87160 --- /dev/null +++ b/MVP-TICKETS.md @@ -0,0 +1,112 @@ +# HAPI MVP Tickets + +This document outlines the tickets for the HAPI MVP, broken into tracer-bullet vertical slices. + +## Prefactoring Tickets + +1. **Initialize Repository Structure** + - Create `.gitignore`, `pyproject.toml`, `docker-compose.yml`, `Makefile` + - Set up basic folder structure for FastAPI app (`models/`, `routers/`, `schemas/`, `services/`, `db/`) + - Add CI/CD configuration files (`.gitea/`, `.github/`) + - **Blocked by**: None + +2. **Set Up Secrets Management** + - Configure SOPS with age keys (generate key pair, set up SOPS CLI) + - Store age keys in Vaultwarden + - Add encrypted secrets file for initial configuration (DB passwords, API keys) + - **Blocked by**: None + +--- + +## Tracer Bullet Tickets + +### 3. **Terraform: Provision Linode Infrastructure** + - Provision Linode resources (VMs, PostgreSQL, Object Storage, LCR) + - Configure Kubernetes cluster with StatefulSet for PostgreSQL + - Set up networking (firewalls, IPs, DNS) + - **Blocked by**: 1, 2 + +### 4. **Terraform: Provision Kubernetes Add-ons** + - Deploy Prometheus stack for metrics (optional, learnable) + - Deploy cert-manager for TLS certificates + - Deploy ingress controller (e.g., Traefik) + - **Blocked by**: 3 + +### 5. **FastAPI: Build Application Skeleton** + - Create layered architecture (`models/`, `routers/`, `schemas/`, `services/`, `db/`) + - Add basic endpoints (root, health, version) + - Integrate with PostgreSQL (connection, session management) + - **Blocked by**: 1, 2, 3 + +### 6. **FastAPI: Add Authentication Module** + - Implement JWT authentication (token generation, validation, revocation) + - Add authentication middleware and dependency + - Store secrets (JWT secret, refresh token key) in SOPS + - **Blocked by**: 5 + +### 7. **FastAPI: Add Rate Limiting Middleware** + - Implement token-based rate limiting (in-memory, Redis-ready) + - Add rate limit headers and error responses + - Configure limits per environment (staging vs production) + - **Blocked by**: 6 + +### 8. **FastAPI: Add Structured Logging** + - Implement structured JSON logging (timestamps, levels, context fields) + - Add logging middleware for request context + - Configure log levels per environment + - **Blocked by**: 5 + +### 9. **FastAPI: Integrate NTFY Alerts** + - Add NTFY client for sending error/warning notifications + - Add alert topics (e.g., "Database connection failures", "Upload failures") + - Configure alert severity and context (request ID, user ID) + - **Blocked by**: 5, 8 + +### 10. **FastAPI: Expand Health Endpoint** + - Add dependency checks to `/health` (DB, object storage) + - Add `/health/ready` and `/health/live` endpoints + - Add health check response format (status, dependencies, timestamp) + - **Blocked by**: 5, 8 + +### 11. **FastAPI: Add Linode Object Storage Integration** + - Integrate Linode Object Storage for uploads (upload, download, delete) + - Add upload endpoints with metadata (filename, size, type) + - Configure credentials via SOPS + - **Blocked by**: 3, 5, 8 + +### 12. **FastAPI: Add NextCloud Backup Integration** + - Integrate NextCloud as secondary storage for uploads + - Add mirror logic (upload to Linode, then sync to NextCloud) + - Add NextCloud-specific endpoints (e.g., health, sync status) + - **Blocked by**: 3, 5, 8 + +### 13. **FastAPI: Add Pytest Tests** + - Set up Pytest with test database (`hapi_test`) + - Add tests for API endpoints (auth, health, uploads) + - Add tests for auth module (token generation, validation) + - Configure CI to run tests (pytest + coverage) + - **Blocked by**: 5, 8 + +### 14. **Docker Compose: Configure Local Development Stack** + - Set up Docker Compose for local stack (FastAPI, PostgreSQL, Adminer) + - Configure hot reload for FastAPI (volume mounts, `uvicorn --reload`) + - Add optional Redis for caching (ready for rate limiting expansion) + - **Blocked by**: 1, 2, 5 + +### 15. **CI/CD: Set Up Gitea Actions Pipeline** + - Configure Gitea Actions with act_runner for local execution + - Add build workflow (Docker buildx, push to LCR) + - Add test workflow (pytest, coverage report) + - Add deploy workflow (Kubernetes apply, staging auto, prod on tag) + - **Blocked by**: 1, 2, 3, 11, 12 + +--- + +## Notes + +- Tickets are ordered by dependency (blockers first). +- Each ticket is a vertical slice covering multiple layers (infrastructure, API, tests, CI/CD). +- Prefactoring tickets enable later work but aren't strictly blocking. +- Terraform is split into two tickets (Infrastructure + Add-ons) for better focus. +- Observability (ticket 8) is now split into three separate vertical tickets (logging, NTFY, health endpoint). +- File upload support (ticket 9) is split into Linode and NextCloud tickets for clearer scope.