Welcome to Personal Backend Starter, a backend project created for personal use and learning. This project allows me to explore new technologies and best practices while building a reusable and scalable backend structure. Inspired by Mucahit Nezir's express-starter and Ghostlexly's ultimate-expressjs-starter-kit, this project incorporates ideas from these amazing starters, with my own adaptations and enhancements.
While it’s a personal learning project, feedback and contributions are more than welcome! 😊
- Learning and experimentation:
An opportunity to explore tools and technologies I don’t frequently use, such as Drizzle ORM, Redis, AWS S3, Sentry, and Biome. - Building a reusable starter:
A modular and scalable structure, suitable for future projects. - Applying best practices:
Adherence to TypeScript, modern tools, and clean architecture for maintainability.
- Authentication and Security:
JWT-based authentication, session management, and middleware for rate-limiting and secure headers. - File Uploads and Storage:
File handling with AWS S3 for reliable storage. - Caching:
Performance boost with Redis for caching. - Schema Validation:
Strong runtime and compile-time validations with Zod. - Error Tracking:
Seamless integration with Sentry for error monitoring and performance profiling. - Code Quality:
Tools like Biome, Prettier, and ESLint to maintain consistent, clean code. - Email Support:
Prebuilt email templates for various use cases, powered by Nodemailer.
The project is designed with scalability and maintainability in mind.
src: Main source code.common: Shared utilities, configurations, middleware, providers, and schemas.modules: Feature-specific logic (e.g.,auth,note,sample).
- Key Files:
app.ts: Application initialization with middleware and configurations.index.ts: Entry point of the application..env: Environment variables configuration.
The architecture is inspired by:
- Mucahit Nezir’s Express Starter:
A minimal yet scalable starter for Express.js applications. - Ghostlexly’s Ultimate Express Starter Kit:
A feature-packed starter with advanced implementations.
This project uses a modern stack to ensure robustness, performance, and developer productivity.
- Node.js and Express.js:
The foundation for building and managing the server, routes, and middleware. - TypeScript:
Enforces static typing, improving code safety and scalability.
- Drizzle ORM:
A lightweight and type-safe ORM for database management. - Redis:
In-memory data store for caching and session management. - AWS S3:
Reliable file storage for uploads and backups. - Zod:
Schema validation for ensuring data integrity. - Nodemailer:
For email handling, such as account confirmation and password reset.
- Sentry:
Provides error monitoring, performance profiling, and issue tracking.
With Sentry, unexpected crashes or performance bottlenecks are logged for quick resolution.
- Biome:
All-in-one linter, formatter, and code analyzer for maintaining consistent code quality.
It replaces tools like ESLint and Prettier while supporting TypeScript out of the box. - Prettier:
For automated code formatting, ensuring readability and consistency. - ESLint:
Helps enforce best practices and catch potential issues during development.
Clone the repository and install dependencies:
git clone <repo-url>
cd personal-backend-starter
npm installSet up the .env file:
PORT=3000
DATABASE_URL=your_database_url
JWT_SECRET=your_secret_key
REDIS_URL=your_redis_url
AWS_S3_BUCKET=your_bucket_name
AWS_ACCESS_KEY=your_access_key
AWS_SECRET_KEY=your_secret_key
SENTRY_DSN=your_sentry_dsn
-
Development Mode:
npm run dev
-
Production Mode:
npm run build && npm start
-
Run Biome for linting and formatting:
npm run lint
-
Automatically fix linting issues:
npm run lint:fix
- Scalability:
A modular architecture that supports the addition of features with minimal refactoring. - Error Monitoring:
With Sentry, all errors and performance issues are logged for debugging and analysis. - Developer Productivity:
Tools like Biome and Prettier ensure a seamless development experience. - Performance:
Redis caching reduces database load, while optimized middleware enhances overall speed. - Security:
Secure headers, JWT authentication, and rate-limiting for a safer backend.
This project is intended as a starting point. Feel free to:
- Add, swap, or remove dependencies:
Replace tools or libraries to suit your project’s requirements or your preferred workflow. For example:- Swap Drizzle ORM for Prisma or TypeORM.
- Replace Redis with Memcached if needed.
- Modify the architecture:
Extend or simplify the modular design based on your project's complexity. - Customize middleware and configurations:
Adjust middleware like rate limiting, logging, and validation to meet your needs.
The project is designed to be flexible and adaptable, so make it your own!
This project is personal but open to improvements and suggestions. If you have feedback or ideas for enhancement:
- Open an issue or pull request on GitHub.
- Suggest new technologies or patterns that could further refine the project.
Thank you for exploring my Personal Backend Starter! 🚀