Handheld Devices
A microservices stack for managing handheld gaming device catalog data. Built with Lua (API + worker), Deno/Alpine.js (frontend), PostgreSQL, and Redis.
Architecture
| Service |
Tech |
Port |
Description |
| API |
Lua 5.4 |
8080 |
REST API for devices CRUD |
| Worker |
Lua 5.4 |
— |
Consumes events from Redis queue |
| Frontend |
Deno + Alpine.js + Oak |
8090 |
Web UI |
| PostgreSQL |
15-alpine |
5432 |
Primary data store |
| Redis |
7-alpine |
6379 |
Event queue and caching |
The API publishes domain events to Redis on create/update/delete. The worker consumes from the queue and can fan out to external systems. The frontend serves static assets and proxies API requests with CORS and CSP.
Quick Start
Development
Prerequisites
- Docker + Docker Compose - for running the stack
- Lua 5.4 + LuaRocks - for API/worker local dev and tests
- Deno 2.x - for frontend local dev
Install Dependencies
Per-Service Commands
| Service |
Directory |
Commands |
| API |
devices-api/ |
make deps, make test, make lint, make run |
| Worker |
devices-worker/ |
make deps, make lint, make run |
| Frontend |
frontend/ |
make run, make lint |
API Reference
| Method |
Path |
Description |
| GET |
/devices |
List devices (paginated) |
| POST |
/devices |
Create device |
| GET |
/devices/:id |
Get device |
| PUT |
/devices/:id |
Update device |
| DELETE |
/devices/:id |
Delete device |
| GET |
/health/ready |
Readiness (DB + Redis) |
| GET |
/health/live |
Liveness |
Makefile Targets (from root)
| Target |
Description |
make install-deps |
Install all local dev deps |
make dev |
Start all services |
make down |
Stop all services |
make build |
Build Docker images |
make test |
Run API unit tests |
make lint |
Luacheck + Deno check |
make logs |
Follow API logs |
make logs-worker |
Follow worker logs |
make init-db |
Run DB migrations manually |
make shell-postgres |
psql in Postgres container |
make status |
Container status |
Deployment
Configuration
Copy .env.example to .env. Key variables:
DB_* - PostgreSQL connection
REDIS_* - Redis connection
API_URL - API URL used by the frontend (for browser requests)