Infrastructure and DevOps
Infrastructure and DevOps
Relevant source files
The following files were used as context for generating this wiki page:
This section provides a high-level overview of the infrastructure stack, deployment orchestration, and the development lifecycle management for the Primebrick backend. The system relies on Docker for service isolation, a strict GitFlow branching model for stability, and automated version synchronization to ensure consistency between the codebase and git tags.
Infrastructure Stack
The Primebrick backend utilizes a containerized infrastructure managed via Docker Compose. The stack is designed for local development and consistent staging environments, providing the necessary data persistence and service discovery for the API.
Service Overview
The primary infrastructure components are defined in infra/docker-compose.postgres.yml:
- PostgreSQL 18: The primary relational database. It includes a custom entrypoint to install
pg_partmanfor partition management infra/docker-compose.postgres.yml:30-52. - Casdoor: An open-source Identity and Access Management (IAM) solution. It handles authentication and OIDC discovery infra/docker-compose.postgres.yml:60-84.
- NATS: A high-performance messaging system used for internal communication and JetStream persistence infra/docker-compose.postgres.yml:86-100.
Component Relationship Diagram
The following diagram illustrates how the infrastructure services interact with the API and the persistence layers.
Infrastructure Service Map
Code
Sources: infra/docker-compose.postgres.yml:29-112, AGENTS.md:30-31
For details on service configuration, named volumes, and the Casdoor bootstrap process, see Docker Infrastructure and Casdoor Setup.
DevOps and Development Lifecycle
The project follows a disciplined DevOps approach to ensure code quality and versioning integrity. This includes a strict branching strategy and automated hooks that maintain the database state and package versions.
GitFlow and Versioning
The repository adheres to the GitFlow model docs/gitflow.md:1-4.
- Feature Branches:
feature/<slug>branched fromdevelopdocs/gitflow.md:19. - Release Branches:
release/<version>branched fromdevelopfor version bumps docs/gitflow.md:20. - Hotfix Branches:
hotfix/<version>branched frommainfor critical fixes docs/gitflow.md:21.
Version management is automated via version-sync.mjs, which ensures that package.json reflects the branch name and latest git tags docs/gitflow.md:48-54.
Automation Hooks
- Post-Merge Hook: Automatically triggers
pnpm run db:migrateto keep the local database schema aligned with the latest patches AGENTS.md:63-64. - Pre-Commit Constraints: AI agents are strictly prohibited from committing automatically without explicit user instruction AGENTS.md:3-9.
Workflow State Diagram
Code
Sources: docs/gitflow.md:16-45, AGENTS.md:65-70
For details on the branching rules, versioning logic, and operational constraints for AI agents, see GitFlow, Versioning, and CI Hooks.
API Documentation
The backend exposes its capabilities through an OpenAPI 3.0.3 specification. This documentation is served dynamically and provides a contract for frontend integration and external client development.
- Endpoint: The specification is typically served via the
openApiRouter. - Scope: Covers all entity operations (Customer, Organization) and Authentication endpoints src/openapi/openapi.ts:7-203.
For details on the OpenAPI schema, available routes, and integration patterns, see OpenAPI Documentation.
Child Pages
- Docker Infrastructure and Casdoor Setup: Deep dive into the
docker-composeservices and thesetup-casdoor.tsautomation. - GitFlow, Versioning, and CI Hooks: Comprehensive guide to the branching strategy,
version-sync.mjs, and git hooks. - OpenAPI Documentation: Technical reference for the OpenAPI spec and its implementation in the codebase.