Skip to content

About

Inventory Management System – A full-stack application built with Python, FastAPI, Streamlit, and SQLite. Features RESTful CRUD APIs, an interactive inventory dashboard, Docker containerization, and cloud deployment on Render and Streamlit Community Cloud.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Inventory Management System

Animated Project Heading

A full-stack inventory management application built with Python, FastAPI, Streamlit, SQLite, and Docker.


🌐 Live Application

Component Platform Link
Frontend Streamlit Community Cloud https://inventory-management-sys.streamlit.app/
Backend API Render https://inventory-backend-ktbp.onrender.com
API Documentation FastAPI Swagger UI https://inventory-backend-ktbp.onrender.com/docs

📌 Overview

The Inventory Management System is a full-stack web application designed to manage product inventory through a modern dashboard and RESTful API.

The application allows users to create, view, update, and delete products while monitoring inventory information through an interactive Streamlit dashboard.

The project follows a separated frontend and backend architecture:

  • Frontend: Streamlit provides the interactive dashboard.
  • Backend: FastAPI handles API requests and business logic.
  • Database: SQLite stores product records.
  • Containerization: Docker packages the backend application.
  • Deployment: Render hosts the backend, while Streamlit Community Cloud hosts the frontend.

The frontend communicates with the backend through HTTP requests, making the application modular and easier to maintain.

✨ Key Features

📦 Product Management

  • Create new products.
  • View all available products.
  • Retrieve individual products by ID.
  • Update existing product information.
  • Delete products from inventory.

📊 Interactive Dashboard

  • View inventory records.
  • Monitor product information.
  • Display inventory statistics.
  • Manage products through an interactive interface.

⚙️ Backend Architecture

  • RESTful API development with FastAPI.
  • Data validation using Pydantic.
  • SQLite database integration.
  • HTTP exception handling.
  • CORS configuration for frontend-backend communication.

🐳 Deployment & Infrastructure

  • Dockerized backend application.
  • Separate frontend and backend deployment.
  • Backend deployment on Render.
  • Frontend deployment on Streamlit Community Cloud.
  • Environment-independent API communication through a deployed backend URL.

🏗️ System Architecture

The application follows a three-layer architecture.

flowchart TD
    A["👤 User"] --> B["🖥️ Streamlit Frontend"]
    B -->|"HTTP Requests"| C["🔗 FastAPI REST API"]
    C --> D["📋 Pydantic Validation"]
    D --> E["⚙️ Backend Logic"]
    E --> F[("🗄️ SQLite Database")]

    G["🐳 Docker Container"] -.-> C
    H["☁️ Render"] -.-> G
    I["☁️ Streamlit Cloud"] -.-> B
Loading

🔄 Request Lifecycle

  1. A user interacts with the Streamlit dashboard.
  2. The frontend sends an HTTP request using Python Requests.
  3. FastAPI receives the API request.
  4. Pydantic validates incoming product data.
  5. Backend functions communicate with the SQLite database.
  6. The API returns a JSON response.
  7. Streamlit updates the dashboard based on the response.

🛠️ Technology Stack

Technology Purpose
Python Core programming language
FastAPI Backend API framework
Streamlit Interactive frontend
Pydantic Request data validation
SQLite Database management
Requests HTTP communication
Docker Backend containerization
Render Backend hosting
Streamlit Cloud Frontend hosting
Git & GitHub Version control and source management

📂 Project Structure

FastApi-Project/
│
├── Backend/
│   ├── Backend.py
│   ├── database.py
│   ├── inventory.db
│   ├── requirements.txt
│   └── Dockerfile
│
├── Frontend/
│   ├── Frontend.py
│   ├── theme.py
│   └── requirements.txt
│
├── .gitattributes
└── README.md

🔌 REST API Documentation

The backend exposes RESTful endpoints for inventory operations.

Base URL

https://inventory-backend-ktbp.onrender.com

API Endpoints

Method Endpoint Description
POST /products/{product_id} Create a product
GET /products Retrieve all products
GET /products/{product_id} Retrieve a product by ID
PUT /products/{product_id} Update a product
DELETE /products/{product_id} Delete a product

📝 Product Data Schema

{
  "name": "Wireless Mouse",
  "category": "Electronics",
  "price": 45.99,
  "stock": 70
}

Example API Request

Create Product

POST /products/3
Content-Type: application/json
{
  "name": "Mechanical Keyboard",
  "category": "Electronics",
  "price": 120.50,
  "stock": 25
}

Example Response

{
  "message": "Product created successfully",
  "product": {
    "name": "Mechanical Keyboard",
    "category": "Electronics",
    "price": 120.5,
    "stock": 25
  }
}

API Documentation

FastAPI automatically generates interactive API documentation.

  • Swagger UI: /docs
  • ReDoc: /redoc

🧠 Technical Complexities & Engineering Challenges

