A robust and flexible NestJS backend template designed for microservice-ready architecture with modular components that can be easily customized and deployed.
- Microservice Architecture: Designed with modularity in mind, ready to split into separate microservices
- Prisma ORM: Type-safe database client for PostgreSQL integration
- JWT Authentication: Secure authentication & role-based authorization
- Event-Driven: Event system for asynchronous communication between modules
- OpenAPI Documentation: Automatic API documentation generation
- Container Ready: Docker and Kubernetes compatible
Module | Features | Status | Dependencies |
---|---|---|---|
Common | Core utilities, error handling, logger | Beta | PostgreSQL |
Identity | User management, authentication | Alpha | PostgreSQL, Gotrue |
Content | Posts, stories, tweets | Alpha | PostgreSQL |
Social | Comments, likes, follows | Alpha | PostgreSQL |
Notification | User notifications | Alpha | PostgreSQL, Redis, MQTT |
Feed | User activity feeds | Alpha | PostgreSQL, Redis |
Storage | File uploads and management | Alpha | Google Cloud Storage |
Gamification | Points, badges, rewards | Alpha | PostgreSQL |
User-Follow | User follow relationships | Beta | PostgreSQL |
Invitation | User invitations | Beta | PostgreSQL |
Recommendation | Content recommendations | Alpha | PostgreSQL, Redis, Gorse |
Search | Search functionality | - | PostgreSQL |
Payment | Payment processing | - | PostgreSQL |
AI | AI integrations | - | Planned |
Analytic | Data analytics | Planned | PostgreSQL |
This project is optimized for development with Cursor, an AI-powered code editor that enhances your coding experience.
- Install Cursor: Download from https://cursor.so/
- Open this Project: Use File > Open to navigate to the project
- Use AI Commands: Press
Ctrl+K
orCmd+K
to open the AI command palette
Cursor helps you understand the codebase faster and implement features more efficiently by providing context-aware AI assistance.
# Clone and install
git clone https://github.com/reallongnguyen/nestjs-vibe-coding
cd nestjs-vibe-coding
pnpm install
# Configure environment
cp .env.example .env
# Start dependencies (PostgreSQL, Redis, MQTT)
docker compose up -d
# Setup database
npx prisma db push
# Create Root user
export ROOT_USER_AUTH_ID=437834e3-6fa8-4db3-9f8a-a0402f5d0814
npx prisma db seed
# Start dev server with hot reload
pnpm start:dev
# Start production server
pnpm build
pnpm start:prod
You can test the API endpoints using Swagger UI at http://localhost:8000/api
.
To authenticate:
- Click the "Authorize" button in Swagger UI
- Enter your JWT token in the format:
your_token_here
For testing purposes, you can generate a valid JWT using:
# Using node
node -e "require('dotenv').config(); console.log(require('jsonwebtoken').sign({ sub: '437834e3-6fa8-4db3-9f8a-a0402f5d0814' }, process.env.JWT_SECRET ?? 'secret', { expiresIn: '1h' }))"
This project uses Supabase GoTrue for authentication. Here's how to get your own access token:
- Sign Up
curl -X POST 'http://localhost:9999/auth/v1/signup' \
-H "apikey: your-anon-key" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "your-password"
}'
- Sign In
curl -X POST 'http://localhost:9999/auth/v1/token?grant_type=password' \
-H "apikey: your-anon-key" \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"password": "your-password"
}'
Response will include your access token:
{
"access_token": "your.jwt.token",
"token_type": "bearer",
"expires_in": 3600,
"refresh_token": "your-refresh-token"
}
- Using the Token
- In API requests, add the header:
Authorization: Bearer your.jwt.token
- In Swagger UI, click "Authorize" and enter:
Bearer your.jwt.token
For more authentication options and details, see the Supabase GoTrue documentation.
The template is designed to be modular, making it easy to remove unnecessary components:
- Remove the module directory from
src/
- Remove the module import from
src/app.module.ts
- Remove related database schema from
prisma/schema.prisma
(if applicable)
Example:
// src/app.module.ts
@Module({
imports: [
CommonModule,
IdentityModule,
// Remove the line below to remove the ContentModule
// ContentModule,
SocialModule,
// ...other modules
],
controllers: [AppController],
})
export class AppModule {}
This template uses Docker and docker-compose for local development. For production deployment, we recommend:
- Kubernetes: For orchestrating the microservices
- Cloud Providers: AWS, GCP, or Azure for managed infrastructure
See the deployment documentation for detailed instructions on deploying to different environments.
Contributions are welcome! Whether it's:
- π Reporting a bug
- π‘ Requesting a feature
- π Improving documentation
- π§βπ» Submitting a PR
Please check out our Contribution Guidelines before making a contribution.
This project is licensed under the MIT License - see the LICENSE file for details.
Nguyen Phuc Long