⚡
Challenges
- Need for direct sales system from farmer to consumer without intermediaries
- Managing two price types (retail and wholesale) for each product
- Complex transportation system with three vehicle types and different prices for each province
- Need for automatic user registration at purchase time
- Managing marketers and settlement with them
- Calculating transportation costs based on province and city
- Need for admin panel with different access levels
- Jalali date management throughout the system
💡
Solutions
- Implementing Commodity model with two price fields (retail_price, overall_price)
- Designing Transport model with three price fields for each vehicle type (vanet_price, nasan_price, khavar_price)
- Implementing automatic user registration with random password at purchase time
- Designing Cart model with visitor_id and visitor_paid fields for marketer management
- Implementing State_city model with ManyToMany relationship to City
- SMS authentication system via Ghasedak API
- Implementing access levels (admin, user) with access_level field
- Using persiantools for Jalali date
- Designing Takestan_us pages for region introduction
📚
Outcomes
- Complete online store with two sales types (retail and wholesale)
- Smart transportation system with variable prices
- Marketing and settlement system with marketers
- Automatic user registration at purchase time
- Admin panel with different access levels
- Full Jalali date support
- Responsive and user-friendly design
- Province and city management system
🔧
Technical Highlights
- Django 4.2.6 and Python 3
- MySQL database with pymysql
- django-jalali and persiantools for Jalali date
- python-telegram-bot for Telegram bot
- sorl-thumbnail for image optimization
- Pillow for image processing
- xlwt for Excel export
- Flask for auxiliary services
- Automatic registration system with random password
- Access level management (admin, user)
- Transportation system with three vehicle types
- Marketing and settlement system
- State_city management with ManyToMany
- Ghasedak API for SMS
- Jalali date management throughout the system
🏗️
Architecture
Yare Keshavarz is built on Django's MVT (Model-View-Template) architecture and consists of two main applications:
1. store_account: Responsible for user management and authentication
- Custom User model with access_level, mobile, bank_card_number, total_income, paid_income fields
- SMS and password login system
- Automatic user registration at purchase time
2. store_profile: Responsible for products, shopping cart, and transportation management
- Commodity model for agricultural products
- Cart model for shopping cart with visitor_id and visitor_paid fields
- Transport model for transportation management
- State_city model for province and city management
- ImageFile and Keyword models for product images and keywords
Main project views:
- home_page: Homepage with products display and transportation table
- commodity_details: Product details with purchase form
- new_home: Marketer-specific homepage
- new_commodity_details: Marketer-specific product details
- transport: Transportation list
- about_us: About us
- contact_us: Contact us
- takestan_us: About Takestan county
Admin panel includes:
- dashboard: Dashboard
- addcommodity: Add product
- allcommodity: Product list
- edit_commodity: Edit product
- edit_image: Edit images
- admin_cart: Track new orders
- follow_user_cart: Track user cart
- sent_cart: Marketer settlement list
- all_visitor_paid_cart: Sales history
- manage_transport: Transportation management
- state_city: Province and city management
- allusers: User list
- profile_settings: Personal settings
- user_cart: Shopping cart
- user_sent_cart: Previous purchases list
- visitor_cart: Current sales
- visitor_paid_cart: Previous sales
The project runs in DEBUG mode and uses SQLite for development and MySQL for production.
📐
Project Scale
- 2 main applications (store_account, store_profile)
- 5 main data models (User, Commodity, Cart, Transport, State_city)
- 3 vehicle types (van, Nissan, Khavar)
- 2 price types (retail and wholesale)
- 2 access levels (admin, user)
- More than 20 pages and HTML templates
- Automatic registration system
- Marketing and settlement system
- Jalali date management