3.8 KiB
3.8 KiB
Contributing Guide
This guide helps developers (and AI assistants) understand how to contribute to this project.
Development Setup
-
Clone the repository
git clone <repository-url> cd bot-with-admin-starter -
Set up environment
cp .env.example .env # Edit .env with your values -
Start development environment
docker compose -f compose.dev.yml up -d -
Create super admin
docker exec -it ${PROJECT_NAME}_back sh pnpm console admin create {username} {email} -
Start frontend
cd front npm install npm run dev
Code Style
TypeScript
- Use strict typing - avoid
any - Prefer interfaces over types
- Use enums for fixed sets
- Always define return types
- Add JSDoc for public APIs
NestJS Backend
- Follow module structure: Controller → Service → Repository
- Use DTOs with class-validator
- Services contain business logic, controllers handle HTTP
- Use dependency injection
- Use guards for auth
- Use interceptors for response transformation
React Frontend
- Functional components with hooks
- React Query for API calls
- Zod schemas for validation
- Mantine components consistently
- TypeScript paths (@/*) for imports
Adding a New Feature
Backend
-
Create entity
# File: back/src/feature/entities/feature.entity.tsimport { Entity, Column } from 'typeorm'; import { AbstractEntity } from 'src/common/entities/abstract.entity'; @Entity('features') export class Feature extends AbstractEntity { @Column() name: string; } -
Create DTOs
# Files: back/src/feature/dto/create-feature.dto.ts # back/src/feature/dto/update-feature.dto.ts -
Create service
# File: back/src/feature/feature.service.ts -
Create controller
# File: back/src/feature/feature.controller.ts -
Create module
# File: back/src/feature/feature.module.ts -
Register in AppModule
// back/src/app.module.ts imports: [ // ... FeatureModule, ] -
Generate migration
cd back pnpm migration:generate --name=create-feature
Frontend
-
Create Zod schemas
# File: front/src/api/dtos/feature.ts -
Create API hooks
# File: front/src/hooks/api/feature.ts -
Create page component
# File: front/src/pages/feature/index.tsx -
Add route
// front/src/routes/index.tsx { path: '/feature', element: <FeaturePage />, }
Git Workflow
-
Create feature branch
git checkout -b feature/my-feature -
Make changes
- Write code following style guide
- Add tests if applicable
- Update documentation
-
Commit changes
git commit -m "feat: add new feature"Use conventional commits:
feat:New featurefix:Bug fixdocs:Documentationstyle:Formattingrefactor:Code refactoringtest:Testschore:Maintenance
-
Push and create PR
git push origin feature/my-feature
Testing
Backend
cd back
pnpm test
pnpm test:e2e
Frontend
cd front
npm run test
Code Review Checklist
- Code follows style guide
- Tests pass
- Documentation updated
- No console.logs or debug code
- Environment variables documented
- Migration files created for schema changes
- JSDoc comments added for public APIs
Questions?
- Check
.cursorrulesfor code conventions - See
AGENTS.mdfor architecture details - See
EXAMPLES.mdfor code examples