A comprehensive CRM + Inventory + Purchase Tracking system built with Streamlit and SQLite, featuring advanced analytics, enhanced data models, and professional-grade business management capabilities.
- Real-time revenue, orders, items sold, average order value
- Customer metrics: total customers, repeat rate, new customers
- Revenue trends with interactive charts
- Top 5 products and customers
- Recent purchase activity
- Date range filters (Today, Last 7/30/90 Days, All Time)
- Complete customer profiles with address, city, state, postal code
- Customer types: retail, wholesale, corporate
- Company information and tax ID for B2B customers
- Email, phone, and contact details
- Search and filter across all fields
- Loyalty points tracking
- Purchase history per customer
- Active/inactive status management
- Professional product catalog with SKU and barcode
- Dual pricing: selling price and cost price (profit margin tracking)
- Inventory management with automatic stock updates
- Reorder levels and quantities for low-stock alerts
- Multi-level categorization: category, subcategory, brand
- Product tags for flexible organization
- Multiple unit types: piece, kg, liter, meter, pack
- Supplier tracking
- Featured products flag
- Status: available, out of stock, discontinued
- Easy purchase recording with customer and product selection
- Flexible discount options: percentage or fixed amount
- Tax calculation (GST/VAT support)
- Multiple payment methods: cash, card, UPI, bank transfer, credit
- Payment status tracking: paid, pending, partial, refunded
- Order status: completed, pending, cancelled, returned
- Delivery status tracking
- Transaction ID for digital payments
- Automatic stock deduction
- Real-time order summary calculations
- Sales Analytics: Monthly breakdown, revenue trends, sales pivot tables
- Customer Analytics: Top customers by revenue/orders, retention metrics, repeat rate
- Product Analytics: Best sellers by quantity/revenue, category performance
- Payment Analytics: Revenue breakdown by payment method, transaction analysis
- Low-stock alerts with reorder recommendations
- Customer retention and engagement metrics
- Product performance tracking
- Automatic timestamp tracking (created_at, updated_at)
- Database triggers for status updates
- 11 database indexes for optimized performance
- Data validation at multiple levels
- Error handling and user-friendly messages
- Session state management for smooth UX
- Responsive design with custom styling
- Frontend: Streamlit (modern, responsive UI)
- Backend: Python with OOP principles
- Database: SQLite3 with enhanced schema
- Analytics: pandas for data processing
- Visualization: Altair for interactive charts
- Architecture: Layered design (UI β Business Logic β Database)
- Python 3.8 or higher
- pip (Python package manager)
git clone <repository-url>
cd CRPM-SystemWindows (PowerShell):
python -m venv .venv
.venv\Scripts\Activate.ps1macOS/Linux:
python3 -m venv .venv
source .venv/bin/activatepip install -r requirements.txtOption A: Comprehensive sample data (Recommended for testing)
python sample_data.pyCreates:
- 5 sample customers (retail, wholesale, corporate types)
- 10 sample products across categories
- 50 sample purchases over the last 90 days
Option B: Minimal demo data via UI
- Run the app
- Go to Settings β Add Sample Data
- Adds basic customers and products
streamlit run app/main.pyThe app will open in your browser at http://localhost:8501
- SQLite database file created automatically at
data/crpm.dbon first run - Schema applied from
schema.sql(enhanced with 50+ fields) - Foreign keys, constraints, indexes, and triggers set up automatically
- 3 main tables: customers, products, purchases
- 50+ fields with complete business information
- 11 indexes for optimized query performance
- 4 automatic triggers for timestamps and status updates
- Foreign key constraints for data integrity
- CHECK constraints for validation
If you have an existing database from an older version:
Option 1: Migrate (Keep Your Data)
python migrate_database.pyOption 2: Fresh Start
python reset_database.py
python sample_data.pyTo completely reset the database:
- Stop the app
- Delete
data/crpm.db - Run
streamlit run app/main.pyagain (auto-creates new database) - Optionally run
python sample_data.pyfor test data
CRPM-System/
β
βββ app/
β βββ main.py # Streamlit UI (Dashboard, Customers, Products, Purchases, Analytics)
β βββ models.py # Business logic + CRUD (CRPM service class)
β βββ analytics.py # Analytics engine (15+ reporting functions)
β βββ db.py # Database connection + init
β βββ utils.py # Helpers (date parsing, type conversion)
β
βββ assets/
β βββ image.png # Dashboard screenshot
β
βββ data/ # Auto-created at runtime
β βββ crpm.db # SQLite database
β
βββ requirements.txt # Python dependencies
βββ schema.sql # Enhanced DB schema (tables, indexes, triggers)
βββ sample_data.py # Sample data generatorβ
βββ README.md # Overview
βββ CODE_OF_CONDUCT.md # Code of conduct
βββ CONTRIBUTING.md # Contribution guidelines
βββ SECURITY.md # Security policy
βββ LICENSE # License info
- Navigate to π₯ Customers β Add Customer tab
- Fill in customer details (name is required)
- Optionally add address, company info, notes
- Click Add Customer
- Navigate to π¦ Products β Add Product tab
- Enter product name, price, and initial stock
- Optionally add SKU, category, brand, supplier
- Set reorder levels for inventory alerts
- Click Add Product
- Navigate to π Purchases β Record Purchase tab
- Select customer and product from dropdowns
- Enter quantity (validates against available stock)
- Choose payment method and status
- Optionally add discount (percentage or fixed amount)
- Enter tax percentage if applicable
- Review order summary with calculated totals
- Click Record Purchase
- Stock automatically deducted
- Purchase history updated
- Analytics refreshed
- Navigate to π Analytics
- Explore 4 specialized tabs:
- Sales Analytics: Revenue trends, monthly breakdown, pivot tables
- Customer Analytics: Top customers, retention metrics, repeat rate
- Product Analytics: Best sellers, category performance
- Payment Analytics: Payment method breakdown
- View low-stock products in sidebar alerts
- Filter products by Low stock only in Products β Product List
- Check Settings β Stock Alerts for detailed reorder information
Edit app/db.py to change database path:
DB_PATH = Path(__file__).resolve().parents[1] / "data" / "crpm.db"Modify in purchase form or set per transaction (flexible per-purchase tax)
- Categories are created automatically when adding products
- View all categories in Products β Search & Filter tab
- Analytics automatically group by category
- Extend schema in
schema.sql - Update models in
app/models.py - Add UI fields in
app/main.py
This happens when using an old database with new code. Fix:
# Keep your data
python migrate_database.py
# OR start fresh
python reset_database.py
python sample_data.pySee FIX_SCHEMA_ERROR.md for detailed instructions.
# Check Python version
python --version # Should be 3.8+
# Reinstall dependencies
pip install --upgrade -r requirements.txt
# Verify you're in the project directory
cd path/to/CRPM-System# Ensure app/__init__.py exists
# Run from project root
streamlit run app/main.py- Close all other connections to the database
- Ensure only one Streamlit instance is running
- Restart the application
