Backend Development Guide¶
Purpose
This guide defines the expected workflow for building backend features and endpoints in a consistent, review-friendly way using our modern stack.
Workflow (Red-Green-Refactor)¶
- Sync: Pull latest from
devand create a feature branch. - Service: Identify the owner (NestJS Core or FastAPI Solver).
- Red: Write a failing unit/integration test in Jest or pytest.
- Green: Implement the logic. Use PGLite for ephemeral DB tests.
- Refactor: Clean up the code while keeping tests green.
- Swagger: Update or create the required API definitions.
- PR: Open a PR into
devonce local checks pass.
Backend Technology Stack¶
Definition of Done¶
Backend Checklist
- [ ] Work is isolated in a feature branch.
- [ ] Swagger definitions are complete and tested.
- [ ] Unit and Integration tests are passed.
- [ ] Drizzle migrations are generated and tested.
- [ ] CI passes successfully.
- [ ] Code follows the Core-and-Adapter pattern.
Database Strategy¶
Use Drizzle for all core entity management. Ensure schemas are located in packages/database/schema.
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
email: text('email').unique().notNull(),
});
Use PGLite for lightning-fast, isolated unit tests. No Docker required.
pnpm run test:pglite