Skip to content

Commit 6361c7b

Browse files
committed
docs: Add readme
1 parent e76cae0 commit 6361c7b

4 files changed

Lines changed: 120 additions & 201 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ pids
5454

5555
# Diagnostic reports (https://nodejs.org/api/report.html)
5656
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
57+
58+
plans
59+
agent

README.md

Lines changed: 106 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,127 @@
1-
<p align="center">
2-
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
3-
</p>
4-
5-
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
6-
[circleci-url]: https://circleci.com/gh/nestjs/nest
7-
8-
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
9-
<p align="center">
10-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
11-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
12-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
13-
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
14-
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
15-
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
16-
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
17-
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
18-
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
19-
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
20-
</p>
21-
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
22-
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
23-
24-
## Description
25-
26-
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
27-
28-
## Project setup
29-
1+
# Nothing Backend - NestJS Scaffold Template
2+
3+
A progressive and production-ready NestJS scaffold template designed for scalability, type-safety, and clean architecture. This project serves as a foundation for building robust e-commerce or catalog-based backends.
4+
5+
## 🚀 Tech Stack
6+
7+
- **Framework:** [NestJS v11](https://nestjs.com/) (Express-based)
8+
- **Language:** TypeScript (ES2023)
9+
- **Database:** PostgreSQL with [TypeORM](https://typeorm.io/)
10+
- **Validation:** [Zod](https://zod.dev/) via `nestjs-zod` for absolute type safety.
11+
- **Authentication:** JWT (Passport.js strategy) with Access & Refresh token rotation.
12+
- **File Storage:** AWS S3 / MinIO integration via AWS SDK v3.
13+
- **API Documentation:** Integrated Swagger UI (OpenAPI 3.0).
14+
- **Tooling:** ESLint, Prettier, Jest.
15+
16+
## 🏗️ Architectural Decisions
17+
18+
### 1. Modular Structure
19+
The application is organized into domain-driven modules located in `src/modules`. Each module is self-contained, encapsulating its own controllers, services, entities, and DTOs.
20+
- `AuthModule`: Identity and access management.
21+
- `UsersModule`: Profile and user management.
22+
- `ProductsModule`: Catalog and inventory management.
23+
- `CategoriesModule`: Hierarchical classification.
24+
25+
### 2. Path Aliases
26+
To avoid deep relative imports (`../../../../`), the project uses TypeScript path aliases defined in `tsconfig.json`:
27+
- `@modules/*` -> `src/modules/*`
28+
- `@common/*` -> `src/common/*`
29+
- `@config/*` -> `src/config/*`
30+
- `@database/*` -> `src/database/*`
31+
- `@helpers/*` -> `src/helpers/*`
32+
33+
### 3. Response & Error Standardization
34+
The backend enforces a strict design system for API communication:
35+
- **Success Interceptor**: All successful responses are automatically wrapped in a standard `ApiResponse` structure:
36+
```json
37+
{
38+
"success": true,
39+
"message": "Success",
40+
"data": { ... },
41+
"meta": { ... } // Optional (e.g., pagination)
42+
}
43+
```
44+
- **Global Exception Filter**: Errors are caught and formatted consistently by the `HttpExceptionFilter`, ensuring even internal errors return a safe and readable JSON response.
45+
46+
### 4. Schema-First Validation
47+
We use `zod` for all DTOs. This ensures that validation and TypeScript types are always in sync. Use the `ZodValidationPipe` (global) to handle input validation automatically.
48+
49+
---
50+
51+
## 🛠️ Getting Started
52+
53+
### Prerequisites
54+
- Node.js (v18+)
55+
- PostgreSQL
56+
- S3 Compatible Storage (MinIO or AWS S3)
57+
58+
### Installation
3059
```bash
31-
$ npm install
60+
npm install
3261
```
3362

34-
## Compile and run the project
35-
63+
### Environment Setup
64+
Copy `.env.example` to `.env` and fill in your credentials:
3665
```bash
37-
# development
38-
$ npm run start
39-
40-
# watch mode
41-
$ npm run start:dev
42-
43-
# production mode
44-
$ npm run start:prod
66+
cp .env.example .env
4567
```
4668

47-
## Run tests
48-
69+
### Running the App
4970
```bash
50-
# unit tests
51-
$ npm run test
52-
53-
# e2e tests
54-
$ npm run test:e2e
71+
# Development
72+
npm run start:dev
5573

56-
# test coverage
57-
$ npm run test:cov
74+
# Production Build
75+
npm run build
76+
npm run start:prod
5877
```
5978

60-
## Deployment
79+
### API Documentation
80+
Once the app is running, visit:
81+
- **Swagger UI**: `http://localhost:3000/docs`
82+
- **Static Spec**: `src/swagger.json`
6183

62-
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
84+
---
6385

64-
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
86+
## 📘 Integration Guide (For AI Agents & Developers)
6587

66-
```bash
67-
$ npm install -g @nestjs/mau
68-
$ mau deploy
69-
```
70-
71-
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
88+
When building new features on top of this scaffold, follow these guidelines to maintain consistency:
7289

73-
## Resources
90+
### 1. Adding a New Module
91+
Use the NestJS CLI or create a directory in `src/modules/[feature]`:
92+
1. **Define Entity**: Create `entities/[feature].entity.ts` using TypeORM decorators.
93+
2. **Define Schema/DTO**: Create `dto/[feature].dto.ts` using `zod` schemas.
94+
3. **Service**: Implement business logic in `[feature].service.ts`.
95+
4. **Controller**: Define endpoints in `[feature].controller.ts`.
96+
5. **Module**: Wire everything in `[feature].module.ts` and import it into `AppModule`.
7497

75-
Check out a few resources that may come in handy when working with NestJS:
98+
### 2. Working with Standard Responses
99+
You do not need to wrap your data in `success` or `message` keys manually in the controller. Return the raw data (or a promise), and the `ResponseInterceptor` will handle the wrapping.
100+
- **Custom Message**: If you need a specific message, return an object like `{ data, message: 'Your message' }`.
76101

77-
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
78-
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
79-
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
80-
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
81-
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
82-
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
83-
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
84-
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
102+
### 3. Storage Integration
103+
Use the `S3Helper` from `@helpers/s3.helper`:
104+
```typescript
105+
constructor(private readonly s3Helper: S3Helper) {}
85106

86-
## Support
87-
88-
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
107+
async upload(file: Express.Multer.File) {
108+
return await this.s3Helper.uploadFile(file, 'folder-name');
109+
}
110+
```
89111

90-
## Stay in touch
112+
### 4. Authentication & RBAC
113+
Protect routes using the built-in guards:
114+
- **JWT Protection**: `@UseGuards(JwtAuthGuard)`
115+
- **Role Based Access**: `@Roles(Role.Admin)` + `@UseGuards(JwtAuthGuard, RolesGuard)`
91116

92-
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
93-
- Website - [https://nestjs.com](https://nestjs.com/)
94-
- Twitter - [@nestframework](https://twitter.com/nestframework)
117+
### 5. Database Conventions
118+
- Always use `uuid` for primary keys.
119+
- Use `CreateDateColumn` and `UpdateDateColumn` for auditing.
120+
- Prefer relations over manual ID handling where possible.
95121

96-
## License
122+
---
97123

98-
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).
124+
## 🛡️ Design System & Standards
125+
- **Naming**: camelCase for variables/functions, PascalCase for classes, kebab-case for files.
126+
- **Comments**: We follow the **NO non-essential comments** rule. Code should be self-documenting. Use comments only for complex algorithmic logic.
127+
- **Git**: Commits should be descriptive. Feature branches are preferred.

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
"test:watch": "jest --watch",
2121
"test:cov": "jest --config ./jest.json --coverage",
2222
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand"
23-
},
24-
"dependencies": {
23+
},
24+
"dependencies": {
2525
"@aws-sdk/client-s3": "^3.1037.0",
2626
"@nestjs/common": "^11.0.1",
2727
"@nestjs/core": "^11.0.1",
@@ -41,8 +41,8 @@
4141
"swagger-ui-express": "^5.0.1",
4242
"typeorm": "^0.3.28",
4343
"zod": "^4.3.6"
44-
},
45-
"devDependencies": {
44+
},
45+
"devDependencies": {
4646
"@eslint/eslintrc": "^3.2.0",
4747
"@eslint/js": "^9.18.0",
4848
"@nestjs/cli": "^11.0.0",
@@ -67,8 +67,8 @@
6767
"tsconfig-paths": "^4.2.0",
6868
"typescript": "^5.7.3",
6969
"typescript-eslint": "^8.20.0"
70-
},
71-
"jest": {
70+
},
71+
"jest": {
7272
"moduleFileExtensions": [
7373
"js",
7474
"json",
@@ -88,7 +88,9 @@
8888
"<rootDir>/src/**/*.integration-spec.ts",
8989
"<rootDir>/test/**/*.e2e-spec.ts"
9090
],
91-
"setupFilesAfterEnv": ["<rootDir>/test/setup-jest.ts"],
91+
"setupFilesAfterEnv": [
92+
"<rootDir>/test/setup-jest.ts"
93+
],
9294
"coverageThreshold": {
9395
"global": {
9496
"branches": 100,
@@ -97,7 +99,5 @@
9799
"statements": 100
98100
}
99101
}
100-
}
101-
}
102-
103-
}
102+
}
103+
}

plans/comprehensive-test-generation.md

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)