๐ ๏ธ Development Workflow¶
This document outlines the engineering standards and workflows for contributing to the AI Audience Builder.
๐ค The Shared Contract Workflow¶
Because this is a monorepo with high type-safety requirements, you must follow the Shared Contract Workflow when modifying data structures.
- Modify the Contract: Update the interfaces in
packages/shared/src/index.ts. - Synchronize: Run
pnpm buildfrom the root. This ensures that the types are compiled and available to bothapps/backendandapps/frontend. - Implement: Update the backend service and then the frontend component.
[!WARNING] Do not define DTOs locally. If a data structure is used in an API request or response, it MUST reside in
@audience-builder/shared.
๐๏ธ Backend Engineering Standards¶
Modular Monolith Structure¶
Each feature should be encapsulated in a module under apps/backend/src/modules/.
*.module.ts: NestJS module definition.*.controller.ts: API route handlers.*.service.ts: Business logic (Keep controllers thin).*.dto.ts: Local DTOs (only if they don't cross the network boundary).
Error Handling¶
Use the shared ErrorKeys from the shared package to ensure the frontend can provide localized or user-friendly error messages.
๐จ Frontend Engineering Standards¶
Design System¶
We use Tailwind CSS v4. Avoid using ad-hoc CSS classes; stick to the design system tokens defined in index.css.
State Management¶
- Local State:
useState/useReducerfor component-level UI state. - Global State: React Context for user sessions and global settings.
- Persistent State: Use URL search parameters for filters, search queries, and selected items.
๐งน Hygiene & Quality Gates¶
This project enforces strict quality gates via Lefthook and git-hygiene.
- Linting: All code must pass
pnpm lint. - Formatting: Code must be formatted with Prettier via
pnpm format. - Types: No
anytypes allowed. Runpnpm check-typesto verify workspace-wide type safety.
Commit Messages¶
We follow Conventional Commits:
feat:New featurefix:Bug fixdocs:Documentation changeschore:Maintenance tasks
๐งช Testing Strategy¶
- Unit Tests: Place
.spec.tsfiles alongside the source code. Focus on testing business logic in services. - Integration Tests: Focus on API endpoints and database interactions.
- E2E Tests: Use the
test:e2ecommand in the backend to verify the full request-response lifecycle.
๐ CI/CD & Deployment¶
We use GitHub Actions to automate our documentation deployment.
๐ Docs Pipeline (docs.yml)¶
Automatically builds the MkDocs site and deploys it to GitHub Pages whenever changes are merged into the main branch.