Skip to content

Commit f36fa31

Browse files
Merge pull request #14 from codebuilderinc/copilot/setup-copilot-instructions
Add .github/copilot-instructions.md
2 parents 740b308 + b39ddf4 commit f36fa31

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

.github/copilot-instructions.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# Copilot Instructions for codebuilder-api
2+
3+
## Project Overview
4+
5+
This is **codebuilder-api**, a NestJS backend API built with TypeScript. It uses Prisma as the ORM (schema maintained in a Git submodule at `prisma/`), Redis for caching and queues, PostgreSQL for the database, and is deployed via Docker.
6+
7+
## Tech Stack
8+
9+
- **Runtime:** Node.js v22 with pnpm as the package manager
10+
- **Framework:** NestJS 11 with Express adapter
11+
- **Language:** TypeScript (ES2023 target, ESNext modules, bundler resolution)
12+
- **ORM:** Prisma with auto-generated DTOs via `@vegardit/prisma-generator-nestjs-dto`
13+
- **Build:** SWC compiler (configured in `nest-cli.json`)
14+
- **Testing:** Jest with ts-jest; E2E tests use Supertest
15+
- **Linting:** ESLint (flat config) with TypeScript-ESLint and Prettier integration
16+
- **Formatting:** Prettier (140 print width, single quotes, trailing commas ES5, 2-space indent)
17+
18+
## Project Structure
19+
20+
```
21+
src/
22+
├── auth/ # Authentication (JWT, Google OAuth)
23+
├── cloudflare-kv/ # Cloudflare KV integration
24+
├── common/ # Shared infrastructure
25+
│ ├── configs/ # Configuration service
26+
│ ├── database/ # Prisma database module
27+
│ ├── decorators/ # Custom decorators (@Api, @User, @Field)
28+
│ ├── filters/ # Exception filters
29+
│ ├── helpers/ # Utility functions
30+
│ ├── interceptors/# Response interceptors
31+
│ ├── logger/ # Logging service
32+
│ ├── models/ # Common response models
33+
│ ├── pagination/ # Pagination utilities
34+
│ ├── queue/ # BullMQ job queue
35+
│ ├── redis/ # Redis module and providers
36+
│ └── validation/ # Custom validators
37+
├── errors/ # Error reporting
38+
├── events/ # WebSocket events gateway
39+
├── generated/ # Auto-generated Prisma DTOs (do not edit)
40+
├── jobs/ # Job management
41+
├── location/ # Location services
42+
├── notifications/ # Push notifications (Firebase)
43+
├── users/ # User management
44+
└── wss/ # WebSocket support
45+
```
46+
47+
## Coding Conventions
48+
49+
### File Naming
50+
51+
- Controllers: `{name}.controller.ts`
52+
- Services: `{name}.service.ts`
53+
- Modules: `{name}.module.ts`
54+
- DTOs: `{operation}-{entity}.dto.ts` (e.g., `create-job.dto.ts`)
55+
- Filters: `{name}.filter.ts`
56+
- Guards: `{name}.guard.ts`
57+
- Interceptors: `{name}.interceptor.ts`
58+
- Decorators: `{name}.decorator.ts`
59+
60+
### Imports
61+
62+
Use the `@/` path alias for imports from the `src/` directory:
63+
64+
```typescript
65+
import { Api } from '@/common/decorators/api.decorator';
66+
import { NotificationsService } from '@/notifications/notifications.service';
67+
```
68+
69+
### API Patterns
70+
71+
- Use the custom `@Api()` decorator for controller methods to configure Swagger docs, response types, and the response envelope.
72+
- Endpoints using `@Api({ envelope: true })` return `{ "success": true, "data": <payload> }`.
73+
- Paginated endpoints use `paginatedResponseType` and return items with `pageInfo` metadata. Use `buildPaginatedResult()` in services.
74+
- DTO properties use `@Field({ inQuery: true })` or `@Field({ inPath: true })` for automatic Swagger parameter generation.
75+
- Throw standard NestJS `HttpException` subclasses for error handling.
76+
77+
### Validation
78+
79+
- Use `class-validator` and `class-transformer` decorators on DTOs for input validation.
80+
- The global `ValidationPipe` is configured with `whitelist: true` and `transform: true`.
81+
82+
## Important Notes
83+
84+
- **Do not edit files in `src/generated/`** — these are auto-generated from the Prisma schema using `npx prisma generate`.
85+
- **The Prisma schema is a Git submodule** at `prisma/`. Schema changes should be made in the `codebuilderinc/codebuilder-prisma` repository.
86+
- The project uses Prettier for formatting; run `pnpm format` to format code or `pnpm lint` to lint and auto-fix.
87+
88+
## Common Commands
89+
90+
```bash
91+
pnpm install # Install dependencies
92+
pnpm build # Build the project
93+
pnpm dev # Start in development/watch mode (NODE_ENV=local)
94+
pnpm lint # Lint and auto-fix
95+
pnpm format # Format code with Prettier
96+
pnpm test # Run unit tests
97+
pnpm test:e2e # Run end-to-end tests
98+
```

0 commit comments

Comments
 (0)