Thank you for your interest in contributing!
-
Fork and clone the repository
git clone https://github.com/yourusername/maintainer-brief-backend.git cd maintainer-brief-backend -
Install dependencies
npm install
-
Set up environment
cp .env.example .env # Fill in your credentials -
Run migrations
npm run build npm run migrate
-
Start development server
npm run dev
src/
├── config/ # Environment configuration
├── db/ # Database client & migrations
├── auth/ # Authentication & authorization
├── github/ # GitHub API integration
├── ai/ # OpenAI integration & prompts
├── analysis/ # Analysis pipeline
├── queue/ # Job queue (BullMQ)
├── notifications/ # Email & Slack
├── scheduler/ # Automated runs
├── routes/ # API endpoints
├── utils/ # Utilities
└── __tests__/ # Unit tests
We use ESLint and Prettier for consistent code formatting:
# Check linting
npm run lint
# Format code
npm run format# Run all tests
npm test
# Run tests in watch mode
npm test:watch
# Run specific test file
npm test -- auth.test.ts-
Create a feature branch
git checkout -b feature/your-feature-name
-
Make your changes
- Write clean, readable code
- Add tests for new features
- Update documentation if needed
-
Run tests
npm test npm run lint -
Commit your changes
git add . git commit -m "feat: add your feature description"
We follow Conventional Commits:
feat:New featurefix:Bug fixdocs:Documentation changestest:Test changesrefactor:Code refactoringchore:Maintenance tasks
-
Push and create PR
git push origin feature/your-feature-name
- Keep PRs focused on a single feature/fix
- Write clear PR descriptions
- Link related issues
- Ensure all tests pass
- Request review from maintainers
- Create route handler in
src/routes/ - Add authentication with
requireAuth() - Add input validation with Zod schema
- Add ownership checks if needed
- Write tests in
src/__tests__/ - Update
API_EXAMPLES.md
Example:
// src/routes/example.ts
import { FastifyInstance } from 'fastify';
import { requireAuth } from '../auth/middleware';
import { schemas } from '../utils/validation';
export default async function exampleRoutes(fastify: FastifyInstance) {
fastify.get('/example', requireAuth(), async (request, reply) => {
// Your logic here
return reply.send({ success: true });
});
}- Add type to database schema
- Create prompt builder in
src/ai/prompts.ts - Update
generateAllOutputs()insrc/ai/generator.ts - Add tests for prompt structure
- Update documentation
- Create queue in
src/queue/jobs.ts - Add processor in
src/queue/worker.ts - Add enqueue function
- Add error handling
- Write tests
- Create new migration file in
src/db/migrations/ - Use sequential numbering (e.g.,
002_add_feature.sql) - Include both
UPandDOWNmigrations - Test on a copy of production data
- Document breaking changes
- Never commit secrets or tokens
- Use encryption for sensitive data
- Validate all user input
- Implement proper authentication
- Follow principle of least privilege
- Use database indexes appropriately
- Implement caching where beneficial
- Optimize GitHub API calls
- Monitor OpenAI token usage
- Profile slow endpoints
Update documentation when:
- Adding new features
- Changing API contracts
- Modifying configuration
- Adding new environment variables
- Changing deployment process
Files to update:
README.md- Overview and quick startAPI_EXAMPLES.md- API usage examplesDEPLOYMENT.md- Deployment instructions- Code comments - Complex logic
- Open an issue for bugs
- Start a discussion for feature requests
- Join our Discord for chat
By contributing, you agree that your contributions will be licensed under the MIT License.