Skip to content

amirholakoo/IOMS

Repository files navigation

🏒 HomayOMS - Inventory & Order Management System

Python Django License Status

Enterprise-grade Inventory & Order Management System with multi-role authentication, SMS verification, and modern UI/UX design.

πŸ“‹ Table of Contents

🎯 Project Overview

HomayOMS is a comprehensive Inventory & Order Management System designed for modern businesses. Built with Django and featuring a sophisticated multi-role authentication system, it provides secure access for different user types with role-based permissions and SMS verification for customers.

🎨 Key Highlights

  • πŸ” Multi-Role Authentication: 4 distinct user roles with separate login flows
  • πŸ“± SMS Verification: Secure customer authentication via SMS
  • 🎨 Modern UI/UX: Beautiful, responsive design with Tailwind CSS
  • 🌐 Persian RTL Support: Full support for Persian language and RTL layout
  • πŸ”’ Role-Based Access Control: Granular permissions for each user type
  • πŸ“Š Real-time Dashboard: Role-specific dashboards with relevant metrics

πŸš€ Features

πŸ” Authentication & Security

  • 4-Role Login System: Super Admin, Admin, Finance, Customer
  • SMS Verification: Customer authentication via mobile verification
  • Session Management: Secure user sessions with activity tracking
  • Password Security: Encrypted password storage with expiration
  • Role Validation: Strict role-based access control

πŸ‘₯ User Management

  • Custom User Model: Extended Django User with role-based fields
  • Profile Management: User profile editing and management
  • Status Tracking: Active, Inactive, Suspended, Pending statuses
  • Activity Monitoring: Last login and activity tracking

🏒 Business Features

  • Customer Management: Complete customer profile system
  • Inventory Tracking: Product and stock management with external SQLite sync
  • Order Processing: Atomic order creation and management system
  • Financial Management: Pricing and invoice system with cash/credit control
  • Reporting System: Business analytics and reports with Persian calendar

πŸ”„ Advanced Features (v201+)

  • πŸ”„ Atomic Order System: Eliminates unfinished orders with immediate creation
  • πŸ“± Real SMS Integration: SIM800C hardware with Raspberry Pi server
  • πŸ”„ Inventory Synchronization: Bidirectional sync with external SQLite databases
  • πŸ’° Cash Purchase Control: Super Admin can disable cash purchases
  • πŸ“… Persian Calendar: Automatic Jalali date conversion and display
  • πŸ”’ Enhanced Security: Customer deletion protection, comprehensive logging

🎨 User Interface

  • Responsive Design: Works perfectly on all devices
  • Modern UI: Clean, professional interface with animations
  • Persian Support: Full RTL layout and Persian text support
  • Accessibility: WCAG compliant design patterns
  • Dark/Light Mode: Theme switching capability (planned)

πŸ› οΈ Tech Stack

Backend

  • Python 3.8+: Core programming language
  • Django 5.2+: Web framework with admin interface
  • PostgreSQL: Production database (SQLite for development)
  • Gunicorn: Production WSGI server
  • Nginx: Reverse proxy and static file serving

Frontend

  • HTML5/CSS3: Modern web standards
  • JavaScript: Interactive functionality with Persian support
  • Vazirmatn Font: Persian typography
  • Responsive Design: Mobile-first approach

Hardware Integration (v201+)

  • SIM800C GSM Module: Real SMS functionality
  • Raspberry Pi: Hardware server platform
  • Flask: SMS API server
  • Serial Communication: Hardware control via serial ports

DevOps & Tools

  • Git: Version control
  • Docker: Containerization with Docker Compose
  • Systemd: Service management on Raspberry Pi
  • GitHub Actions: CI/CD pipeline (planned)

Security

  • Django Security: Built-in security features
  • HTTPS: SSL/TLS encryption
  • CSRF Protection: Cross-site request forgery protection
  • XSS Prevention: Cross-site scripting protection
  • Role-Based Permissions: Granular access control

πŸ“¦ Installation

Prerequisites

Python 3.8+
pip
git
PostgreSQL (for production)
SQLite3 (for inventory sync)

Quick Start

# Clone the repository
git clone https://github.com/amirholakoo/IOMS.git
cd IOMS/v201  # Use v201 for latest features

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run migrations
python manage.py migrate

# Setup roles and permissions
python manage.py setup_roles

# Create superuser
python manage.py createsuperuser

# Setup SMS templates
python manage.py setup_sms_templates

# Setup field mappings for inventory sync
python manage.py setup_field_mappings

# Create test data
python manage.py create_full_test_data

# Run development server
python manage.py runserver

Environment Configuration

