Files
hapi/GLOSSARY.md
T

86 lines
3.1 KiB
Markdown

# HAPI Glossary
## Core Concepts
### API
The central service exposing HTTP endpoints for clients (humans, bots, frontend). Built with FastAPI, providing REST endpoints, JSON logs, and health checks.
### Environment
An instance of the API serving requests. **Staging** mirrors production for testing; **Production** serves real users. Each has its own PostgreSQL database.
### Migration
A versioned change to the database schema, managed by Alembic. Migrations are additive by default, with destructive changes behind flags.
### Secret
A sensitive value (password, API key, token) stored encrypted. Managed via SOPS with age encryption, committed to Git alongside code.
### Object Storage
A service for storing files (uploads, assets). We use Linode Object Storage as primary, with NextCloud as a backup destination.
### Health Check
An endpoint (`/health`) that reports the API's operational status and dependency health (DB, object storage, etc.).
### Alert
A notification sent to NTFY when an error or warning occurs. Includes severity, context, and details for quick triage.
## Modules
### Auth Module
Handles user authentication via JWT tokens. Supports token-based rate limiting; extensible for OAuth2 and API keys.
### Router Module
API endpoints grouped by domain (users, items, etc.). Each router is a self-contained module with its own schemas and service calls.
### Schema Module
Pydantic models defining request/response shapes. Separated from routers to enable reuse and testing.
### Service Module
Business logic separated from HTTP concerns. Services are testable in isolation and called by routers.
### DB Module
Database connection and utility functions. Includes session management, connection pooling, and migration orchestration.
## Infrastructure
### Kubernetes Cluster
Self-hosted Kubernetes for production and staging deployments. Uses StatefulSet for PostgreSQL.
### Terraform
Infrastructure as code for Linode resources (VMs, PostgreSQL, Object Storage, LCR).
### Gitea CI/CD
Automated workflows for building, testing, and deploying the API. Uses act_runner for GitHub Actions-compatible workflows.
### Docker Compose
Local development environment with FastAPI, PostgreSQL, and Adminer.
## Observability
### Structured Logging
JSON-formatted logs for structured querying and analysis. Each log entry includes timestamp, level, message, and context.
### UptimeKuma
Monitoring service that polls `/health` endpoint to track API availability.
### NTFY
Push notification service for alerts. API sends error/warning notifications with configurable topics.
## Deployment
### Rollout
Deployment of a new API version to an environment. Uses Kubernetes rolling updates for zero-downtime.
### Tagging
Version tags (e.g., `v1.0.0`) trigger production deployments. Staging deploys from `main` branch.
## Future Considerations
### WebSockets
Real-time communication layer for frontend. Not included in MVP; ready for later addition.
### GraphQL
Alternative query layer for complex frontend queries. Not included in MVP; REST is sufficient initially.
### NextCloud Backup
Secondary storage for uploads, mirroring Linode Object Storage to NextCloud for redundancy.