A comprehensive, production-ready Node.js backend starter template built with Express.js, PostgreSQL, Prisma ORM, TypeScript, and modern development practices.
- π§ Modern Stack: Node.js, Express.js, TypeScript, PostgreSQL, Prisma ORM
- π Authentication: JWT-based authentication with refresh tokens
- π₯ User Management: Complete user CRUD with role-based access control
- π File Upload: Cloudinary integration for media management
- π§ Email Service: Nodemailer integration for email functionality
- π‘οΈ Security: Helmet, CORS, rate limiting, input validation
- π Database: PostgreSQL with Prisma ORM for type-safe operations
- π§ͺ Testing: Jest setup with coverage reporting
- π Code Quality: ESLint, Prettier, Husky for code standards
- π³ Docker: Complete Docker setup with docker-compose
- π Documentation: Comprehensive documentation and API reference
- π CI/CD Ready: GitHub Actions workflow templates
- Node.js (v16 or higher)
- npm or yarn package manager
- PostgreSQL database
- Git
git clone <your-repository-url>
cd nodejs-express-prisma-starternpm install# Copy environment template
cp env.example .env
# Edit .env with your configuration
nano .env# Generate Prisma client
npm run db:generate
# Run database migrations
npm run migrate
# (Optional) Seed the database
npm run db:seednpm run devYour server will be running at http://localhost:5000
npm run dev- Start development server with hot reloadnpm run build- Build the project for productionnpm run start- Start production server
npm run migrate- Run database migrationsnpm run migrate:deploy- Deploy migrations to productionnpm run migrate:reset- Reset databasenpm run db:studio- Open Prisma Studionpm run db:generate- Generate Prisma clientnpm run db:seed- Seed database with sample data
npm run lint- Run ESLintnpm run lint:fix- Fix ESLint errorsnpm run format- Format code with Prettiernpm run type-check- Run TypeScript type checking
npm test- Run testsnpm run test:watch- Run tests in watch modenpm run test:coverage- Run tests with coverage
npm run docker:build- Build Docker imagenpm run docker:run- Run Docker containernpm run docker:compose- Start with docker-compose
src/
βββ controllers/ # Request handlers
βββ services/ # Business logic
βββ models/ # Data models
βββ middleware/ # Express middleware
βββ utils/ # Utility functions
βββ types/ # TypeScript type definitions
βββ constants/ # Application constants
βββ validators/ # Request validation schemas
βββ database/ # Database configuration
βββ routes/ # Route definitions
βββ config/ # Configuration files
βββ scripts/ # Utility scripts
βββ templates/ # Email templates
βββ tests/ # Test files
βββ app.ts # Express app configuration
βββ server.ts # Server entry point
See env.example for all available environment variables:
- Database: PostgreSQL connection string
- JWT: Authentication secrets and expiration times
- Email: SMTP configuration for email sending
- Cloudinary: File upload and storage
- Security: CORS, rate limiting, and other security settings
The template includes the following models:
- User: User authentication and profile management
- Media: File upload and metadata storage
# Build and start with docker-compose
npm run docker:compose
# Or build and run manually
npm run docker:build
npm run docker:run-
Build the application:
npm run build
-
Set up production environment:
cp env.example .env # Configure production environment variables -
Run database migrations:
npm run migrate:deploy
-
Start the application:
npm start
Comprehensive documentation is available in the DOCS/ directory:
- Quick Start Guide - Get started in 5 minutes
- API Documentation - Complete API reference
- Project Structure - Detailed project organization
- Deployment Guide - Production deployment
- Troubleshooting - Common issues and solutions
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverageThe project includes:
- ESLint for code linting
- Prettier for code formatting
- Husky for git hooks
- lint-staged for pre-commit checks
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
See Contributing Guide for detailed information.
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check the
DOCS/directory - Issues: Create an issue on GitHub
- Discussions: Use GitHub Discussions for questions
- Express.js - Web framework
- Prisma - Database ORM
- TypeScript - Type safety
- PostgreSQL - Database
Happy Coding! π