Description: Upon opening the website, users are welcomed with a prominent heading stating "Cointab SE-ASSIGNMENT." Additionally, a button named "All Users" is displayed on the webpage.
Functionality:
- Clicking the "All Users" button fetches data from the specified API ('https://jsonplaceholder.typicode.com/users').
- Essential user information is displayed, including:
- Name
- Phone
- Website
- City
- Company
- Alongside the displayed user information, two buttons, "Open" and "Add," are provided.
- Initially, only the “Add” button is visible.
- Clicking the "Add" button stores all the user information retrieved from the API in the Mongodb database.
- If the database contains the user's entry, the "Open" button is shown, and the “Add” button is hidden.
- Clicking the "Open" button opens a new Post page.
Description: The Post Page fetches data from the API ('https://jsonplaceholder.typicode.com/posts?userId=${userId}') for the specific userId stored in the database.
Functionality:
- Essential user information is displayed, including:
- Name (corresponding to the specific userId)
- Title
- Body
- Company (associated with the particular userId)
- Two buttons, "Bulk Add" and "Download In Excel," are placed at the top of the page.
- Initially, only the "Bulk Add" button is visible.
- Clicking the "Bulk Add" button stores all the posts present on that page into the Mongodb database.
- If the database contains post entries for the specific userId, the "Bulk Add" button is hidden, and the "Download in Excel" button is shown.
- Clicking the "Download in Excel" button initiates the download of an Excel file containing all the post information for that particular user.
-
Node.js:
- Utilized as the server-side runtime environment.
-
MongoDb Database:
- Employed to store user and post data efficiently.
-
Express.js:
- Framework used to build the web application.
-
JavaScript (Frontend and Backend):
- Used for both client-side and server-side scripting.
-
HTML/CSS:
- Responsible for structuring and styling the web pages.
-
Seamless Integration:
- Demonstrates effective integration of Node.js, Express.js, MongoDb, and other technologies.
-
API Interaction:
- Fetches data from the provided API endpoints to display user and post information dynamically.
-
Database Operations:
- Implements database operations such as storing user and post information and checking for existing entries.
-
User Interaction:
- Provides a user-friendly interface with buttons for adding, opening, bulk adding, and downloading in Excel.
-
Cloud Hosting:
- Cyclic.sh.
This project showcases a well-structured and interactive web application that fulfills the specified business requirements while utilizing a stack of modern technologies.
- Route:
/
- Method: GET
- Description: Welcomes users to the backend.
- Response:
- Success: 200 OK
"Welcome to backend"
- Success: 200 OK
- Route:
/api/user/userdata
- Method: GET
- Description: Retrieves all user data from the database.
- Response:
- Success: 200 OK
{ "userIDs": ["userId1", "userId2", ...] }
- Error: 500 Internal Server Error
- Success: 200 OK
- Route:
/api/user/addNewUser
- Method: POST
- Description: Adds a new user to the database.
- Request Body:
{ "name": "User Name", "email": "user@example.com", "phone": "1234567890", "website": "https://example.com", "city": "City Name", "company": "Company Name", "userId": "uniqueUserId" }
- Response:
- Success: 200 OK
{ "message": "The user Data is added successfully" }
- Error: 500 Internal Server Error
- Success: 200 OK
- Route:
/api/user/:id
- Method: GET
- Description: Retrieves user data by user ID.
- Parameters:
id
: User ID
- Response:
- Success: 200 OK
{ "data": { // User Data Object } }
- Error: 500 Internal Server Error
- Success: 200 OK
- Route:
/api/post/addPostInBulk
- Method: POST
- Description: Adds bulk posts to the database.
- Request Body:
{ "data": [ { // Post Data Object }, { // Post Data Object }, ... ] }
- Response:
- Success: 200 OK
{ "message": "Bulk posts added successfully", "bulkPostAdded": [ // Array of added post objects ] }
- Error: 500 Internal Server Error
- Success: 200 OK
- Route:
/api/post/verifyUserId/:userId
- Method: GET
- Description: Verifies if a user ID exists in the database.
- Parameters:
userId
: User ID to verify
- Response:
- Success: 200 OK
or
{ "exists": true, "message": "userId already exists in the database" }
{ "exists": false, "message": "userId does not exist in the database" }
- Error: 500 Internal Server Error
- Success: 200 OK