diff --git a/PROJECT_PLAN.md b/PROJECT_PLAN.md index fba7f66..b1f848d 100644 --- a/PROJECT_PLAN.md +++ b/PROJECT_PLAN.md @@ -30,11 +30,11 @@ A lightweight Go service that: ## Tech Stack - **Language**: Go -- **Database**: SQLite (local cache) - **Source DB**: Gitea MySQL (read-only, same docker network) - **HTTP**: Standard library `net/http` - **Deployment**: Docker + Docker Compose on vps.git - **API Key**: Rotates every 10 minutes, stored in Docker volume at `/data/api-key` +- **Cache**: In-memory map (repo_id → Repo), refreshed every 5h + webhook updates ## Authentication @@ -97,16 +97,20 @@ Returns `{"status": "ok"}`. ## Data Model -### SQLite cache table: `repos` +### In-memory cache: `map[int64]*Repo` -| Column | Type | Notes | -|--------------|---------|------------------------------| -| id | INTEGER | Gitea repo ID (primary key) | -| name | TEXT | | -| owner | TEXT | Gitea username of owner | -| is_private | INTEGER | 0 or 1 | -| url | TEXT | Full .git HTTPS URL | -| updated_at | INTEGER | Unix timestamp of last sync | +```go +type Repo struct { + ID int64 + Name string + Owner string + IsPrivate bool + URL string +} +``` + +Cached in a `sync.RWMutex`-protected map keyed by Gitea repo ID. +Refreshed on startup, every 5 hours, and on webhook events. ## Configuration @@ -118,8 +122,6 @@ Environment variables: | `DB_USER` | `root` | MySQL username | | `DB_PASS` | — | MySQL password | | `DB_NAME` | `giteadb` | MySQL database name | -| `SQLITE_PATH` | `/data/cache.db` | SQLite file path | -| `API_KEY_FILE` | `/data/api-key` | Path for rotating api-key | | `WEBHOOK_SECRET` | — | Gitea webhook secret token | | `PORT` | `8080` | HTTP listen port | @@ -150,11 +152,9 @@ services: DB_USER: root DB_PASS: ${MYSQL_ROOT_PASSWORD} DB_NAME: giteadb - SQLITE_PATH: /data/cache.db WEBHOOK_SECRET: ${GITEA_WEBHOOK_SECRET} PORT: 8080 volumes: - - ./gitea-custom-api/data:/data - ./gitea-custom-api/api-key:/data/api-key networks: - git-network