Skip to content

Shahinshac/InventoryProject

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

InventoryProject

Simple Inventory + Billing CRUD API built with Python, FastAPI, and MongoDB.

Features

  • CRUD operations for 5 MongoDB collections: suppliers, products, customers, invoices, invoice_items
  • Billing endpoint to create an invoice from product line items
  • Automatic stock deduction during billing
  • Basic duplicate protections with MongoDB indexes

Tech Stack

  • Python
  • FastAPI
  • PyMongo
  • MongoDB

Project Structure

.
├── app
│   ├── __init__.py
│   ├── config.py
│   ├── database.py
│   ├── main.py
│   ├── schemas.py
│   └── utils.py
├── .env.example
├── .gitignore
├── README.md
└── requirements.txt

Setup

  1. Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Copy environment file and edit values if needed:
cp .env.example .env
  1. Ensure MongoDB is running (default URI in .env.example):
mongodb://localhost:27017
  1. Run API server:
uvicorn app.main:app --reload
  1. Open docs:
  • Swagger UI: http://127.0.0.1:8000/docs
  • ReDoc: http://127.0.0.1:8000/redoc

API Endpoints

Suppliers

  • POST /suppliers
  • GET /suppliers
  • GET /suppliers/{supplier_id}
  • PUT /suppliers/{supplier_id}
  • DELETE /suppliers/{supplier_id}

Products

  • POST /products
  • GET /products
  • GET /products/{product_id}
  • PUT /products/{product_id}
  • DELETE /products/{product_id}

Customers

  • POST /customers
  • GET /customers
  • GET /customers/{customer_id}
  • PUT /customers/{customer_id}
  • DELETE /customers/{customer_id}

Invoices

  • POST /invoices
  • GET /invoices
  • GET /invoices/{invoice_id}
  • PUT /invoices/{invoice_id}
  • DELETE /invoices/{invoice_id}

Invoice Items

  • POST /invoice-items
  • GET /invoice-items
  • GET /invoice-items/{invoice_item_id}
  • PUT /invoice-items/{invoice_item_id}
  • DELETE /invoice-items/{invoice_item_id}

Billing Workflow

  • POST /billing/invoices

Creates an invoice from product lines, inserts invoice items, and decreases stock.

Example Billing Request

curl -X POST "http://127.0.0.1:8000/billing/invoices" \
	-H "Content-Type: application/json" \
	-d '{
		"customer_id": "CUSTOMER_OBJECT_ID",
		"tax_rate": 0.05,
		"items": [
			{"product_id": "PRODUCT_OBJECT_ID_1", "quantity": 2},
			{"product_id": "PRODUCT_OBJECT_ID_2", "quantity": 1}
		]
	}'

Notes

  • MongoDB uses collections, which are the equivalent of SQL tables.
  • This project is intentionally simple and does not implement auth.

About

An inventory management system dashbaord for management of supplies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%