Enterprise-grade Inventory & Order Management System with multi-role authentication, SMS verification, and modern UI/UX design.
- π― Project Overview
- π Features
- π οΈ Tech Stack
- π¦ Installation
- π§ Django Management Commands
- π Authentication System
- π Project Structure
- β Completed Features
- π TODO List
- π€ Contributing
- π₯ Contributors
- π License
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.
- π 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
- 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
- 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
- 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
- π 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
- 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)
- 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
- HTML5/CSS3: Modern web standards
- JavaScript: Interactive functionality with Persian support
- Vazirmatn Font: Persian typography
- Responsive Design: Mobile-first approach
- SIM800C GSM Module: Real SMS functionality
- Raspberry Pi: Hardware server platform
- Flask: SMS API server
- Serial Communication: Hardware control via serial ports
- Git: Version control
- Docker: Containerization with Docker Compose
- Systemd: Service management on Raspberry Pi
- GitHub Actions: CI/CD pipeline (planned)
- 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
Python 3.8+
pip
git
PostgreSQL (for production)
SQLite3 (for inventory sync)
# 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
# Copy environment file
cp env.local .env
# Edit environment variables
nano .env
The inventory sync app requires an external SQLite database file that is NOT included in the repository.
# 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
);
# In your .env file
SQLITE_DB_PATH=/path/to/your/inventory.db
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!
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.
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.
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.
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.
-
Create the folder structure (if not already present):
yourapp/ management/ commands/ __init__.py your_command.py
-
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!'))
-
Run your command:
python manage.py hello
-
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!
- Use
- Always activate your virtual environment before running commands.
- If you get
CommandError
orModuleNotFoundError
, 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!
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
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 |
-
Staff Login (
/accounts/staff/login/
)- Username + Password authentication
- Role validation and permissions
- Session management
-
Customer SMS Login (
/accounts/customer/login/
)- Phone number verification
- SMS code authentication via SIM800C hardware
- No password required
- Customer activation notifications
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
- β 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
- β 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
- β 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
- β 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
- β 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
- β 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
- β 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
- β 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
- 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 Templates: More customizable SMS templates
- Bulk SMS: Mass SMS sending capabilities
- SMS Analytics: Message delivery statistics and analytics
- SMS Scheduling: Scheduled SMS sending
- 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
- 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
- Dark Mode: Theme switching capability
- Notifications: Real-time notifications system
- Search Functionality: Global search across modules
- Data Export: CSV/Excel export capabilities
- 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 App: React Native mobile application
- Webhook Integration: Third-party integrations
- Email Notifications: Automated email system
- Barcode Scanning: QR code integration
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- Follow PEP 8 Python style guide
- Add Persian comments with emojis
- Write comprehensive tests
- Update documentation
- Use meaningful commit messages
Amir DarBandi Full Stack Developer π GitHub |
Parsa Parvizi Backend Developer π GitHub |
-
π― 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
- Homayoun Paper & Cardboard Industries Co. - Project sponsor
- Django Community - Framework and documentation
- Tailwind CSS Team - UI framework
This project is licensed under the MIT License - see the LICENSE file for details.