How bhavana23jagadeesan/mongo_db works
AgriLink is a two-sided agricultural marketplace for buyers and farmers. Buyers authenticate, browse and filter approved produce, manage a cart, and access order tracking; farmers manage listings, orders, returns, payments, inventory, and business insights. The sampled backend routes implement authentication, product listings, order lifecycle, and analytics over MongoDB models. Several seller views and client API interactions were not excerpted, so their internal data flows are not asserted.
Main entry points: App.jsx Role-based app · server.js HTTP server · authMiddleware.js Token and role checks · orderRoutes.js Order API
Components 27
Marketplace client
- Role-based app
client/src/App.jsx - Authentication dialog
client/src/components/AuthModal.jsx - Auth state
client/src/context/AuthContext.jsx - Browse and filter
client/src/components/buyer/CategoryBar.jsx - Product cards
client/src/components/buyer/ProductCard.jsx - Product details
client/src/components/buyer/ProductDetailModal.jsx - Cart state
client/src/context/CartContext.jsx - Cart and checkout
client/src/components/buyer/CartDrawer.jsx - Buyer orders
client/src/components/buyer/MyOrders.jsx
Farmer workspace
- Listings management
client/src/components/seller/MyListings.jsx - Listing editor
client/src/components/seller/AddListingModal.jsx - Active orders
client/src/components/seller/ActiveOrdersView.jsx - Seller insights
client/src/components/seller/SellerSubViews.jsx - Payments overview
client/src/components/seller/PaymentsOverview.jsx
API services
- HTTP server
server/server.js - Authentication API
server/routes/authRoutes.js - Product API
server/routes/productRoutes.js - Order API
server/routes/orderRoutes.js - Analytics API
server/routes/analyticsRoutes.js - Token and role checks
server/middleware/authMiddleware.js
Domain and persistence
- User records
server/models/User.js - Product records
server/models/Product.js - Order records
server/models/Order.js - Database connection
server/config/db.js
Other components
- Buyer
- Farmer
- MongoDB
Connections 37
- Buyer → Role-based app: uses marketplace
client/src/App.jsx - Farmer → Role-based app: uses workspace
client/src/App.jsx - Role-based app → Authentication dialog: renders
client/src/App.jsx - Role-based app → Browse and filter: renders
client/src/App.jsx - Role-based app → Product cards: renders
client/src/App.jsx - Role-based app → Product details: renders
client/src/App.jsx - Role-based app → Cart and checkout: renders
client/src/App.jsx - Role-based app → Buyer orders: renders
client/src/App.jsx - Role-based app → Listings management: renders
client/src/App.jsx - Role-based app → Listing editor: renders
client/src/App.jsx - Role-based app → Active orders: renders
client/src/App.jsx - Role-based app → Seller insights: renders
client/src/App.jsx - Role-based app → Payments overview: renders
client/src/App.jsx - Role-based app → Auth state: reads user
client/src/App.jsx - Role-based app → Product API: fetches products
client/src/App.jsx - Authentication dialog → Auth state: uses auth
client/src/components/AuthModal.jsx - Product cards → Cart state: adds products
client/src/components/buyer/ProductCard.jsx - Product details → Cart state: adds products
client/src/components/buyer/ProductDetailModal.jsx - Cart and checkout → Cart state: uses cart
client/src/components/buyer/CartDrawer.jsx - Buyer orders → Auth state: uses auth
client/src/components/buyer/MyOrders.jsx - HTTP server → Authentication API: mounts routes
server/server.js - HTTP server → Product API: mounts routes
server/server.js - HTTP server → Order API: mounts routes
server/server.js - HTTP server → Analytics API: mounts routes
server/server.js - Authentication API → User records: reads and writes
server/routes/authRoutes.js - Authentication API → Token and role checks: protects profile
server/routes/authRoutes.js - Product API → Product records: reads and writes
server/routes/productRoutes.js - Product API → Token and role checks: checks farmer
server/routes/productRoutes.js - Order API → Order records: reads and writes
server/routes/orderRoutes.js - Order API → Product records: looks up product
server/routes/orderRoutes.js - Order API → Token and role checks: checks access
server/routes/orderRoutes.js - Analytics API → Order records: queries analytics
server/routes/analyticsRoutes.js - Analytics API → Product records: queries analytics
server/routes/analyticsRoutes.js - Analytics API → Token and role checks: checks access
server/routes/analyticsRoutes.js - Token and role checks → User records: loads user
server/middleware/authMiddleware.js - HTTP server → Database connection: connects database
server/server.js - Database connection → MongoDB: opens connection
server/config/db.js