# Copy environment file
cp env.local .env

# Edit environment variables
nano .env

⚠️ Important: Inventory Sync Setup

The inventory sync app requires an external SQLite database file that is NOT included in the repository.

Setting Up Your SQLite Database

# Create a new SQLite database
sqlite3 inventory_sync/db.sqlite3

# Or use your existing inventory database
cp /path/to/your/existing/inventory.db inventory_sync/db.sqlite3

# Required table structure
CREATE TABLE Products (
    id INTEGER PRIMARY KEY,
    reel_number TEXT UNIQUE NOT NULL,
    width INTEGER,
    length INTEGER,
    weight REAL,
    status TEXT DEFAULT 'In-stock',
    date TEXT,
    notes TEXT
);

Configure Database Path

# In your .env file
SQLITE_DB_PATH=/path/to/your/inventory.db

πŸ”§ Django Management Commands

For Next Developer:
This section explains how to use, extend, and troubleshoot all custom Django management commands in this project. If you want to automate tasks, create test data, or add your own scripts, start here!

πŸ“‹ What are Django Management Commands?

Django management commands are scripts you run with python manage.py <command> to automate tasks like creating test data, setting up roles, or running custom scripts.


πŸš€ How to Use Our Custom Commands

1. List all available commands:

python manage.py help

Look for commands like:

create_full_test_data
setup_roles
setup_sms_templates
setup_field_mappings
test_sqlite_connection
test_sms_connection
...

2. Get help for a specific command:

python manage.py help create_full_test_data

3. Run a command (example):

python manage.py create_full_test_data

This will create test users for all roles and print their credentials in the terminal.

4. Typical development workflow:

# Setup roles and permissions
python manage.py setup_roles --create-superuser --username admin --password admin123

# Setup SMS templates and field mappings
python manage.py setup_sms_templates
python manage.py setup_field_mappings

# Create test users and products
python manage.py create_full_test_data
python manage.py create_test_products --count 10

# Test connections
python manage.py test_sqlite_connection
python manage.py test_sms_connection

5. See output and use credentials: After running create_full_test_data, you'll see a table of test users and passwords you can use to log in.


πŸ”„ Inventory Sync Commands

Test SQLite Connection:

python manage.py test_sqlite_connection

Tests connectivity to external SQLite database for inventory sync.

Setup Field Mappings:

python manage.py setup_field_mappings

Creates default field mappings for inventory synchronization.


πŸ“± SMS Commands

Test SMS Connection:

python manage.py test_sms_connection

Tests SMS server connectivity and hardware status.

Setup SMS Templates:

python manage.py setup_sms_templates

Creates default SMS templates for verification and notifications.


πŸ› οΈ How to Add Your Own Custom Command

  1. Create the folder structure (if not already present):

    yourapp/
      management/
        commands/
          __init__.py
          your_command.py
    
  2. Write your command:

    # yourapp/management/commands/hello.py
    from django.core.management.base import BaseCommand
    
    class Command(BaseCommand):
        help = 'Prints Hello World'
    
        def handle(self, *args, **kwargs):
            self.stdout.write(self.style.SUCCESS('Hello, World!'))
  3. Run your command:

    python manage.py hello
  4. Best practices:

    • Use self.stdout.write(self.style.SUCCESS(...)) for nice output.
    • Add a help string and docstring.
    • Handle errors gracefully and print useful messages.
    • Document your new command in this section for future developers!

πŸ“ Tips & Troubleshooting

  • Always activate your virtual environment before running commands.
  • If you get CommandError or ModuleNotFoundError, check your folder structure and __init__.py files.
  • Use python manage.py help to discover all commands.
  • For bulk data, use --count or similar arguments if available.
  • For inventory sync: Ensure your SQLite database file exists and is accessible.
  • For SMS testing: Ensure SMS server is running and hardware is connected.
  • If you add a new command, document it in this section for the next developer!

πŸ“š Resources


Now, any new developer can:

  • See all available commands
  • Run and test with real data in seconds
  • Add their own commands with confidence
  • Troubleshoot common issues quickly
  • Set up inventory sync and SMS functionality properly

πŸ” Authentication System

User Roles & Permissions

Role Access Level Features
πŸ”΄ Super Admin Full System Access User management, System settings, All modules, SMS management, Inventory sync
🟑 Admin Operational Access Customer management, Orders, Inventory, Reports
🟒 Finance Financial Access Pricing, Invoices, Financial reports, Payments
πŸ”΅ Customer Limited Access Own orders, Profile management, SMS verification

