TECH PIXEL

Welcome to Python Practice Projects at techtpixel.xyz — your one-stop hub to master Python through real-world, beginner to advanced projects. Learn by building web apps, scripts, automation tools, APIs, and more. Whether you're into data science, Django, Flask, or interview prep, our hands-on tutorials help you level up your skills and build a strong portfolio. Start coding smarter with practical Python challenges today!

Inventory Management & Cart API Using Flask — Full REST API Project

๐Ÿ›’ Inventory Management & Cart API Using Flask — Full REST API Project

๐Ÿ“Œ Author: Arooj Amina
๐Ÿ“ GitHub Repo: Inventory-Management-API
๐Ÿง  Tech Stack: Python, Flask, Flask-RESTful, SQLAlchemy, Marshmallow


๐Ÿš€ Project Overview

This project is a full-featured REST API for Inventory & Cart Management, built with Flask. It's ideal for managing products, stock, and a simple e-commerce cart system, all exposed via clean and organized API endpoints.

Whether you're managing a small warehouse or building a foundation for an e-commerce system, this API covers the essential features.


๐Ÿ”ง Features

๐Ÿ“ฆ Inventory Management API

  • ✅ Add, update, and delete products and categories

  • ๐Ÿ“Š Track stock quantity per product

  • ๐Ÿ” Handle stock changes like:

    • Restocking

    • Selling

    • Returning items

  • ๐Ÿ“‰ Endpoints to warn when stock is low

  • ๐Ÿ“† Date-based filtering for analytics (e.g., view items sold in last 7 days)



๐Ÿ›️ E-Commerce Cart API

๐Ÿ›’ Add or remove items from a user’s cart

๐Ÿ’ฐ Checkout system that:

Calculates the total
Deducts inventory
Clears the cart


๐Ÿ“‚ Project Structure

Inventory-Management-API/
│
├── app/
│   ├── __init__.py
│   ├── models/              # SQLAlchemy models
│   ├── schemas/             # Marshmallow schemas
│   ├── api/
│   │   ├── inventory/       # Product, category, stock APIs
│   │   └── cart/            # Cart APIs
├── config.py
├── requirements.txt
├── run.py                   # Main entry point

๐Ÿš€ How to Run This Project Locally

๐Ÿ”น 1. Clone the repository

git clone https://github.com/AroojAmina/Inventory-Management-API.git
cd Inventory-Management-API

๐Ÿ”น 2. Create & activate virtual environment

python -m venv env
source env/bin/activate   # On Windows: env\Scripts\activate

๐Ÿ”น 3. Install dependencies

pip install -r requirements.txt

๐Ÿ”น 4. Set environment variables (optional)

If required, configure config.py or use .env file.

๐Ÿ”น 5. Run the Flask app

python run.py

API will be available at http://localhost:5000/


๐Ÿงช Sample API Endpoints

๐Ÿ› ️ Product Management

Method Endpoint Description
GET /api/products/ List all products
POST /api/products/ Create new product
GET /api/products/<id> Get single product
PUT /api/products/<id> Update product
DELETE /api/products/<id> Delete product

๐Ÿ” Stock Movement

Endpoint Description
/api/stock/restock Add stock to product
/api/stock/sell Sell product
/api/stock/return Return product to stock
/api/stock/low-stock Get low-stock warnings

๐Ÿ›’ Cart System

Method Endpoint Description
POST /api/cart/add Add product to cart
POST /api/cart/remove Remove product from cart
GET /api/cart/view View cart contents
POST /api/cart/checkout Checkout and finalize

๐Ÿ“Š What Makes This Project Stand Out?

  • ๐Ÿ”„ Stock Movement Logic: Sell/return flows affect stock intelligently.

  • ๐Ÿ“‰ Low Stock Alerts: Helps keep stock levels in check.

  • ⏱️ Date Filtering: Track performance with time-based filters.

  • ๐Ÿงฑ Modular Code Structure: Easy to scale or convert to production.


๐Ÿ”š Conclusion

This project is a great foundation for anyone building an inventory system, POS backend, or basic e-commerce cart using Flask. It uses best practices like:

Class-based views (Flask-RESTful)
Schema validation (Marshmallow)
Clean separation of logic and routing


๐Ÿ”— Resources


๐Ÿ“Œ Note: This API is currently not deployed, but you can easily deploy it to platforms like Render, Railway, or Fly.io using free tiers.


Post a Comment

0 Comments