DEV Community

Cover image for “AgriExchange: A Full-Stack Agricultural Resource Exchange with Django + MongoDB”
Eira Reddy
Eira Reddy

Posted on

“AgriExchange: A Full-Stack Agricultural Resource Exchange with Django + MongoDB”

How We Built AgriExchange — A Smart Marketplace for Agricultural Resource Exchange

by @chada_sirichandana_eba7e @eira_reddy_c6ec70fa5b0014 @pasala_venkatahruthika_a

Developed under the guidance of Professor @chanda_rajkumar , and we are thankful for his valuable support throughout this project.


Why We Built This:

In agriculture and livestock ecosystems, one problem keeps showing up again and again:

Someone has resources.
Someone needs them.
They just don’t find each other at the right time.

Farmers need feed, tools, or raw materials.
Suppliers have stock sitting unused.
And the platforms available? Either too fragmented or not built for direct exchange.

So instead of complaining about it… We built AgriExchange.

A platform where:

  • Farmers can find what they need
  • Suppliers can reach the right buyers
  • Transactions happen smoothly in one place

Here is how we login:



Two Roles, One Ecosystem

AgriExchange is built around role-based interaction, keeping things simple and relevant:

| Role     | What they do                        |
| -------- | ----------------------------------- |
| Farmer   | Browse and request resources        |
| Supplier | Post and manage available resources |
Enter fullscreen mode Exit fullscreen mode

No unnecessary complexity. Just what each user actually needs.

Farmer Dashboard:

Animal Husbandry Owner Dashboard:


Tech Stack

I wanted something powerful but not over-engineered, so I went with:

Backend

  • Django + Django REST Framework
  • Handles APIs, logic, authentication Database
  • MongoDB (via PyMongo)
  • Flexible document structure for different data types Frontend
  • Plain HTML, CSS, JavaScript
  • No heavy frameworks — easier to understand and debug Auth
  • JWT-based authentication Deployment
  • Backend → Railway
  • Frontend → Vercel / ngrok

🍃 Why MongoDB?

MongoDB’s document model made it easier to:

  • Iterate quickly
  • Store dynamic data
  • Scale features without redesigning schemas
# MongoDB settings
MONGO_URI = os.getenv('MONGO_URI', 'mongodb://localhost:27017/')
MONGO_DB = os.getenv('MONGO_DB', 'agriexchange')
Enter fullscreen mode Exit fullscreen mode

🔑 Core Features

Here’s what the platform actually does:

🔐 Authentication

  • JWT-based login/signup
  • Role-based user profiles

📦 Resource Marketplace

  • Suppliers post resources
  • Farmers browse listings

🤝 Transactions

  • Users can initiate trades
  • Agreements are generated automatically

🧠 Smart Matching

  • Suggests relevant buyers/sellers
  • Based on roles and activity

⭐ Ratings & History

  • Track past trades
  • Build trust in the system

📊 Analytics Dashboard

  • Platform stats
  • Usage insights

How It’s Structured

I kept the architecture clean and modular:

  • Backend (Django)
  • Handles API routes
  • Business logic
  • Authentication
  • Database (MongoDB)

Collections:

  • users
  • resources
  • transactions
  • ratings

API Endpoints

`from django.urls import path
from . import views

urlpatterns = [
    path('signup', views.signup, name='signup'),
    path('login', views.login, name='login'),
    path('me', views.get_profile, name='get_profile'),
    path('users/<str:user_id>', views.get_user_profile, name='get_user_profile'),
    path('resources', views.resources_view, name='resources'),  # GET & POST
    path('resources/my', views.my_resources, name='my_resources'),
    path('resources/<str:resource_id>', views.delete_resource, name='delete_resource'),  # DELETE
    path('transactions', views.transactions_view, name='transactions'),  # POST & GET
    path('transactions/my', views.my_transactions, name='my_transactions'),
    path('transactions/<str:tx_id>/agreement', views.get_agreement, name='get_agreement'),
    path('ratings', views.submit_rating, name='submit_rating'),
    path('match', views.match_resources, name='match_resources'),
    path('stats', views.get_stats, name='get_stats'),  # Added missing stats endpoint
]`
Enter fullscreen mode Exit fullscreen mode

Frontend

  • Static UI
  • Uses api.js to communicate with backend

⚠️ Challenges We Faced

A few things were trickier than expected:

  • Designing role-based logic without making it messy
  • Structuring MongoDB collections properly
  • Managing transactions and consistency
  • Keeping frontend simple but still functional

How we upload resources:


▶️ Running the Project

  1. Start MongoDB

  2. Backend

`cd backend
python manage.py runserver 8000`
Enter fullscreen mode Exit fullscreen mode
  1. Frontend
`
cd frontend
python -m http.server 5500`
Enter fullscreen mode Exit fullscreen mode
  1. Open
`http://localhost:5500`

Enter fullscreen mode Exit fullscreen mode


What We Learnt

Building AgriExchange taught us more than just coding:

  • How to design real-world systems
  • When to choose NoSQL over SQL
  • How frontend and backend actually communicate
  • Why simplicity is often better than complexity

Demo Video
[( https://youtu.be/Sq3dXHcH5-g )]

GitHub Repo
[( https://github.com/EIRAREDDY/KARSHAK-BHANDHU )]

Top comments (0)