This Node.js backend server manages menus divided into categories, subcategories, and items. It provides APIs to create, retrieve, update, and search for categories, subcategories, and items.
-
Clone this repository.
git clone https://github.com/Atif-27/Menu_Management.git
-
Change Directory
cd Menu_Management
-
Install dependencies.
npm install
-
Set Up your env file
DB_URI=mongodb+srv://atif276ali:[email protected]/menu?retryWrites=true&w=majority&appName=Cluster0 PORT=9000
-
Run the server.
npm start
-
You can now use Postman or any API client to interact with the server. Here is my postman collection Link
-
Imp Note - Select the New environment mode otherwise routes wont be working
-
Paste the URL in initial and current value of the environment in case of error
menu-management-three.vercel.app/api/v1
- Node.js: JavaScript runtime
- Express.js: Web application framework for Node.js
- MongoDB: NoSQL database for storing menu data
- Mongoose: MongoDB object modeling for Node.js
- Zod: TypeScript-inspired schema validation library for JavaScript
Model | Description |
---|---|
Category | Represents a menu category |
Subcategory | Represents a subcategory of a category |
Item | Represents an item in a subcategory |
Route | Method | Description |
---|---|---|
/api/v1/categories |
POST | Create a new category |
/api/v1/categories |
GET | Get all categories |
/api/v1/categories/:id |
GET | Get a single category by ID or name |
/api/v1/categories/:id |
PUT | Update a category by ID |
Route | Method | Description |
---|---|---|
/api/v1/subcategories |
POST | Create a new subcategory |
/api/v1/subcategories |
GET | Get all subcategories |
/api/v1/subcategories/category/:id |
GET | Get all subcategories under a category |
/api/v1/subcategories/:id |
GET | Get a single subcategory by ID or name |
/api/v1/subcategories/:id |
PUT | Update a subcategory by ID |
Route | Method | Description |
---|---|---|
/api/v1/items |
POST | Create a new item |
/api/v1/items |
GET | Get all items |
/api/v1/items/category/:id |
GET | Get all items under a category |
/api/v1/items/subcategory/:id |
GET | Get all items under a subcategory |
/api/v1/items/:id |
GET | Get a single item by ID or name |
/api/v1/items/:id |
PUT | Update an item by ID |
/api/v1/items/search/:name |
GET | Search items by name |
-
Which database have you chosen and why? I have chosen MongoDB because of its flexibility with JSON-like documents, scalability, and ease of use, which aligns well with the dynamic nature of menu management data.
-
3 things that you learned from this assignment?
- Enhanced my understanding of building RESTful APIs with Express.js.
- Gained experience in schema validation using Zod.
- Learned more about managing relationships between MongoDB collections.
-
What was the most difficult part of the assignment? Designing and implementing the database schema to handle the relationships between categories, subcategories, and items efficiently.
-
What would you have done differently given more time? Given more time, I would have integrated multer for image uploads, used Cloudinary for image storage, implemented pagination for limiting API responses, and added sorting capabilities for better data organization and scalability.