Manage Stock. Track Sales. Grow Business.
StockMate is a modern, high-performance, transaction-safe Inventory and Sales Management System built to streamline daily business operations. Developed primarily to demonstrate core backend engineering proficiency in Python, RESTful API design, database normalization, and robust concurrency handling.
Whether you run a single retail storefront or coordinate a multi-channel operation, StockMate provides business owners and counter employees with a secure, responsive, and visually stunning tool to control stock levels, log sales, track procurement, and analyze financial performance.
- Retail Stores & Shop Owners โ Fast invoice generation and real-time stock deductions.
- Wholesalers & Distributors โ Track bulk purchasing lists and vendor relations.
- Warehouses & Small Businesses โ Automated alerts for low stock levels and expiring products.
- ๐ Live Demo
- ๐ธ Screenshots
- ๐ Features
- ๐ ๏ธ Technology Stack
- ๐ Project Structure
- ๐๏ธ Database Schema
- ๐ Application Workflow
- ๐ป Installation Guide
- ๐ Environment Variables
- ๐ API Documentation
- โ๏ธ Deployment
- ๐ฎ Future Improvements
- ๐ฏ Why This Project
- โ๏ธ Author
Explore the live application and interactive API documentation:
| Service | Endpoint / Link | Description |
|---|---|---|
| Frontend / Web App (Render) | https://stockmate-vlpq.onrender.com/ | Access the dashboards and UI screens. |
| Frontend / Web App (Railway) | https://stock-mate.up.railway.app/ | Access the dashboards and UI screens. |
| API Documentation | https://stock-mate.up.railway.app//docs | Interactive Swagger UI for REST endpoint testing. |
Provides secure, session-managed entry points for Owners and Employees.
Provides Owner-only financial analytics including daily sales, monthly revenue trend charts, and alert summaries.
A clean workspace for sales agents to record sales and check products.
Real-time product grid with automated visual warnings for Expired, Low Stock, and Expiring Soon items.
Maintains a registry of customer contact details and transaction history.
Tracks contact information and purchase history for replenishment vendors.
Enables employees to draft restocking orders, awaiting owner approval before updating inventory.
Interactive multi-item checkout builder that dynamically computes prices, sub-totals, and GST.
Sample dynamic invoice generated programmatically with full business branding and GST calculations.
Provides customized date filters for profit analysis and data exporting.
Chart.js graphics representing revenue flow, category distributions, and top product metrics.
Displays warning notifications for low stock thresholds and approaching expiry dates.
- Secure Login / Logout: Uses HTTP-Only secure cookies to manage state and session tokens.
- Role-Based Access Control (RBAC): Restricts administrative modules (Audit Logs, Reports, Employee registers) strictly to
Owneraccounts, while permitting counter checkout processes toEmployeecredentials. - Password Hashing: Implements secure one-way hashing algorithms (bcrypt) to safely store credentials.
- Route Protection: Validates JWT payloads on every requests to prevent session hijacking.
- Product Catalog: Full CRUD capabilities for recording product cost prices, selling prices, stock levels, and expiry alerts.
- Nested Categories: Standardizes hierarchical categorization with cascading validations.
- Low Stock Warnings: Computes dynamic warnings whenever product levels drop below their minimum threshold.
- Expiry Tracking: Flags items automatically as "Expired" or "Expiring Soon" (within 30 days) to prevent waste.
- Search & Filters: Multi-parameter search by keyword, category, and alert status.
- Customer Ledger: Integrates customer contact numbers and emails with their historical purchases.
- Multi-Product Checkout: Point-of-sale interface to build, adjust, and submit sales with live price updates.
- Atomic Deductions: Utilizes database-level locking (
.with_for_update()) to prevent race conditions during concurrent checkouts, rolling back transactions completely if any item check fails. - Profit Calculations: Calculates revenue margins per line item and stores aggregates for financial reporting.
- Supplier Directory: Manages vendor contacts and logs previous procurement transactions.
- Purchase Orders: Standardizes replenishment drafts. Stock levels and average unit cost prices are only updated upon Owner approval.
- Live Dashboards: High-impact dashboards rendering charts for Daily Sales, Monthly Trends, Category distribution, and Top-Selling inventory.
- Financial Reports: Custom interval queries (Today, Yesterday, Last 7 Days, Month, Year, Custom Range) compiling net revenues and margins.
- Data Streams: Streams large datasets directly into CSV files for Excel importing.
- PDF Billing: Instantly generates clean PDF invoice sheets formatted with client and server information using ReportLab.
| Component | Technology | Description |
|---|---|---|
| Backend | Python | Core application runtime. |
| FastAPI | High-performance, asynchronous REST framework. | |
| Frontend | HTML5 & CSS3 | Dynamic page structures. |
| Bootstrap 5 | Responsive layout styling and dark custom glassmorphic overrides. | |
| Vanilla JavaScript | Asynchronous fetches, dynamic form rows, and modal interactions. | |
| Database | MySQL / SQLite | Relational transactional databases. |
| SQLAlchemy | Database Object Relational Mapper (ORM) with transaction manager. | |
| Validation | Pydantic | Strict runtime schema parsing and request verification. |
| Visualizations | Chart.js | Renders HTML5 Canvas dashboards. |
| Reporting | ReportLab | Generates dynamic PDF invoice streams. |
| Deployment | Railway | Cloud hosting with automated continuous deployment. |
| VCS | Git & GitHub | Source code management. |
StockMate/
โ
โโโ app/
โ โโโ auth/ # Security dependencies, role tokens, and bcrypt hashing
โ โโโ models/ # SQLAlchemy Database structures (User, Sale, Product, etc.)
โ โโโ routers/ # REST Endpoints and HTML controllers
โ โโโ schemas/ # Pydantic schemas for payload validation
โ โโโ static/ # Frontend assets (CSS styles, JS modules, logo images)
โ โโโ templates/ # Jinja2 templates (dashboard layouts, invoices, modals)
โ โโโ utils/ # Business helpers (PDF builder, CSV exporter, logger)
โ โโโ config.py # Settings parser with environment variables
โ โโโ database.py # Database engine setup and local session getters
โ โโโ main.py # Main ASGI app init, middleware, and startup triggers
โ
โโโ tests/ # Unit and integration test suites (Pytest)
โโโ screenshots/ # UI image walkthrough files
โโโ Procfile # Railway process commands
โโโ runtime.txt # Python compiler instructions
โโโ requirements.txt # Python dependency package manifests
โโโ stockmate.db # SQLite database for local development
StockMate uses a normalized, relational database schema configured with foreign key constraints, indexes for rapid querying, and cascade rules.
โโโโโโโโโโโโโโ
โ Categories โ
โโโโโโโโฌโโโโโโ
โ 1
โ
โ *
โโโโโโโโโโโโโ โโโโโโโโดโโโโ โโโโโโโโโโโโโโ
โ Suppliers โโโโโโโโค Products โโโโโโโโค Sale_Items โ
โโโโโโโฌโโโโโโ 1 โโโโโโโโโโโโ * โโโโโโโฌโโโโโโโ
โ โ *
โ 1 โ
โโโโโโโดโโโโโโ โ 1
โ Purchases โ โ
โโโโโโโฌโโโโโโ 1 โ
โ โ
โ * โ
โโโโโโโดโโโโโโโโโโโโโโโโโ โโโโโโโดโโโโ
โ Purchase_Order_Items โ โ Sales โ
โโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโฌโโโโโ
โ *
โ
โ 1
โโโโโโดโโโโโโโ
โ Customers โ
โโโโโโโโโโโโโ
users- Stores credential hashes and system designations (
OwnerorEmployee). - Relationships: Has a one-to-many relationship with
sales(employee who processed the sale) andaudit_logs(user who triggered the event).
- Stores credential hashes and system designations (
categories- Manages classifications for products (e.g., Electronics, Groceries).
- Relationships: One-to-many relationship with
products. Removing a category cascades validation to prevent orphaned products.
products- Stores core inventory specifications, pricing structures, stock counts, and expiry thresholds.
- Relationships: Belongs to a single
category. Linked tosale_itemsandpurchase_order_items.
suppliers- Stores procurement vendor profiles.
- Relationships: Has a one-to-many relationship with
purchasesorders.
purchases- Tracks restocking requests. Statuses include
PendingandCompleted. - Relationships: Belongs to a
supplier. Has manypurchase_order_items.
- Tracks restocking requests. Statuses include
purchase_order_items- Stores the breakdown details of a purchase order (product quantities, unit costs).
- Relationships: Connects
purchasesto the specificproductsbeing restocked.
customers- Records retail and corporate clients.
- Relationships: One-to-many relationship with
salesinvoices.
sales- Represents transactions. Compiles revenue totals, profit aggregates, and GST.
- Relationships: Linked to a
customerand the processingemployee(fromusers). Has manysale_items.
sale_items- Individual invoice lines storing historical transaction pricing and counts.
- Relationships: Pairs each
salesrecord toproducts.
company_profile/business_settings- Stores meta details like Business Name, Address, GST Registration Number, and Tax rates used in PDF headers.
notifications- Caches warnings for products with low stock levels or expiring dates.
audit_logs- Records security-sensitive operations. Tracks timestamps, actions, target descriptions, and IP addresses.
[Login Screen] โโ> [Verify Credentials] โโ> [Check Role: Owner or Employee?]
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ โผ
[Owner Dashboard] [Employee Dashboard]
* Visual Analytics & Charts * Personal Sales Counter
* View Full Audit Logs & Reports * Quick POS Access
* Manage Employee Accounts & CRUD Controls * Search Inventory Details
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ
[Billing/POS Screen]
โ
โผ
[Select Customer & Products]
โ
โผ
[Atomic Stock & Inventory Checks]
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโ
โผ (Success) โผ (Insufficent Stock)
[Update Stock Quantities] [Rollback Transaction]
โ โ
โผ โผ
[Commit Sale & Log Actions] [Display Error Banner]
โ
โผ
[Generate Dynamic PDF Invoice]
- Python 3.9 or higher.
- MySQL Server (optional, defaults to SQLite local developer database).
Clone this repository to your local directory:
git clone https://github.com/YOUR_GITHUB_REPOSITORY/StockMate.git
cd StockMateInitialize a local python virtual environment to isolate package dependencies:
python -m venv .venvActivate the environment:
- Windows (Command Prompt / PowerShell):
.venv\Scripts\activate
- macOS / Linux:
source .venv/bin/activate
Install all dependencies using pip:
pip install -r requirements.txtCopy the environment variables template and configure your parameters:
cp .env.example .env(On Windows cmd: copy .env.example .env)
Update the values inside .env (such as changing the Database URL to point to SQLite or your MySQL Server instance).
Run the FastAPI development server:
uvicorn app.main:app --port 8000 --reloadOn startup, StockMate automatically sets up all database tables and seeds default user roles.
Navigate to: http://127.0.0.1:8000 Log in with the default credentials:
- Owner Dashboard:
owner@stockmate.com(password:owner123) - Employee Dashboard:
employee@stockmate.com(password:employee123)
Create a .env file in the project root directory:
# Application Settings
APP_ENV=development # Options: development, production
SECRET_KEY=yoursecretkey123!@# # Used for signing cookie sessions
# Database Configuration
# For SQLite (default development):
DATABASE_URL=sqlite:///./stockmate.db
# For MySQL (production):
# DATABASE_URL=mysql+pymysql://username:password@localhost:3306/stockmate_dbStockMate exposes standard OpenAPI documentation, allowing developers to explore and interact with backend REST APIs:
- Interactive Swagger UI: http://127.0.0.1:8000/docs
- Alternative ReDoc UI: http://127.0.0.1:8000/redoc
StockMate is pre-configured for instant deployment on Railway:
- Procfile: Tells Railway to launch Uvicorn and bind to the correct host and port:
web: uvicorn app.main:app --host 0.0.0.0 --port $PORT - Environment Configuration: Add these variables in the Railway console:
APP_ENV=productionSECRET_KEY=[YourRandomCryptographicKeyString]DATABASE_URL=[YourProductionMySQLConnectionString]
- Database Migrations: Database tables are initialized automatically on application startup.
Here is the development roadmap for future releases of StockMate:
- ๐ Barcode Scanner Integration โ Scan item barcodes directly via browser camera.
- ๐ฑ QR Codes on Invoices โ Render payment QR codes on dynamic invoices.
- โ๏ธ Email Invoices โ E-mail PDF invoices to customers automatically.
- ๐ฌ WhatsApp Invoices โ Send digital invoice receipts directly to WhatsApp.
- ๐ข Multi-Store Management โ Manage inventory across multiple stores.
- ๐ Warehouse Transfers โ Coordinate stock movements between warehouse units.
- ๐ฑ Native Mobile App โ Develop a companion app for inventory checks on the go.
- ๐ค AI Demand Forecasting โ Predict restocking requirements based on sales trends.
This project was built to demonstrate proficiency in core web backend concepts:
- REST APIs: Designed using clean HTTP methods and structured JSON payloads.
- Authentication & Authorization: Handled via HTTP-only cookie sessions and JWT parsing.
- Database Design: Structured relational schema with database-level indexes and atomic operations.
- Business Logic: Real-world operations like cost accounting, tax collection, and product life-cycle alerts.
- Data Validations: Strict client/server validation using Pydantic.
- Reporting: Programmatic file generation (PDF & CSV streams) built dynamically.
It showcases the ability to design, build, and deploy production-ready systems using the Python ecosystem.
Jay Jadhav
- LinkedIn: https://linkedin.com/in/jayjadhav04
- Email: jaydjadhav1111@gmail.com
- Portfolio: https://jay-jadhav-portfolio.vercel.app/