This project involved several practical backend and deployment challenges.

1. Frontend and Backend Separation

Instead of building the entire application inside one Python file, the project separates frontend responsibilities from backend responsibilities.

Challenge: Maintaining communication between independently deployed applications.

Implementation: The Streamlit frontend communicates with the FastAPI backend through HTTP requests.

2. RESTful API Design

Implemented separate endpoints for product creation, retrieval, updating, and deletion.

Engineering considerations:

  • HTTP methods and status codes.
  • Dynamic route parameters.
  • JSON request and response handling.
  • Product ID validation.
  • Handling missing or duplicate products.

3. Database Integration

Integrated SQLite with the FastAPI backend to store and retrieve inventory records.

Engineering considerations:

  • Database initialization.
  • Product insertion.
  • Product retrieval.
  • Product updates.
  • Product deletion.
  • Database function separation.

4. Data Validation with Pydantic

Created a Product schema to validate incoming API data.

class Product(BaseModel):
    name: str
    category: str
    price: float
    stock: int

This helps ensure that incoming product information follows the expected structure and data types.

5. Docker Containerization

Packaged the FastAPI backend into a Docker image.

Engineering considerations:

  • Dockerfile configuration.
  • Python dependency installation.
  • Container startup commands.
  • Port configuration.
  • Docker image building and deployment.

6. Cross-Origin Resource Sharing (CORS)

Configured FastAPI's CORSMiddleware to allow requests from the deployed Streamlit frontend.

This enables communication between frontend and backend hosted on different domains.

7. Cloud Deployment

Deployed the frontend and backend independently.

  • Backend: Render with Docker.
  • Frontend: Streamlit Community Cloud.

This demonstrates practical experience with multi-service deployment and production-style application architecture.


🚀 Installation & Local Setup

Follow these steps to run the project locally.

Prerequisites

  • Python 3.10+
  • Git
  • Docker Desktop (optional, for containerized backend execution)

1. Clone the Repository

git clone YOUR_GITHUB_REPOSITORY_URL
cd FastApi-Project

2. Setup Backend

cd Backend

Create a virtual environment:

python -m venv venv

Activate it on Windows:

venv\Scripts\activate

Install dependencies:

pip install -r requirements.txt

Start the backend:

uvicorn Backend:app --reload

Backend URL:

http://127.0.0.1:8000

3. Setup Frontend

Open another terminal:

cd Frontend

Create and activate a virtual environment if needed, then install dependencies:

pip install -r requirements.txt

Run Streamlit:

streamlit run Frontend.py

Frontend URL:

http://localhost:8501

Important: For local frontend testing, configure the frontend API base URL to point to the local backend. For the deployed application, use the Render backend URL.


🐳 Docker Deployment

The backend is containerized using Docker.

Build Docker Image

Run from the project root:

docker build -t inventory-backend:1.0 ./Backend

Run Docker Container

docker run -d -p 8000:8000 --name inventory-api inventory-backend:1.0

Verify Container

docker ps

Test Backend

http://localhost:8000/docs

☁️ Deployment Architecture

Service Deployment Platform Responsibility
Frontend Streamlit Community Cloud User interface and dashboard
Backend Render REST API and application logic
Database SQLite Product data storage
Container Docker Backend packaging and runtime

The frontend and backend are deployed independently and communicate through the configured API URL.


🔐 Error Handling

The backend handles important product-related errors:

Scenario HTTP Status
Product created successfully 201
Product already exists 400
Product not found 404
Invalid request data 422

📈 Future Improvements

Potential enhancements for future versions:

  • 🔐 User authentication and role-based access.
  • 🗄️ PostgreSQL database integration.
  • 📦 Product image uploads.
  • 🔍 Advanced search and filtering.
  • 📊 Inventory analytics and reporting.
  • 📉 Low-stock alerts.
  • 📜 Product transaction history.
  • 🧪 Automated testing with Pytest.
  • 🔄 CI/CD pipeline integration.
  • 📋 Pagination and advanced API filtering.

🎯 Learning Outcomes

Building this project provided practical experience with:

  • Full-stack application architecture.
  • REST API development using FastAPI.
  • Pydantic data validation.
  • SQLite database operations.
  • Frontend-backend integration.
  • HTTP requests and API communication.
  • CORS configuration.
  • Docker image creation and container execution.
  • Cloud deployment using Render and Streamlit Community Cloud.
  • Debugging deployment and environment configuration issues.

👨‍💻 Author

Abdullah Asim

Full-Stack Developer | AI Development & Automation


Built with Python, FastAPI, Streamlit & Docker.
⭐ If you find this project useful, consider giving it a star!

About

Inventory Management System – A full-stack application built with Python, FastAPI, Streamlit, and SQLite. Features RESTful CRUD APIs, an interactive inventory dashboard, Docker containerization, and cloud deployment on Render and Streamlit Community Cloud.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages