https://www.loom.com/share/b672f6ce3dcb4f49807f02f523815ef3?sid=6e985aa6-10da-4c9b-b6b4-8269ebe7eddd
- Node.js (v14 or later)
- MongoDB
- Clone the repository
- Install dependencies
- Set up the environment variables:
Create a .env file in the project root folder and add the following variables:
MONGODB_URL
AWS_BUCKET_NAME
ACCESS_KEY_ID
SECRET_ACCESS_KEY
REGION
- Start the server:
npm run dev - The server will start running on
http://localhost:3000.
POST /categories: Create a new categoryGET /categories: Get all categoriesGET /categories/:id: Get a category by IDPUT /categories/:id: Update a category by ID
POST /subcategories/:categoryId: Create a new subcategory under a categoryGET /subcategories: Get all subcategoriesGET /subcategories/:id: Get a subcategory by IDPUT /subcategories/:id: Update a subcategory by ID
POST /items/subcategory/:subcategoryId: Create a new item under a subcategoryPOST /items/category/:categoryId: Create a new item under a categoryGET /items: Get all itemsGET /items/category/:categoryId: Get an item under categoryGET /items/subcategory/:subcategoryId: Get an item under subcategoryGET /items/getItemById/:id: Get an item by IDPUT /items/:id: Update an item by IDGET /items/search?name=<query>: Search for items by name
I have chosen MongoDB as the database for this application. MongoDB is a popular NoSQL database that offers flexibility, scalability, and ease of use. It's particularly well-suited for applications that require storing and retrieving data in a schema-less or flexible manner, which is often the case with menu management systems like guestara where the data structure can be complex and evolving.
Gained experience in designing and implementing a RESTful API for managing hierarchical data structures like categories, subcategories, and items. Learned how to handle nested data relationships using MongoDB's embedded document model and referencing.
The most difficult part of the assignment was implementing the search functionality for items by name. Handling regular expressions and case-insensitive searches required some research and understanding of MongoDB's query syntax. Additionally, ensuring proper error handling and input validation for the search endpoint was challenging.
Given more time, I would have:
Added more comprehensive input validation and error handling for all API endpoints. Implemented authentication and authorization mechanisms to secure the API routes. Introduced caching mechanisms to improve performance for frequently accessed data. Implemented pagination and sorting for endpoints that return large amounts of data.