{"id":18963401,"url":"https://github.com/pashamakhilkumarreddy/nestjs-starter","last_synced_at":"2026-04-10T07:03:31.948Z","repository":{"id":39115054,"uuid":"266351237","full_name":"pashamakhilkumarreddy/nestjs-starter","owner":"pashamakhilkumarreddy","description":"A starter template for building scalable and maintainable server-side applications using NestJS, Postgres, Redis and Docker.","archived":false,"fork":false,"pushed_at":"2024-10-19T14:33:01.000Z","size":720,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-01T05:20:32.976Z","etag":null,"topics":["docker","docker-compose","express","keycloak","nestjs","nodejs","postgresql","redis"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pashamakhilkumarreddy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-23T14:18:33.000Z","updated_at":"2024-06-18T17:55:08.000Z","dependencies_parsed_at":"2024-06-18T22:27:20.793Z","dependency_job_id":"11c4fa92-04f9-4321-a3e0-f942a3ad9759","html_url":"https://github.com/pashamakhilkumarreddy/nestjs-starter","commit_stats":null,"previous_names":["pashamakhilkumarreddy/nestjs-starter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pashamakhilkumarreddy%2Fnestjs-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pashamakhilkumarreddy%2Fnestjs-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pashamakhilkumarreddy%2Fnestjs-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pashamakhilkumarreddy%2Fnestjs-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pashamakhilkumarreddy","download_url":"https://codeload.github.com/pashamakhilkumarreddy/nestjs-starter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239958308,"owners_count":19724926,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","express","keycloak","nestjs","nodejs","postgresql","redis"],"created_at":"2024-11-08T14:19:14.635Z","updated_at":"2026-04-10T07:03:31.861Z","avatar_url":"https://github.com/pashamakhilkumarreddy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nest.JS Starter API\n\nThis project is a RESTful API built with Nest.js, a framework designed for efficient and scalable Node.js server-side applications. It also employs Docker for containerization, Postgres as the database, NVM for managing Node.js versions, and Swagger for API documentation and testing.\n\n## Prerequisites\n\n-   Node.js version 20.x.x (LTS)\n-   Postgres\n-   Docker\n-   Docker Compose\n-   NVM (optional, for managing Node.js versions)\n\n## Table of Contents\n\n-   [Installation](#installation)\n-   [Usage](#usage)\n-   [Project Structure](#project-structure)\n-   [Swagger](#swagger)\n-   [Docker](#docker)\n-   [Database](#database)\n-   [Database Migrations](#database-migrations)\n-   [Testing](#testing)\n-   [Linting and Formatting](#linting-and-formatting)\n\n## Installation\n\nBefore starting, ensure you have [Node.js](https://nodejs.org/) installed. It's recommended to use [NVM](https://github.com/nvm-sh/nvm) to manage Node.js versions. The project uses the Node.js version specified in `.nvmrc`.\n\n1. Clone this repository:\n\n    ```bash\n    git clone https://github.com/pashamakhilkumarreddy/nestjs-starter.git\n    ```\n\n2. Navigate to the project directory:\n\n    ```bash\n    cd nestjs-starter\n    ```\n\n3. If using NVM, set the correct Node.js version:\n\n    ```bash\n    nvm use\n    ```\n\n4. Create a `.env` file in the project root directory and add the required environment variables (use `.env.example` as a reference).\n\n    ```bash\n    cp .env.example .env\n    ```\n\n5. Install dependencies:\n\n    ```bash\n    npm install\n    ```\n\n## Usage\n\nTo start the application:\n\n-   Development Mode:\n\n    ```bash\n    npm run start:dev\n    ```\n\n-   Production Mode:\n\n    ```bash\n    npm run start:prod\n    ```\n\n## Project Structure\n\n```bash\n├── src\n│   ├── common\n│   │   ├── config\n│   │   ├── constants\n│   │   ├── decorators\n│   │   ├── dtos\n│   │   ├── filters\n│   │   ├── guards\n│   │   ├── interceptors\n│   │   ├── middlewares\n│   │   ├── services\n│   │   ├── utils\n│   ├── entities\n│   ├── infrastructure\n│   ├── modules\n│   ├── app.controller.ts\n│   ├── app.module.ts\n│   ├── main.ts\n├── config\n├── nginx\n├── seeders\n├── test\n├── .commitlintrc.json\n├── .dockerignore\n├── .editorconfig\n├── .env\n├── .env.example\n├── .eslintignore\n├── .eslintrc.js\n├── .gitignore\n├── .npmrc\n├── .nvmrc\n├── .prettierignore\n├── .prettierrc\n├── .sequelize\n├── CONTRIBUTING.md\n├── docker-compose.prod.yml\n├── docker-compose.yml\n├── Dockerfile\n├── Dockerfile.dev\n├── Dockerfile.prod\n├── jest.config.js\n├── nest-cli.json\n├── package-lock.json\n├── package.json\n├── README.md\n├── tsconfig.build.json\n└── tsconfig.json\n```\n\n## Detailed Project Structure\n\n-   `src`: Main source code directory.\n    -   `common`: Contains shared utilities, configurations, and constants.\n        -   `config`: Configuration files.\n        -   `constants`: Constant values used across the application.\n        -   `decorators`: Custom decorators for NestJS.\n        -   `dtos`: Data Transfer Objects for defining data structures.\n        -   `filters`: Custom exception filters.\n        -   `guards`: Custom guards.\n        -   `interceptors`: Custom interceptors.\n        -   `middlewares`: Custom middlewares.\n        -   `services`: Shared services.\n        -   `utils`: Utility functions.\n    -   `entities`: Database entities.\n    -   `infrastructure`: Code related to infrastructure (e.g., database connections).\n    -   `modules`: NestJS modules organizing features.\n    -   `app.controller.ts`: Main application controller.\n    -   `app.module.ts`: Main application module.\n    -   `main.ts`: Application entry point.\n-   `config`: Additional configuration files.\n-   `nginx`: NGINX configuration files (if applicable).\n-   `seeders`: Database seeders.\n-   `test`: Testing configurations and files.\n-   Various configuration files for Commitlint, Docker, EditorConfig, ESLint, Git, NPM, Prettier, and Sequelize.\n\n## Swagger\n\nAccess the Swagger UI at [Swagger API Docs](http://localhost:5000/api-docs).\n\n## Docker\n\nThe project includes Docker Compose files for various environments. Ensure the necessary environment variables are set in the corresponding `.env` files (use `.env.example` as a reference).\n\n#### Building Docker Images\n\nTo build Docker images:\n\n-   Development Mode:\n\n    ```bash\n    npm run docker:dev:build\n    ```\n\n-   Production Mode:\n\n    ```bash\n    npm run docker:prod:build\n    ```\n\n#### Running Docker Containers\n\nTo run Docker containers:\n\n-   Development Mode:\n\n    ```bash\n    npm run docker:dev:start\n    ```\n\n-   Production Mode:\n\n    ```bash\n    npm run docker:prod:start\n    ```\n\n#### Stopping and Cleaning Docker Containers\n\nTo stop and clean Docker containers:\n\n```bash\nnpm run docker:dev:stop\nnpm run docker:dev:clean\n```\n\n## Database\n\nThis application uses [PostgreSQL](https://www.postgresql.org/). Set up and configure the database as follows:\n\n1. Ensure PostgreSQL is installed.\n2. Create a new database and user:\n\n    ```bash\n    psql -U postgres\n    CREATE DATABASE nestjs;\n    CREATE USER nestjs_admin WITH PASSWORD 'your_password';\n    GRANT ALL PRIVILEGES ON DATABASE nestjs TO nestjs_admin;\n    \\q\n    ```\n\n## Database Migrations\n\nThe API uses Sequelize for database migrations. Manage migrations with these commands:\n\n1. Generate Migration:\n\n    ```bash\n    npm run db:generate\n    ```\n\n2. Run Migrations:\n\n    ```bash\n    npm run db:migrate\n    ```\n\n3. Undo Migrations:\n\n    ```bash\n    npm run db:migrate:down\n    ```\n\n## Testing\n\n1. Run Tests:\n\n    ```bash\n    npm test\n    ```\n\n2. Watch Tests:\n\n    ```bash\n    npm run test:watch\n    ```\n\n3. Test Coverage:\n\n    ```bash\n    npm run test:coverage\n    ```\n\n4. Debug Tests:\n\n    ```bash\n    npm run test:debug\n    ```\n\n5. End-to-End Tests:\n\n    ```bash\n    npm run test:e2e\n    ```\n\n## Linting and Formatting\n\n1. Run ESLint:\n\n    ```bash\n    npm run lint\n    ```\n\n2. Fix ESLint Issues:\n\n    ```bash\n    npm run lint:fix\n    ```\n\n3. Format Code:\n\n    ```bash\n    npm run format:fix\n    ```\n\n### Pre-commit Hook\n\nPre-commit hooks using Husky and lint-staged enforce linting and formatting. To bypass these hooks temporarily:\n\n```bash\ngit commit --no-verify -m \"Your commit message\"\n```\n\n## Scripts\n\nKey npm scripts include:\n\n-   `npm run build`: Build the application for production.\n-   `npm run format`: Format code using Prettier.\n-   `npm run lint`: Lint code using ESLint.\n-   `npm run start`: Start the application in production mode.\n-   `npm run start:dev`: Start the application in development mode.\n-   `npm run start:debug`: Start the application in debug mode.\n-   `npm run db:migrate`: Apply database migrations.\n-   `npm run db:migrate:down`: Revert the last migration.\n-   `npm run test`: Run unit and integration tests.\n-   `npm run test:watch`: Run tests in watch mode.\n-   `npm run test:cov`: Generate code coverage report.\n-   `npm run test:debug`: Debug tests.\n-   `npm run test:e2e`: Run end-to-end tests.\n\nRefer to the `package.json` file for more details.\n\n## Keycloak Setup\n\nFor Keycloak setup, see the [Keycloak guide](./Keycloak.md).\n\n## Contributing\n\nFor contributing guidelines, see the [Contributing guide](./CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpashamakhilkumarreddy%2Fnestjs-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpashamakhilkumarreddy%2Fnestjs-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpashamakhilkumarreddy%2Fnestjs-starter/lists"}