Skip to content

asmien/Python-REST-API-with-Flask--Inventory-Management-System-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛒 Inventory Management System (Flask REST API)

📌 Overview

This project is a Flask-based REST API for managing inventory in a retail system. It allows users to perform full CRUD operations on products and integrates with the OpenFoodFacts API to fetch real-world product data using barcodes.

The system also includes a CLI (Command Line Interface) for user interaction and a testing suite to validate functionality.


🚀 Features

✅ Inventory Management (CRUD)

  • Add new items
  • View all inventory items
  • View a single item by ID
  • Update item price and stock
  • Delete items

🌐 External API Integration

  • Fetch product details using barcode

  • Retrieve:

    • Product name
    • Brand
    • Ingredients

💻 CLI Interface

  • User-friendly terminal menu
  • Perform all operations without a browser

🧪 Testing

  • Unit tests using pytest

  • Covers:

    • API endpoints
    • CRUD operations
    • External API route

🛠️ Technologies Used

  • Python 3
  • Flask
  • Requests
  • Pytest

📁 Project Structure

inventory-api/
│
├── app.py           # Main Flask API
├── inventory.py     # In-memory database (list)
├── cli.py           # Command-line interface
├── test_app.py      # Unit tests
├── requirements.txt # Dependencies
└── README.md        # Documentation

⚙️ Installation & Setup

1. Clone the repository

git clone https://github.com/YOUR_USERNAME/inventory-api.git
cd inventory-api

2. Create virtual environment

python3 -m venv venv
source venv/bin/activate   # Linux/Mac
venv\Scripts\activate      # Windows

3. Install dependencies

pip install -r requirements.txt

▶️ Running the Application

Start Flask server

python app.py

Server runs at:

http://127.0.0.1:5000/

🌐 API Endpoints

Method Endpoint Description
GET /inventory Get all items
GET /inventory/ Get one item
POST /inventory Add item
PATCH /inventory/ Update item
DELETE /inventory/ Delete item
GET /fetch/ Fetch product from API

🧪 Testing the API

🔹 Browser (GET requests only)

Open:

http://127.0.0.1:5000/inventory
http://127.0.0.1:5000/fetch/737628064502

🔹 CLI (Full interaction)

Run:

python cli.py

You can:

  • Add items
  • View inventory
  • Update items
  • Delete items
  • Fetch product data

🔹 Automated Tests

Run:

pytest

Expected output:

6 passed

⚠️ Notes

  • The inventory is stored in memory (resets when server restarts)
  • External API may fail depending on network environment
  • Error handling is implemented for API failures

📈 Future Improvements

  • Persistent database (SQLite/PostgreSQL)
  • Web frontend (React)
  • Authentication system
  • Auto-save fetched products into inventory

👤 Author

Samantha Bora


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages