About • Key Feaures • Installation • Learn More • Contribute • Report Bug • Request Feature
Welcome, good sir or madam, to the esteemed Backend Repository! Herein lies a backend project, meticulously crafted in the wondrous realm of NestJS, making skillful use of the noble TypeScript, as well as the mighty tools of MySQL and TypeORM. This project faithfully adheres to the principles of Clean Architecture, guiding its structure with wisdom and foresight.
Behold, it boasts the power of JWT authentication with role-based authorization, ensuring the safeguarding of realms. Furthermore, it graciously accommodates multiple environment files for both the grand spectacle of production and the humble stages of development.
The noble objective of this endeavor is to serve as a robust foundation for the creation of backend applications, placing great emphasis on modularity, extensibility, and scalability. By harnessing the remarkable features of NestJS and TypeScript, along with the virtues of Clean Architecture, this project presents a reliable and flexible solution for building enterprise-grade backend systems.
- NestJS: Built on top of the popular Node.js framework, NestJS provides a robust and efficient foundation for developing scalable server-side applications.
- TypeScript: Leveraging the benefits of static typing, TypeScript enhances code readability, catch potential errors early, and enables better tooling and refactoring capabilities.
- MySQL: The project utilizes MySQL as the database system, ensuring reliable and efficient data storage and retrieval.
- TypeORM: With the help of TypeORM, a powerful and flexible Object-Relational Mapping (ORM) library, working with the database becomes effortless, providing a seamless experience for managing database operations.
- Clean Architecture: Following the principles of Clean Architecture, this project ensures separation of concerns, loose coupling, and a focus on testability, making it easier to understand, maintain, and extend the codebase.
- JWT Authentication: The project incorporates JWT-based authentication, providing a secure and stateless mechanism for user authentication and authorization.
- Multiple Environment Files: To cater to different environments, such as production and development, the project supports multiple environment files, enabling easy configuration and customization.
To use this project, follow these steps:
- Clone the repository from here.
- Install Dependencies: Navigate to the project directory and install the required dependencies using your preferred package manager. Run the following command:
npm install
# or
yarn install3.Configure Environment Variables: The project requires environment variables for configuration. Create the necessary .env files for different environments (e.g., .env.production and .env.development). These files should contain the specific configuration values for each environment.
-
Configure Database: Set up a MySQL database and update the database configuration in the .env file with the appropriate credentials.
-
Run the Project: Once the dependencies and environment variables are set up, you can start the project using the available scripts:
- Build: Builds the project and stores it into the dist directory. Run the following command:
npm run build- Start:local: Starts the local version of the project. Run the following command
npm run start:local- Start:dev: Starts the development version of the project with hot reload. It uses the nest.sh script, which terminates if the port is already in use. Run the following command:
npm run start:devNote: The start:dev script runs the nest.sh script, which terminates if the specified port is already in use.
That's it! After completing these steps, you will have the project set up and running on your local machine. You can now explore its features and functionalities.
To dive deeper into the concepts and technologies used in this project, refer to the following resources:
NestJS Official Documentation - Explore the official documentation of NestJS to gain a comprehensive understanding of the framework's features, modules, and best practices.
TypeScript Handbook - Visit the official TypeScript handbook to learn more about the language's syntax, types, and advanced features.
MySQL Documentation - Refer to the MySQL documentation for detailed information on setting up and working with MySQL databases.
TypeORM Documentation - Explore the official TypeORM documentation to learn how to use the library for database integration, migrations, and querying.
Clean Architecture Principles - Read Uncle Bob's blog post on Clean Architecture to understand the principles and benefits of building applications with a clean and modular architecture.
JSON Web Tokens (JWT) - Learn more about JSON Web Tokens and how they are used for authentication and authorization in web applications.
Feel free to explore these resources to enhance your knowledge and skills in developing backend applications using NestJS, TypeScript, MySQL, TypeORM, and Clean Architecture.
Contributions are welcome and greatly appreciated! To contribute to this project, please follow these guidelines:
- Fork the repository on GitHub.
- Create a new branch from the
mainbranch for your contribution. - Make your changes and ensure they follow the coding style and best practices used in the project.
- Write appropriate tests to validate your changes.
- Commit your changes with descriptive commit messages.
- Push your branch to your forked repository.
- Submit a pull request to the
mainbranch of the original repository. - Your pull request will be reviewed, and any necessary feedback or changes will be communicated.
- Once your pull request is approved, it will be merged into the
mainbranch. - Congratulations! You have successfully contributed to the project.
If you encounter any issues or have suggestions for improvements, you can open an issue on the GitHub repository. When opening an issue, please provide detailed information about the problem or feature request, including steps to reproduce the issue if applicable.
To report a bug, follow these steps:
- Go to the GitHub repository's "Issues" tab.
- Click on the "New Issue" button.
- Provide a descriptive title and a clear description of the bug.
- Include steps to reproduce the bug if possible.
- Add any relevant code snippets, screenshots, or error messages.
- Submit the issue, and it will be reviewed by the project maintainers.
Feel free to contribute, open issues, or report bugs. Your contributions will help improve the project and make it more robust and reliable.
This repository is derived from the exemplary work of Pavel Varentsov, found at https://github.com/pvarentsov/typescript-clean-architecture. In the pursuit of academic rigor, I have undertaken the task of reorganizing and streamlining the aforementioned work, eliminating overdesigns and overabstractions, while introducing novel features and refining outdated or suboptimal components, such as the implementation of hot-reload functionality. It is important to note that despite its foundational origins in Pavel Varentsov's work, this rendition stands as a distinct entity, diverging significantly in its composition and character.