Skip to content

The boilerplate is a Nest.js, PostgreSQL, and Prisma starter project that provides an initial structure for developing scalable and robust web applications. It combines a modern framework, a reliable database, and an efficient data access layer to accelerate the development process.

Notifications You must be signed in to change notification settings

psnavega/nest-boilerplate

Repository files navigation

Boilerplate Nest.js with PostgreSQL and Prisma

Features

  • Nest.js framework for building scalable and modular applications
  • PostgreSQL as the relational database management system
  • Prisma as the database toolkit for type-safe database access and migrations
  • Fully configured for development and production environments
  • Includes example code for creating users using controllers, services, and DTOs
  • Docker Compose setup for easy deployment and containerization

Prerequisites

Before running the project, ensure that you have the following software installed on your machine:

  • Docker and Docker Compose (for containerization)
  • Node.js (version 14 or higher)
  • PostgreSQL (optional, if you want to run the database locally instead of using Docker)

Getting Started

  1. Clone the repository and navigate to the project directory.
  2. Create a .env file in the project root and set the necessary environment variables. Refer to the provided example in the README for the required variables.
    • There's a .env.example with example of required envs to start the project =)
  3. Run docker-compose up to start the project with Docker, or manually start the PostgreSQL database and run the project locally using npm run start:prod.
  4. Access the application by visiting http://localhost:3000 in your browser.

Project Structure

The project follows a structured folder hierarchy to maintain a clean and organized codebase. Here's an overview of the main directories:

  • src/infra: Contains infrastructure-related code, such as configuration files for Prisma.
  • src/user: Represents the user domain module, including application-specific code.
  • src/user/application: Contains the controllers and services related to user management.
  • src/user/data: Includes repositories and use cases for data access and business logic.
  • src/domains: Contains shared domain-related entities, interfaces, and repositories.
  • src/dtos: Contains Data Transfer Objects (DTOs) used for data validation and input/output.
  • src/user.module.ts: Defines the user module and its dependencies.
  • src/app.module.ts: Main module file that imports all the required modules and sets up the application.
  • test/: Contains test files and configurations.

Feel free to modify the project structure according to your specific requirements.

  • prisma
    • migrations
    • schema.prisma
  • src
    • infra
      • config
        • prisma.module
        • prisma.service
    • user (context)
      • application
        • controllers
        • services
      • data
        • repositories
        • use-cases
    • domains
      • entities
      • interfaces
      • repositories
    • dtos
    • user.module.ts
  • app.module.ts
  • test

Contributing

Contributions to this boilerplate project are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Authors

Enjoy building amazing applications with Nest.js, PostgreSQL, and Prisma!

About

The boilerplate is a Nest.js, PostgreSQL, and Prisma starter project that provides an initial structure for developing scalable and robust web applications. It combines a modern framework, a reliable database, and an efficient data access layer to accelerate the development process.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published