Technical Architecture
Technical architecture of the ID Generator service — async stack, database design, concurrency patterns, and Kubernetes deployment.
Project structure
id-generator/
├── config/
│ └── default.yaml # Default configuration
├── src/
│ └── id_generator/
│ ├── main.py # FastAPI app entry point
│ ├── config.py # Pydantic Settings (YAML + env vars)
│ ├── db.py # Async SQLAlchemy engine
│ ├── models.py # Table creation (table-per-ID-type)
│ ├── api/
│ │ ├── router.py # API endpoints
│ │ └── schema.py # Response envelope
│ ├── generator/
│ │ ├── engine.py # ID generation pipeline
│ │ ├── filters.py # 10 filter implementations
│ │ └── verhoeff.py # Verhoeff checksum
│ └── pool/
│ ├── manager.py # Background replenishment
│ └── issuer.py # Issue & mark TAKEN
├── tests/ # Integration test suite
├── charts/ # Helm chart
├── Dockerfile
└── pyproject.tomlDatabase design
Table-per-ID-type strategy
Why table-per-ID-type
Aspect
Single table
Table-per-ID-type (chosen)
Issuing IDs — concurrency-safe path
SQL pattern
Why FOR UPDATE SKIP LOCKED
FOR UPDATE SKIP LOCKEDDeadlock retry
Pool replenishment
Background task
Why PostgreSQL advisory locks
Sub-batch insertion
ID generation pipeline
Startup behaviour
Kubernetes deployment
Probes
Probe
Endpoint
Purpose
Key architectural decisions
#
Decision
Choice
Rationale
Last updated
Was this helpful?

