NOTE: Any folder which is not a NestJS module we prefix it with
_
this makes the view better in code editor & separate of concerns.
Welcome to the NestJS Starter Kit π This starter is opensource and provides a robust backend framework using NestJS with Prisma for database management, PostgreSQL as the database, Zod for schema validation, Resend email service, and TypeScript for type safety. Complete Authentication and Authorization are also included out of the box using PassportJS strategies JWT access & refresh tokens.
NOTE: Join the Innovators Lounge Discord Server for free to get support and be an innovator member π
- Features and Benefits
- Getting Started
- Installation
- Usage
- Docker Setup
- Contributing
- Sponsorship π€
- Current ERD
- License
- NestJS: A progressive Node.js framework for building efficient, reliable, and scalable server-side applications.
- Authentication and Authorization: Complete user authentication solution and Role-based Access Control (RBAC) π.
- Prisma: An open-source database toolkit that simplifies database access and management.
- PostgreSQL: A powerful, open-source relational database system.
- TypeScript Support: Strongly typed code for better maintainability and scalability.
- Zod Validation: Validation across all requests and responses lifecycle using zod schemas.
- Docker: Containerization abstract the setup tools on any local machine and help in deployment.
- Resend Email Service: A fast & cheap email service to use in your project.
- Modular Architecture: Organized code structure for better separation of concerns.
This guide will walk you through how to set up, configure, and run the NestJS starter kit on your local machine OR skip this and go to Docker Setup to avoid installing tools.
Make sure you have the following installed:
- Node.js (version 20.11.0 or higher)
- npm & pnpm
- PostgreSQL (installed and running)
To get started with this starter kit, follow these steps:
-
Clone the repository:
git clone https://github.com/mr-meselmani/nestjs-starter-kit.git
-
Navigate to the project directory:
cd nestjs-starter-kit
-
Install dependencies:
pnpm install
-
Set up Environment Variables:
- Create a
.env
file in the root directory. - Copy the contents of
.env.example
into.env
and configure any necessary environment variables and make sure to read notes written inside the.env
file. For Local, make sureDATABASE_URL
is set to use theHOST
aslocalhost
.
- Create a
-
Make a database migration using the script defined in the
package.json
file by running:pnpm db:migrate
-
Run the seed command to seed the database by some data defined in
prisma/seed/data
:pnpm db:seed
-
Run the application:
pnpm start:dev
After running the application, you can access the Swagger API documentation at http://localhost:3000/doc
. You can modify the code to fit your project requirements.
To run the project using Docker, make sure Docker is installed and running on your machine. Follow these steps:
-
Clone the Repository:
git clone https://github.com/mr-meselmani/nestjs-starter-kit.git
-
Navigate to the Project Directory:
cd nestjs-starter-kit
-
Set up Environment Variables:
- Create a
.env
file in the root directory. - Copy the contents of
.env.example
into.env
and configure any necessary environment variables. For Docker, make sureDATABASE_URL
is set to use theHOST
aspostgres
(the name of the database service in thedocker-compose.yml
file).
- Create a
-
Run the Project with Docker Compose:
docker-compose up -d
This command will build and run the application and a PostgreSQL container, as defined in the
docker-compose.yml
file. -
Apply Database Migrations: Once the containers are running, apply database migrations using the following command:
docker-compose exec app pnpm prisma migrate deploy
Replace
app
with the name of the service in yourdocker-compose.yml
file if itβs different. -
Access the Application: The application should be available at
http://localhost:3000/doc
on your local machine.
We welcome contributions from the community. If you'd like to contribute, please follow these steps:
- Open an issue in the GitHub repository.
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your branch and create a pull request
only to development branch
. - Wait for review & acceptance.
Please ensure your code follows the project's coding standards and very well tested.
If you find this project helpful and would like to support its development, please consider sponsoring this project. You can send contributions using the following cryptocurrencies:
-
Bitcoin NativeSegwit (BTC):
bc1qyveg0kx7jthyr6dvpaz8fl63g9cvwwy4g56wwn
-
Ethereum (ETH):
0x7ff0b2e075e8969c2d7554bc6e86bb2f5b75cf6f
-
Tron (TRX):
TT6s8rx7RyYB7yncNVE2nzTbkdQaoYZAE7
-
Solana (SOL):
8Do6X7EU7jswKt55PD5Lm6sygLoYj3LvtSRVJE7kS3et
Your contributions will help ensure the continued development and maintenance of this starter kit. Thank you for your support π€
This project is licensed under the MIT License. See the LICENSE file for more details.
Thank you for checking out the NestJS Starter Kit π Happy coding π