e-Mandi is an all-in-one digital marketplace that connects farmers with buyers for the sale and purchase of agricultural produce. The platform features real-time listings, order tracking, and category-based crop discovery, enabling direct farmer-to-buyer transactions.
- Users must be able to register with email and password
- Users must be able to log in securely using JWT-based authentication
- Users must be able to log out from the system
- System must support three user roles: Farmer, Buyer, and Admin
- Users must be able to switch between Farmer and Buyer roles dynamically
- Users must be able to create and update their profile information including:
- Full name
- Email address
- Phone number
- Address (street, city, state, pincode)
- Profile information must be persisted and retrievable across sessions
- Farmers must be able to add new crop listings with the following details:
- Crop name
- Category (vegetables, fruits, grains, pulses, spices, dairy, other)
- Description
- Quantity available (in kg or specified unit)
- Price per unit
- Harvest date
- Expiry date
- Location
- Image URL
- Organic certification status
- Farmers must be able to edit their existing crop listings
- Farmers must be able to delete their crop listings
- Farmers must be able to mark crops as available or unavailable
- System must automatically hide crops with zero quantity
- Farmers must be able to view all orders placed for their crops
- Farmers must be able to see order details including:
- Buyer information (name, contact details)
- Crop name and quantity ordered
- Total price
- Delivery address
- Order status
- Order date
- Farmers must be able to update order status through the following workflow:
- Pending → Confirmed → Shipped → Delivered
- Ability to cancel orders
- Farmers must receive real-time notifications for new orders
- Dashboard must display key metrics:
- Total crops listed
- Total revenue generated
- Number of pending orders
- Dashboard must show a list of all active crop listings
- Dashboard must display recent orders with status tracking
- Buyers must be able to browse all available crops
- Buyers must be able to search crops by:
- Crop name
- Description
- Location
- Buyers must be able to filter crops by category:
- Vegetables
- Fruits
- Grains
- Pulses
- Spices
- Dairy
- Other
- System must display only available crops with quantity > 0
- Buyers must be able to view detailed crop information including:
- Crop name, category, and description
- Available quantity and unit
- Price per unit
- Harvest and expiry dates
- Organic certification status
- Crop image
- Buyers must be able to view farmer information:
- Farmer name
- Location (city, state)
- Contact phone number
- Buyers must be able to place orders by specifying:
- Quantity to purchase
- Delivery address
- Optional notes
- System must automatically calculate total price based on quantity and unit price
- System must validate that ordered quantity does not exceed available quantity
- System must update crop quantity after successful order placement
- Buyers must be able to view all their placed orders
- Buyers must be able to track order status in real-time:
- Pending
- Confirmed
- Shipped
- Delivered
- Cancelled
- Buyers must be able to view order history with complete details
- Dashboard must display key metrics:
- Total orders placed
- Total amount spent
- Number of pending orders
- Dashboard must show available crops with search and filter capabilities
- Dashboard must display order history with status tracking
- Admin must be able to view comprehensive platform statistics:
- Total registered users
- Number of farmers
- Number of buyers
- Total crops listed
- Total orders placed
- Pending orders count
- Total revenue generated (from delivered orders)
- Admin must be able to view all registered users with details:
- Name, email, user type
- Location information
- Registration date
- Admin must be able to search users by name or email
- Admin must be able to view individual user profiles
- Admin must be able to suspend or ban users (future enhancement)
- Admin must be able to view all crop listings across the platform
- Admin must be able to search crops by name or category
- Admin must be able to view crop details including farmer information
- Admin must be able to delete inappropriate or fraudulent crop listings
- Admin must be able to view crop availability status
- Admin must be able to view all orders across the platform
- Admin must be able to search orders by crop name, buyer, or farmer
- Admin must be able to view complete order details
- Admin must be able to update order status for dispute resolution
- Admin must be able to monitor pending orders requiring attention
- Admin dashboard must be accessible only to users with admin privileges
- System must verify admin status before granting access
- Non-admin users must be denied access with appropriate error message
- Users must receive toast notifications for:
- Successful operations (order placed, crop added, status updated)
- Error conditions (failed operations, validation errors)
- Important updates (order status changes)
- Page load time must not exceed 3 seconds under normal network conditions
- Search and filter operations must return results within 1 second
- Database queries must be optimized with appropriate indexes
- System must handle concurrent users without performance degradation
- Images must be optimized for web delivery
- All passwords must be hashed using bcrypt before storage
- JWT tokens must be used for session management
- Tokens must expire after a reasonable time period
- All API endpoints must require authentication
- Role-based access control (RBAC) must be enforced at database level
- Row Level Security (RLS) must be enabled on all database tables
- Users must only access their own data unless explicitly authorized
- Farmers can only modify their own crop listings
- Buyers can only view their own orders
- Admin access must be strictly controlled and audited
- All user inputs must be validated on both client and server side
- SQL injection prevention through parameterized queries
- XSS prevention through input sanitization
- CSRF protection must be implemented
- Database schema must support horizontal scaling
- Application must be stateless to enable load balancing
- Caching strategies must be implemented for frequently accessed data
- System must handle increasing number of users and transactions
- System uptime must be at least 99.5%
- Database backups must be performed daily
- System must gracefully handle errors without crashing
- Failed transactions must be rolled back to maintain data consistency
- User interface must be intuitive and easy to navigate
- System must be responsive and work on desktop, tablet, and mobile devices
- Forms must provide clear validation messages
- Loading states must be displayed during asynchronous operations
- Error messages must be user-friendly and actionable
- Code must follow consistent coding standards and conventions
- Components must be modular and reusable
- Database schema must be version-controlled through migrations
- System must have comprehensive error logging
- Code must be well-documented with comments where necessary
- Application must work on modern browsers:
- Chrome (latest 2 versions)
- Firefox (latest 2 versions)
- Safari (latest 2 versions)
- Edge (latest 2 versions)
- Application must be mobile-responsive
- System must support different screen sizes and resolutions
- All database operations must maintain ACID properties
- Foreign key constraints must be enforced
- Cascade deletes must be properly configured
- Timestamps (created_at, updated_at) must be automatically managed
- Quantity validation must prevent negative values or overselling
- Application should follow WCAG 2.1 guidelines where possible
- Proper semantic HTML must be used
- Keyboard navigation must be supported
- Color contrast ratios must meet accessibility standards
- Screen reader compatibility should be considered
- System must log all critical operations
- Error tracking must be implemented
- Performance metrics must be monitored
- User activity must be logged for audit purposes
- Database query performance must be monitored
- Frontend: React.js with TypeScript
- UI Framework: Tailwind CSS with shadcn/ui components
- Backend: Supabase (PostgreSQL database with built-in authentication)
- State Management: React Query (@tanstack/react-query)
- Routing: React Router DOM
- Form Handling: React Hook Form with Zod validation
- Build Tool: Vite
- PostgreSQL database through Supabase
- Row Level Security (RLS) policies must be defined
- Database migrations must be version-controlled
- Indexes must be created for frequently queried columns
- Application must be deployable to modern hosting platforms
- Environment variables must be used for configuration
- Production build must be optimized and minified
- user_id (UUID, Primary Key)
- email (Text, Unique)
- full_name (Text)
- user_type (Enum: farmer, buyer, admin)
- phone (Text)
- address (Text)
- city (Text)
- state (Text)
- pincode (Text)
- created_at (Timestamp)
- updated_at (Timestamp)
- id (UUID, Primary Key)
- farmer_id (UUID, Foreign Key → auth.users)
- name (Text)
- category (Enum: vegetables, fruits, grains, pulses, spices, dairy, other)
- description (Text)
- quantity_available (Decimal)
- unit (Text, default: 'kg')
- price_per_unit (Decimal)
- harvest_date (Date)
- expiry_date (Date)
- location (Text)
- image_url (Text)
- is_available (Boolean)
- is_organic (Boolean)
- created_at (Timestamp)
- updated_at (Timestamp)
- id (UUID, Primary Key)
- buyer_id (UUID, Foreign Key → auth.users)
- farmer_id (UUID, Foreign Key → auth.users)
- crop_id (UUID, Foreign Key → crops)
- quantity (Decimal)
- total_price (Decimal)
- status (Enum: pending, confirmed, shipped, delivered, cancelled)
- delivery_address (Text)
- delivery_date (Date)
- notes (Text)
- created_at (Timestamp)
- updated_at (Timestamp)
- Register/Login as Farmer
- Complete profile with location and contact details
- Add crop listings with details and pricing
- Receive orders from buyers
- Update order status as processing progresses
- Track revenue and manage inventory
- Register/Login as Buyer
- Browse available crops with search and filters
- View crop details and farmer information
- Place order with quantity and delivery address
- Track order status in real-time
- View order history and spending
- Login with admin credentials
- Monitor platform analytics and metrics
- Review and manage user accounts
- Moderate crop listings for quality control
- Resolve order disputes and issues
- Generate reports on platform activity
- Integrate payment gateway for online transactions
- Support multiple payment methods
- Implement escrow system for secure transactions
- Allow buyers to rate farmers and crops
- Display ratings on crop listings
- Implement review moderation
- Implement geolocation-based search
- Add price range filters
- Support sorting by various criteria
- Enable direct communication between farmers and buyers
- Implement in-app chat functionality
- Support order-related queries
- Develop native mobile apps for iOS and Android
- Push notifications for order updates
- Offline capability for viewing listings
- Advanced reporting for farmers
- Sales trends and insights
- Demand forecasting
- Support regional languages
- Localization for different markets
- Number of registered farmers and buyers
- Total crops listed on the platform
- Order completion rate
- Average order value
- User retention rate
- Platform revenue
- User satisfaction scores
- Response time for order processing
Document Version: 1.0
Last Updated: February 12, 2026
Status: Active Development