This is task that i have implement as a part of Zywa Recruitment Assignment , implemented the task with proper file structuring.The project involves processing data from a CSV file, storing it in a MongoDB database, and creating an API endpoint to retrieve the latest status of a card.
- We have given set of data for user's card.
- So implementd an endpoint to get status of user card.
- Node.js (javascript)
- Express
- MongoDb
- Mongoose
Main file is app.js, data folder contains provided CSV files, in User folder i am implementing all the business logic, SetUpData folder contains file to copy data from local store (data folder) into MongoDB database.
To run following project , follow these steps:
-
Clone the repository to your local machine (mycase it is ubuntu)
git clone https://github.com/dhakad22klx/Zywa-Assignment
-
Install the required packages.
cd Zywa-Assigment npm i
-
Start the application.
nodemon app.js
-
Open the application in your web browser and pass json in body having cardId as one attribute.
http://localhost:{3000}/user/getcardstatus
-
Schema Design: Four schemas are created to represent different card statuses. This design choice allows for efficient querying and retrieval of status data.
-
API Endpoint: An endpoint is created to provide a convenient interface for retrieving card statuses. The endpoint is designed to be intuitive and RESTful, accepting a card ID as input and returning the latest status.
-
Error Handling: Error handling middleware is implemented to gracefully handle errors and provide meaningful responses to clients.
-
Database Selection : We could have used SQL in place of NoSQL but i have choosed this one considering scalability in mind and easy to implement or data complexity in future.
-
Input Validation: Implement input validation to ensure that only valid card IDs are accepted by the API endpoint.
-
Authentication & Authorization: Add authentication and authorization mechanisms to secure the API endpoints and restrict access to authorized users.