CRUD Sample Blog designed and implemented in Angular 16 and NestJs with MongoDB and Google and Facebook Authentication. This is implemented based on the factory design pattern, with unit test coverage of 97%.
Follow the steps below to run both applications locally:
- Navigate to the "backend" directory.
- Install modules with
npm install
. - Set up the
.env
file to referencebackend/.env
. Ensure correct configuration. - Run the NestJs development server with
npm run start:dev
.
- Navigate to the "frontend" directory.
- Install the necessary modules with
npm install
. - Start the Angular development server with
ng serve
. - Open your web browser and go to http://localhost:4200.
This project consists of a UI Application in Angular, a Backend Service in NestJs,and a Bulk Data Generator script in Node.js. Let's explore each of these applications and their features.
A Front-End application built in Angular using RxJS Observables and Operators. It includes features like:
- Login through Google Account and Facebook.
- A dashboard page listing all the blogs created by users.
- A create blog page allowing users to enter Blog Title, Body, Category, and Tags.
- A blog detail page that opens when users click on a blog title in the dashboard.
- Logout functionality.
Additional Features:
Infinite Scroll is implemented on the dashboard page for paginated blog listings. It loads recent blogs first and dynamically adds more as users scroll down.
A Backend service created in NestJs with MongoDB database. Features include:
- Authentication via Google account and Facebook.
- Generation of application-specific JWT Access tokens upon successful Google and Facebook authentication.
- NestJs Passport and JWT libraries for user authentication.
- NestJs decorator to check the Bearer Access Token in request headers.
- APIs to get all user blogs, create a blog, and get a single blog by slug.
Additional Features:
- Implementation of Factory Method design pattern.
- Unit Test Cases for repositories, services, and helper methods with over 95% coverage.
- E2E Test cases for Get Blogs, Get Single Blog, and Create Blog APIs.
- Environment configuration for easy access to configuration-based values.
Unit test cases cover 95% of the backend codebase.
To get the test coverage : npm run test:cov
Scripts to generate bulk records in Node.js:
- Calls the endpoint to insert blogs one by one at 20ms intervals, capable of inserting almost 100k records in 3-5 mins.
- A bulk data generator script that directly inserts data into the MongoDB database.
- Automatically generates random article titles, bodies, categories, and tags for insertion.
- Install modules with
npm install
. - Run
node app.js
to insert data by calling the API one by one, capable of inserting up to 100k records in 3-5 mins. - Run
node bulk-generator.js
to insert data in bulk, capable of inserting up to 300k records in just 30-50 seconds.
Dockerfiles are set up for both the UI and backend applications to facilitate deployment to the cloud.
- Go to the UI App.
- Build the Docker image.
- Go to the Backend App.
- Build the Docker image.