From 7c8517e2c196a94e46359d8f641e8cb6b4eb9377 Mon Sep 17 00:00:00 2001 From: Janishar Ali Date: Mon, 19 Dec 2022 23:57:27 +0530 Subject: [PATCH] update readme --- README.md | 106 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index a10878f..5146089 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,56 @@ # Node.js Backend Architecture Typescript Project -Learn to build a Blogging platform like Medium, MindOrks, and FreeCodeCamp - Open-Source Project By Janishar Ali +A complete project to build a blogging platform like Medium, and FreeCodeCamp + +> Note: This is the **latest (version 2)** of the project. If you are using **version 1** then checkout the branch [**version-1**](https://github.com/janishar/nodejs-backend-architecture-typescript/tree/version-1)


-## About this Open Source Project -This open-source project is for you(community). I (https://janisharali.com) have taken this initiative to promote Backend Learning in the best possible way. I am determined to provide quality content for everyone. Let's do it together by learning from this project. +# Project Highlights +1. Node.js +2. Express.js +3. Typescript +4. Mongoose +5. Redis +6. Mongodb +7. Joi +8. Unit Tests & Integration Tests +9. Docker +10. JWT + +# About The Project +This project is designed to be used in a production ready environment. It will handle the scale and complexity of very demanding applications. This project is used by companies like Mindorks, AfterAcademy, and CuriousJr, having 10+ million usebase. + +It can be used to serve websites, mobile apps, and other API services. + +# About The Author +I, [Janishar Ali](https://janisharali.com) have created this project using my 10 years of experience in developing software for top tech companies. I enjoy sharing my learnings with the community. You can connect with me here: +* [Twitter](https://twitter.com/janisharali) +* [LinkedIn](https://www.linkedin.com/in/janishar-ali) +* [Instagram](https://www.instagram.com/janisharali) -## We will learn and build the backend application for a blogging platform. -The main focus will be to create a maintainable and highly testable architecture. +[Learn from My YouTube Channel](https://www.youtube.com/@janisharali) + +# Project Instructions +We will learn and build the backend application for a blogging platform. The main focus will be to create a maintainable and highly testable architecture.
Following are the features of this project: * **This backend is written in Typescript**: The type safety at build time and having intellisense for it in the IDE like vscode is unparalleled to productivity. We have found production bug reduced to a significant amount since most of the code vulnerabilities are identified during the build phase itself. -* **Separation of concern principle is applied**: Each component has been given a particular role. The role of the components is mutually exclusive. This makes the project easy to be unit tested. -* **Feature encapsulation is adopted**: The files or components that are related to a particular feature have been grouped unless those components are required in multiple features. This enhances the ability to share code across projects. -* **Centralised Error handling is done**: We have created a framework where all the errors are handled centrally. This reduces the ambiguity in the development when the project grows larger. -* **Centralised Response handling is done**: Similar to Error handling we have a response handling framework. This makes it very convenient to apply a common API response pattern. +* **Separation of concern principle**: Each component has been given a particular role. The role of the components is mutually exclusive. This makes the project easy to be unit tested. +* **Feature encapsulation**: The files or components that are related to a particular feature have been grouped unless those components are required in multiple features. This enhances the ability to share code across projects. +* **Centralised Error handling**: We have created a framework where all the errors are handled centrally. This reduces the ambiguity in the development when the project grows larger. +* **Centralised Response handling**: Similar to Error handling we have a response handling framework. This makes it very convenient to apply a common API response pattern. * **Mongodb is used through Mongoose**: Mongodb fits very well to the node.js application. Being NoSQL, fast, and scalable makes it ideal for modern web applications. -* **Async execution is adopted**: We have used async/await for the promises and made sure to use the non-blocking version of all the functions with few exceptions. +* **Redis Memcache**: We have used the redis server for caching the items which does not change frequently. It will boost the performance of our system. +* **Async execution**: We have used async/await for the promises and made sure to use the non-blocking version of all the functions with few exceptions. * **Docker compose has been configured**: We have created the Dockerfile to provide the easy deployability without any setup and configurations. * **Unit test is favored**: The tests have been written to test the functions and routes without the need of the database server. Integration tests has also been done but the unit test is favored. * **A pure backend project**: We have experienced that when a backend is developed clubbed with a frontend then in the future it becomes really difficult to scale. We would want to create a separate backend project that servers many websites and mobile apps. -## We have also open source a complete blogging website working on this backend project: [Goto Repository](https://github.com/janishar/react-app-architecture) -> In the above repository [**React.js Isomorphic Web Application Architecture**] we will learn and build a React web application for a blogging platform using this project as its API server. [Visit demo website](https://demo.react-app-architecture.afteracademy.com) +> We have also open source a complete blogging website working on this backend project: [Goto Repository](https://github.com/janishar/react-app-architecture) +The repository [**React.js Isomorphic Web Application Architecture**] has a complete React.js web application implemented for a blogging platform which is using this project as its API server. ## 3RE Architecture: Router, RouteHandler, ResponseHandler, ErrorHandler