Login Flows

  1. Staff Login (/accounts/staff/login/)

    • Username + Password authentication
    • Role validation and permissions
    • Session management
  2. Customer SMS Login (/accounts/customer/login/)

    • Phone number verification
    • SMS code authentication via SIM800C hardware
    • No password required
    • Customer activation notifications

πŸ“Š Project Structure

HomayOMS/
β”œβ”€β”€ v201/                    # 🎯 Latest Production Version
β”‚   β”œβ”€β”€ accounts/            # User authentication & management
β”‚   β”‚   β”œβ”€β”€ models.py        # Custom User model with roles
β”‚   β”‚   β”œβ”€β”€ views.py         # Authentication views
β”‚   β”‚   β”œβ”€β”€ permissions.py   # Role-based permissions
β”‚   β”‚   └── management/      # Django management commands
β”‚   β”œβ”€β”€ core/                # Core business logic
β”‚   β”‚   β”œβ”€β”€ models.py        # Customer, Order, Product models
β”‚   β”‚   β”œβ”€β”€ views.py         # Business views with atomic order system
β”‚   β”‚   β”œβ”€β”€ urls.py          # Core URL routing
β”‚   β”‚   └── management/      # Management commands
β”‚   β”œβ”€β”€ inventory_sync/      # Inventory synchronization
β”‚   β”‚   β”œβ”€β”€ models.py        # SyncConfig, SyncLog, ProductMapping
β”‚   β”‚   β”œβ”€β”€ services.py      # SQLiteInventoryService, InventorySyncService
β”‚   β”‚   β”œβ”€β”€ views.py         # Sync management views
β”‚   β”‚   └── templates/       # Persian UI templates
β”‚   β”œβ”€β”€ payments/            # Payment processing
β”‚   β”‚   β”œβ”€β”€ models.py        # Payment models
β”‚   β”‚   β”œβ”€β”€ services.py      # Payment services
β”‚   β”‚   └── views.py         # Payment views
β”‚   β”œβ”€β”€ sms/                 # SMS integration
β”‚   β”‚   β”œβ”€β”€ models.py        # SMS templates, messages, verifications
β”‚   β”‚   β”œβ”€β”€ services.py      # SMSService, SMSNotificationService
β”‚   β”‚   └── views.py         # SMS management views
β”‚   β”œβ”€β”€ HomayOMS/            # Project settings
β”‚   β”‚   β”œβ”€β”€ settings/        # Environment-based settings
β”‚   β”‚   β”œβ”€β”€ urls.py          # Main URL configuration
β”‚   β”‚   └── baseModel.py     # Base model with timestamps
β”‚   β”œβ”€β”€ templates/           # HTML templates
β”‚   β”‚   β”œβ”€β”€ accounts/        # Authentication templates
β”‚   β”‚   β”œβ”€β”€ core/            # Business templates
β”‚   β”‚   └── inventory_sync/  # Sync templates
β”‚   β”œβ”€β”€ static/              # Static files (CSS, JS, images)
β”‚   β”œβ”€β”€ requirements.txt     # Python dependencies
β”‚   β”œβ”€β”€ config.py            # Environment configuration
β”‚   └── manage.py            # Django management script
β”œβ”€β”€ v200/                    # Previous version
β”œβ”€β”€ v1.1/                    # Legacy version
β”œβ”€β”€ v1/                      # Legacy version
└── v0/                      # Initial version

βœ… Completed Features

πŸ” Authentication & User Management

  • βœ… Custom User Model: Extended Django User with role-based fields
  • βœ… Multi-Role Login System: 4 distinct login flows
  • βœ… SMS Verification: Customer authentication via phone
  • βœ… Role-Based Access Control: Granular permissions
  • βœ… Session Management: User activity tracking
  • βœ… Profile Management: User profile editing

πŸ”„ Advanced Order System (v201+)

  • βœ… Atomic Order Creation: Orders created with items immediately
  • βœ… Page Exit Protection: Automatic order cancellation on page exit
  • βœ… Product Reservation: Products marked as 'Pre-order' to prevent double booking
  • βœ… Automatic Cleanup: Draft orders cancelled after timeout or page exit
  • βœ… Unfinished Orders: Continue payment for incomplete orders

πŸ“± Real SMS Integration (v201+)

  • βœ… SIM800C Hardware: Real SMS functionality with GSM module
  • βœ… Raspberry Pi Server: Flask API server for hardware control
  • βœ… Customer Activation: Automatic SMS notifications when accounts are activated
  • βœ… Verification System: Secure SMS code authentication
  • βœ… Message Templates: Configurable SMS templates with variable substitution

