|
| 1 | +# Contributing to Team Flow |
| 2 | + |
| 3 | +Thanks for contributing. |
| 4 | + |
| 5 | +This document defines contribution workflow, quality standards, and testing rules for this monorepo. |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +- [Prerequisites](#prerequisites) |
| 10 | +- [Local Setup](#local-setup) |
| 11 | +- [Branching and Commits](#branching-and-commits) |
| 12 | +- [Coding Standards](#coding-standards) |
| 13 | +- [Testing Policy](#testing-policy) |
| 14 | +- [Database and Prisma Rules](#database-and-prisma-rules) |
| 15 | +- [Pull Request Rules](#pull-request-rules) |
| 16 | +- [Definition of Done](#definition-of-done) |
| 17 | +- [Security and Secrets](#security-and-secrets) |
| 18 | +- [License](#license) |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- Node.js 22+ |
| 23 | +- pnpm 10+ |
| 24 | +- PostgreSQL (local or remote) |
| 25 | + |
| 26 | +## Local Setup |
| 27 | + |
| 28 | +1. Install dependencies: |
| 29 | + |
| 30 | +```bash |
| 31 | +pnpm install |
| 32 | +``` |
| 33 | + |
| 34 | +2. Create environment files: |
| 35 | + |
| 36 | +```bash |
| 37 | +cp apps/api/.env.example apps/api/.env |
| 38 | +cp apps/web/.env.local.example apps/web/.env.local |
| 39 | +``` |
| 40 | + |
| 41 | +3. Prepare DB: |
| 42 | + |
| 43 | +```bash |
| 44 | +pnpm --filter api prisma:generate |
| 45 | +pnpm --filter api prisma:migrate |
| 46 | +``` |
| 47 | + |
| 48 | +4. Run all apps: |
| 49 | + |
| 50 | +```bash |
| 51 | +pnpm dev |
| 52 | +``` |
| 53 | + |
| 54 | +## Branching and Commits |
| 55 | + |
| 56 | +- Branch from latest `main`. |
| 57 | +- Branch naming: |
| 58 | + - `feature/<scope>` |
| 59 | + - `fix/<scope>` |
| 60 | + - `chore/<scope>` |
| 61 | +- Keep commits atomic and logically grouped. |
| 62 | +- Use clear, outcome-based commit messages. |
| 63 | +- Do not mix unrelated refactors with functional changes. |
| 64 | + |
| 65 | +## Coding Standards |
| 66 | + |
| 67 | +- Use TypeScript across apps/packages. |
| 68 | +- Reuse contracts from `@repo/types`. |
| 69 | +- Reuse shared primitives from `@repo/ui` where possible. |
| 70 | +- Keep server actions typed and return predictable error/data contracts. |
| 71 | +- Keep Nest modules cohesive and guarded at route boundaries. |
| 72 | +- Prefer explicit, maintainable implementations over quick workarounds. |
| 73 | + |
| 74 | +## Testing Policy |
| 75 | + |
| 76 | +Testing is mandatory for behavior changes. |
| 77 | + |
| 78 | +### Required checks before PR |
| 79 | + |
| 80 | +From repo root: |
| 81 | + |
| 82 | +```bash |
| 83 | +pnpm lint |
| 84 | +pnpm test |
| 85 | +pnpm build |
| 86 | +``` |
| 87 | + |
| 88 | +### App-level expectations |
| 89 | + |
| 90 | +- API (`apps/api`, Jest): |
| 91 | + - Add/update unit tests for service and guard logic changes. |
| 92 | + - Add/update integration tests for route-contract or auth-flow changes. |
| 93 | +- Web (`apps/web`, Vitest): |
| 94 | + - Add/update tests for server actions and utility logic changes. |
| 95 | + - Add/update integration tests for page/action flows when behavior changes. |
| 96 | + |
| 97 | +### Test quality rules |
| 98 | + |
| 99 | +- Tests must be deterministic (no flaky timing dependencies). |
| 100 | +- Avoid network calls in unit tests; mock external dependencies. |
| 101 | +- Keep assertions specific to behavior, not implementation noise. |
| 102 | +- New features should include at least one positive-path and one failure-path test. |
| 103 | + |
| 104 | +### Running targeted tests |
| 105 | + |
| 106 | +```bash |
| 107 | +pnpm --filter api test |
| 108 | +pnpm --filter web test |
| 109 | +``` |
| 110 | + |
| 111 | +## Database and Prisma Rules |
| 112 | + |
| 113 | +When changing `apps/api/prisma/schema.prisma`: |
| 114 | + |
| 115 | +- Generate migration with meaningful name: |
| 116 | + |
| 117 | +```bash |
| 118 | +pnpm --filter api prisma:migrate |
| 119 | +``` |
| 120 | + |
| 121 | +- Validate and regenerate client: |
| 122 | + |
| 123 | +```bash |
| 124 | +pnpm --filter api prisma:validate |
| 125 | +pnpm --filter api prisma:generate |
| 126 | +``` |
| 127 | + |
| 128 | +- Update seed data if required by new schema constraints. |
| 129 | +- Include migration impact notes in the PR description. |
| 130 | + |
| 131 | +## Pull Request Rules |
| 132 | + |
| 133 | +Each PR should include: |
| 134 | + |
| 135 | +- Clear summary and scope |
| 136 | +- Why the change is needed |
| 137 | +- Testing evidence (commands run + result) |
| 138 | +- Migration notes (if DB changed) |
| 139 | +- Screenshots/GIFs for user-facing UI changes |
| 140 | + |
| 141 | +Keep PRs reviewable: |
| 142 | + |
| 143 | +- Prefer smaller PRs |
| 144 | +- Avoid unrelated formatting churn |
| 145 | +- Resolve review comments with follow-up commits |
| 146 | + |
| 147 | +## Definition of Done |
| 148 | + |
| 149 | +A change is considered done when: |
| 150 | + |
| 151 | +- Code is implemented and reviewed |
| 152 | +- Relevant tests are added/updated |
| 153 | +- `pnpm lint`, `pnpm test`, and `pnpm build` pass |
| 154 | +- No secrets or local env files are committed |
| 155 | +- Documentation is updated when behavior/setup changes |
| 156 | + |
| 157 | +## Security and Secrets |
| 158 | + |
| 159 | +- Never commit `.env`, `.env.local`, tokens, secrets, or credentials. |
| 160 | +- Redact sensitive values in logs and screenshots. |
| 161 | +- Report security concerns privately to maintainers. |
| 162 | + |
| 163 | +## License |
| 164 | + |
| 165 | +By contributing, you agree that contributions are licensed under the |
| 166 | +[MIT License](./LICENSE). |
0 commit comments