RESTful API backend for inventory management system with MongoDB integration
βοΈ Installation β’ π API Endpoints β’ β¨ Features β’ π¦ Tech Stack
This is a comprehensive RESTful API built with Node.js and Express.js for managing inventory, customers, products, and sales. The API provides full CRUD operations for all entities with MongoDB as the database backend.
Note: This was one of my first backend projects, demonstrating fundamental API development skills and database integration.
- πͺ Complete Inventory Management: Products with codes, descriptions, prices, and images
- π₯ Customer Management: Full customer database with contact information
- π Sales System: Sales tracking with customer relationships
- π Sales Details: Detailed breakdown of products sold per transaction
- π€ User Authentication: Basic user login system
- π RESTful API: Standard HTTP methods (GET, POST, PUT, DELETE)
- π Data Validation: Schema validation with Mongoose
- π Database Relationships: Proper references between collections
codigo: Unique product codenombre: Product namedescripcion: Product descriptionmarca: Brandprecio_venta: Selling priceprecio_compra: Purchase priceurl_img: Product image URLfecha_creacion: Creation date
nombres: First nameapellidos: Last namedni: National IDemail: Email addresscelular: Phone numberfecha_creacion: Creation date
descripcion: Sale descriptionfecha_venta: Sale dateid_cliente: Reference to customer
cantidad: Quantity soldid_producto: Reference to productid_venta: Reference to sale
username: Usernamepassword: Passwordnombre: First nameapellido: Last namedni: National IDrpta: Active statusventas: Array of sales references
GET /api/producto- Get all productsGET /api/producto/:cod- Get product by codePOST /api/producto- Create new productPUT /api/producto/:cod- Update product by codeDELETE /api/producto/:cod- Delete product by code
GET /api/cliente- Get all customersGET /api/cliente/:cod- Get customer by codePOST /api/cliente- Create new customerPUT /api/cliente/:cod- Update customer by codeDELETE /api/cliente/:cod- Delete customer by code
GET /api/venta- Get all sales (with customer data)GET /api/venta/:cod- Get sale by codePOST /api/venta- Create new salePUT /api/venta/:cod- Update sale by codeDELETE /api/venta/:cod- Delete sale by code
GET /api/detalleVenta- Get all sale details (with product data)GET /api/detalleVenta/:cod- Get sale detail by codePOST /api/detalleVenta- Create new sale detailPUT /api/detalleVenta/:cod- Update sale detail by codeDELETE /api/detalleVenta/:cod- Delete sale detail by code
GET /api/usuario- Get all usersGET /api/usuario/:cod- Get user by usernamePOST /api/usuario- Create new userPOST /api/login- User authenticationPUT /api/usuario/:cod- Update user by usernameDELETE /api/usuario/:cod- Delete user by username
- Clone the repository
git clone https://github.com/your-username/inventory-management-api
cd inventory-management-api- Install dependencies
npm install- Environment Setup
# Create .env file
cp .env.example .env
# Add your MongoDB connection string
MONGODB_URI=mongodb://localhost:27017/inventory_db
# or for MongoDB Atlas:
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/inventory_db- Start the server
# Development mode (with nodemon)
npm start
# The server will run on http://localhost:9000curl -X POST http://localhost:9000/api/producto \
-H "Content-Type: application/json" \
-d '{
"codigo": "PROD001",
"nombre": "Laptop Dell",
"descripcion": "Laptop Dell Inspiron 15",
"marca": "Dell",
"precio_venta": 1200,
"precio_compra": 1000,
"url_img": "https://example.com/laptop.jpg"
}'curl http://localhost:9000/api/productocurl -X POST http://localhost:9000/api/cliente \
-H "Content-Type: application/json" \
-d '{
"nombres": "Juan",
"apellidos": "PΓ©rez",
"dni": "12345678",
"email": "juan@email.com",
"celular": "987654321"
}'curl -X POST http://localhost:9000/api/login \
-H "Content-Type: application/json" \
-d '{
"username": "admin",
"password": "password123"
}'- RESTful Design: Follows REST API conventions
- Database Relationships: Proper MongoDB references and population
- Modular Structure: Clean separation of models, routes, and main app
- Error Handling: Basic error handling with try-catch blocks
- Data Validation: Mongoose schema validation
- Environment Configuration: Secure environment variable management
This project demonstrates:
- β Basic Express.js server setup
- β MongoDB integration with Mongoose
- β RESTful API design patterns
- β Database schema design
- β CRUD operations implementation
- β Environment configuration
- β Modular code organization
This project is licensed under the ISC License.
Jeremy - Full Stack Developer
This was one of my first backend projects, showcasing fundamental API development skills and database integration with MongoDB.