πŸ”„ Inventory Synchronization (v201+)

  • βœ… External SQLite Integration: Bidirectional sync with external inventory systems
  • βœ… Field Mapping System: Configurable field mappings between systems
  • βœ… Product Import/Export: Import products and export sales status
  • βœ… Comprehensive Logging: All sync operations logged with detailed information
  • βœ… Mobile-Friendly Persian UI: Responsive interface for sync management

πŸ’° Cash Purchase Control (v201+)

  • βœ… Super Admin Control: Toggle cash purchase availability
  • βœ… Dynamic UI Updates: Real-time interface updates based on settings
  • βœ… Customer Guidance: Clear notifications about payment limitations
  • βœ… Alternative Options: Credit (Ω†Ψ³ΫŒΩ‡) payment remains available

πŸ“… Persian Calendar Integration (v201+)

  • βœ… Automatic Conversion: All dates automatically converted to Persian Jalali format
  • βœ… Accurate Algorithm: Proper Persian calendar conversion with leap year support
  • βœ… Client-Side Processing: No server overhead, pure JavaScript conversion
  • βœ… Visual Styling: Converted dates displayed in blue with medium font weight

🎨 User Interface

  • βœ… Professional Design: Beautiful Persian RTL interface
  • βœ… Responsive Layout: Mobile-first approach with touch-friendly elements
  • βœ… Modern Components: Clean, professional interface with animations
  • βœ… Accessibility: WCAG compliant design patterns

πŸ”§ Development & DevOps

  • βœ… Environment Configuration: Local, Dev, Production settings
  • βœ… Production Deployment: Manual deployment on Raspberry Pi
  • βœ… Docker Support: Containerization with Docker Compose
  • βœ… Comprehensive Logging: Structured logging and monitoring
  • βœ… Security Best Practices: CSRF, XSS protection, secure headers

πŸ“ TODO List

πŸ”„ Order Management Enhancements

  • Order Templates: Predefined order templates for common scenarios
  • Bulk Order Processing: Mass order operations
  • Order History: Detailed order history and tracking
  • Order Notifications: Real-time order status notifications

πŸ“± SMS System Improvements

  • SMS Templates: More customizable SMS templates
  • Bulk SMS: Mass SMS sending capabilities
  • SMS Analytics: Message delivery statistics and analytics
  • SMS Scheduling: Scheduled SMS sending

πŸ”„ Inventory Sync Enhancements

  • Real-time Sync: WebSocket-based real-time synchronization
  • Conflict Resolution: Handle data conflicts between systems
  • Incremental Sync: Only sync changed data
  • API Integration: REST API for external system integration

πŸ“Š Analytics & Reporting

  • Sales Reports: Revenue and sales analytics
  • Inventory Reports: Stock level reports and alerts
  • Customer Analytics: Customer behavior insights
  • Financial Reports: Profit/loss statements and cash flow

🎨 User Experience

  • Dark Mode: Theme switching capability
  • Notifications: Real-time notifications system
  • Search Functionality: Global search across modules
  • Data Export: CSV/Excel export capabilities

πŸ”§ Technical Improvements

  • API Development: RESTful API endpoints
  • Database Optimization: Query optimization and indexing
  • Caching System: Redis integration for performance
  • Background Tasks: Celery integration for async tasks
  • Testing Suite: Unit and integration tests
  • CI/CD Pipeline: Automated deployment and testing

πŸ“± Mobile & Integration

  • Mobile App: React Native mobile application
  • Webhook Integration: Third-party integrations
  • Email Notifications: Automated email system
  • Barcode Scanning: QR code integration

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 Python style guide
  • Add Persian comments with emojis
  • Write comprehensive tests
  • Update documentation
  • Use meaningful commit messages

πŸ‘₯ Contributors

Lead Developers


Amir DarBandi

Full Stack Developer
πŸ”— GitHub

Parsa Parvizi

Backend Developer
πŸ”— GitHub

Development Team

  • 🎯 Amir DarBandi - Project Lead & Full Stack Development

    • Expertise: Python, Django, JavaScript, React, Laravel
    • Focus: System architecture, UI/UX, DevOps
  • 🎯 Parsa Parvizi - Backend Development & Security

    • Expertise: Python, Django, Cybersecurity, Database Design
    • Focus: Authentication system, Security implementation

Special Thanks

  • Homayoun Paper & Cardboard Industries Co. - Project sponsor
  • Django Community - Framework and documentation
  • Tailwind CSS Team - UI framework

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


🏒 HomayOMS - Enterprise Inventory & Order Management System

GitHub stars GitHub forks

Built with ❀️ by the HomayOMS Team

About

Inventory & Order Management System

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •