Skip to content

πŸΉπŸ‘‘ A starter kit for NestJS with Prisma, Passport, Zod, Swagger, and more. Built to be a solid foundation for YOUR next project πŸ‘‘πŸΉ.

License

Notifications You must be signed in to change notification settings

mr-meselmani/nestjs-starter-kit

Repository files navigation

Nest Logo

NestJS Starter Kit πŸš€

Project Banner

Architecture

Project Banner

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

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 😎


Table of Contents


Features and Benefits

  • 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.

Getting Started

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.

Prerequisites

Make sure you have the following installed:

  • Node.js (version 20.11.0 or higher)
  • npm & pnpm
  • PostgreSQL (installed and running)

Installation

To get started with this starter kit, follow these steps:

  1. Clone the repository:

    git clone https://github.com/mr-meselmani/nestjs-starter-kit.git
  2. Navigate to the project directory:

    cd nestjs-starter-kit
  3. Install dependencies:

    pnpm install
  4. 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 sure DATABASE_URL is set to use the HOST as localhost.
  5. Make a database migration using the script defined in the package.json file by running:

    pnpm db:migrate
  6. Run the seed command to seed the database by some data defined in prisma/seed/data:

    pnpm db:seed
  7. Run the application:

    pnpm start:dev

Usage

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.


Docker Setup

To run the project using Docker, make sure Docker is installed and running on your machine. Follow these steps:

  1. Clone the Repository:

    git clone https://github.com/mr-meselmani/nestjs-starter-kit.git
  2. Navigate to the Project Directory:

    cd nestjs-starter-kit
  3. 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 sure DATABASE_URL is set to use the HOST as postgres (the name of the database service in the docker-compose.yml file).
  4. 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.

  5. 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 your docker-compose.yml file if it’s different.

  6. Access the Application: The application should be available at http://localhost:3000/doc on your local machine.


Contributing

We welcome contributions from the community. If you'd like to contribute, please follow these steps:

  1. Open an issue in the GitHub repository.
  2. Fork the repository.
  3. Create a new branch for your feature or bug fix.
  4. Make your changes and commit them.
  5. Push your branch and create a pull request only to development branch.
  6. Wait for review & acceptance.

Please ensure your code follows the project's coding standards and very well tested.


Sponsorship

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 🀍


Current ERD

Project Banner

License

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 πŸŽ‰

About

πŸΉπŸ‘‘ A starter kit for NestJS with Prisma, Passport, Zod, Swagger, and more. Built to be a solid foundation for YOUR next project πŸ‘‘πŸΉ.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published