@@ -51,7 +76,7 @@ Following are the features of this project: * [Implement JSON Web Token (JWT) Authentication using AccessToken and RefreshToken](https://janisharali.com/blog/implement-json-web-token-jwt-authentication-using-access-token-and-refresh-token) * [TypeScript Tutorial For Beginners](https://afteracademy.com/blog/typescript-tutorial-for-beginners) * [From JavaScript to TypeScript](https://afteracademy.com/blog/from-javascript-to-typescript) -* [Authentication vs Authorization](https://afteracademy.com/blog/authentication-vs-authorization) + ## You can find the complete API documentation [here](https://documenter.getpostman.com/view/1552895/SzYUZg52?version=latest) @@ -92,6 +117,11 @@ Following are the features of this project: ## Project Directory Structure ``` +├── .vscode +│ ├── settings.json +│ ├── tasks.json +│ └── launch.json +├── .templates ├── src │ ├── server.ts │ ├── app.ts @@ -106,7 +136,15 @@ Following are the features of this project: │ │ ├── ApiError.ts │ │ ├── ApiResponse.ts │ │ ├── JWT.ts -│ │ └── Logger.ts +│ │ ├── Logger.ts +│ │ └── utils.ts +│ ├── cache +│ │   ├── index.ts +│ │   ├── keys.ts +│ │   ├── query.ts +│ │   └── repository +│ │   ├── BlogCache.ts +│ │   └── BlogsCache.ts │ ├── database │ │ ├── index.ts │ │ ├── model @@ -123,22 +161,29 @@ Following are the features of this project: │ │ └── UserRepo.ts │ ├── helpers │ │ ├── asyncHandler.ts +│ │ ├── permission.ts │ │ ├── role.ts +│ │ ├── security.ts +│ │ ├── utils.ts │ │ └── validator.ts │ ├── routes │ │ └── v1 │ │ ├── access +│ │ │ ├── credential.ts │ │ │ ├── login.ts │ │ │ ├── logout.ts │ │ │ ├── schema.ts │ │ │ ├── signup.ts -│ │ │ └── token.ts +│ │ │ ├── token.ts +│ │ │ └── utils.ts │ │ ├── blog -│ │ │ ├── blogDetail.ts -│ │ │ ├── blogList.ts │ │ │ ├── editor.ts +│ │ │ ├── index.ts │ │ │ ├── schema.ts │ │ │ └── writer.ts +│ │   ├── blogs +│ │   │   ├── index.ts +│ │   │   └── schema.ts │ │ ├── index.ts │ │ └── profile │ │ ├── schema.ts @@ -163,22 +208,27 @@ Following are the features of this project: │ │ └── jwt │ │ ├── mock.ts │ │ └── unit.test.ts +│ ├── cache +│ │ └── mock.ts +│ ├── database +│ │ └── mock.ts │ ├── routes │ │ └── v1 -│ │ ├── blog -│ │ │ ├── blogDetail +│ │ ├── access +│ │ │ ├── login +│ │ │ │ ├── integration.test.ts │ │ │ │ ├── mock.ts │ │ │ │ └── unit.test.ts -│ │ │ └── writer +│ │ │ └── signup │ │ │ ├── mock.ts │ │ │ └── unit.test.ts -│ │ ├── login -│ │ │ ├── integration.test.ts -│ │ │ ├── mock.ts -│ │ │ └── unit.test.ts -│ │ └── signup -│ │ ├── mock.ts -│ │ └── unit.test.ts +│ │ └── blog +│ │ ├── index +│ │ │ ├── mock.ts +│ │ │ └── unit.test.ts +│ │ └── writer +│ │ ├── mock.ts +│ │ └── unit.test.ts │ ├── .env.test │ └── setup.ts ├── addons @@ -194,8 +244,6 @@ Following are the features of this project: ├── .prettierrc ├── .prettierignore ├── .travis.yml -├── .vscode -│ └── launch.json ├── Dockerfile ├── docker-compose.yml ├── package-lock.json