Case Study
Project Case Study
Challenges, solutions, outcomes, technical highlights, architecture, and project scale.
⚡
Challenges
1. Implementing multi-role architecture with different access levels for admin, manager, marketer, lawyer, and regular user.
2. Designing a wallet and income system with automatic calculation for each role at purchase time.
3. Managing inventory per owner (each user has their own inventory).
4. Integrating ZarinPal payment gateway with automatic profit allocation among different roles.
5. Implementing SMS OTP login for users.
6. Designing dedicated admin panels for each role (managers, marketers, lawyers) with different capabilities.
7. Managing multi-section content (articles, questions, legal experiences, videos) with a unified structure in the Seo model.
8. Implementing a chat-like consultation system between user and lawyer.
💡
Solutions
1. Building CustomUser with separate boolean fields (admin_access, manager_access, agent_access, response_access) for access control.
2. Automatic calculation of marketer and product owner profit in the ZarinPal verify function and deposit to wallet.
3. Creating Owners model for per-user inventory and ManyToMany relation with products.
4. Using dynamic Callback URL for gateway return and cart update.
5. Using ghasedak service for SMS and storing random code in random_pass field.
6. Designing role-specific panel templates with different menus based on access fields.
7. Using a single Seo model with type field (articles/questions/experiences/video) for content management.
8. Creating Counseling and Conversation models for user-lawyer chat.
📚
Outcomes
- Creating a complete e-commerce ecosystem with 5 different roles.
- Increasing revenue through a multi-level marketing system.
- Unified content and product management in one panel.
- Full automation of profit calculation and wallet deposits.
- Reducing support costs with online consultation system.
- Increasing conversion rate with quick SMS login.
🔧
Technical Highlights
- Using CustomUser inheriting AbstractUser with 10+ custom fields.
- Using persiantools for Gregorian to Jalali date conversion.
- Using ghasedak package for SMS sending.
- Implementing AJAX for all cart and panel operations.
- Using DRF Permissions for access control.
- Secure file upload management with timestamp and ID naming.
- Using pymysql for MySQL connection.
🏗️
Architecture
The project is built on Django's MVT architecture with 7 main apps:
1. account: User management and SMS authentication.
2. site_profile: User panel, dashboard, managers, and consultations.
3. seo: Articles, questions, legal experiences, and videos management.
4. product: Products, brands, categories, inventory, and variations management.
5. cart: Shopping cart and order management.
6. zarinpal: Payment gateway integration.
7. marketing: Marketer withdrawal request management.
Apps communicate via ForeignKey and ManyToMany and share a common CustomUser.
📐
Project Scale
The project is designed at the level of a large application with 7 independent apps. It currently uses SQLite but has been upgraded to MySQL for production. The codebase exceeds 5,000 lines of Python and 50+ HTML templates.