How ansukr07/wooltrace works
Purpose and Entry Points
This is a Vite/React wool supply-chain platform spanning farmers, inspectors, processors, warehouses, sellers, transport, teachers, and public users. The frontend bootstraps at src/main.jsx, composes routing/UI in src/App.jsx, and is deployable as serverless functions via vercel.json. Backend HTTP entry points are the route-like files under api/, notably api/login.js, api/batches.js, api/processing.js, and api/market.js.
Client Application Shell and Access Control
Role-specific layouts organize authenticated workspaces: src/layouts/FarmerLayout.jsx, src/layouts/ProcessingLayout.jsx, src/layouts/WarehouseLayout.jsx, and src/layouts/SellerLayout.jsx. src/components/ProtectedRoute.jsx forms the client-side route-access boundary. Shared authentication and cross-page application state live in src/context/AuthContext.jsx, src/context/GlobalStateContext.jsx, and src/context/WoolKartContext.jsx.
Batch Traceability and Quality Lifecycle
The central domain entity is the wool batch, persisted through api/_models/WoolBatch.js. Farmers create/manage and track stock through src/pages/farmer/MyWool.jsx, src/pages/farmer/BatchDetail.jsx, and src/pages/farmer/TrackWool.jsx; public users can inspect a batch without entering a role workspace at src/pages/public/PublicTrackBatch.jsx. The backend’s batch boundary is api/batches.js. Traceability is rendered through src/components/TraceabilityTimeline.jsx.
Quality inspection requests, resulting certificates, and public certificate verification are represented by api/_models/InspectionRequest.js, api/_models/QualityCertificate.js, and api/qa.js. Inspector workflows are centered in src/pages/inspector/InspectionDetail.jsx and src/pages/inspector/Certificates.jsx; public verification is src/pages/public/VerifyCertificate.jsx. Frontend calls are isolated behind src/services/qa/qaService.js.
Processing and Warehouse Handoffs
Processing requests and records model conversion of batches at api/_models/ProcessingRequest.js and api/_models/ProcessingRecord.js. The serverless processing API, api/processing.js, coordinates persistence plus the external CEDA-related integration encapsulated by api/_utils/processingCedaService.js and api/_utils/ceda.js. Processors operate through src/pages/processing/ProcessingDashboard.jsx and src/pages/processing/ProcessingBatchDetail.jsx, using src/services/processing/processingService.js.
Warehouse work is a subsequent custody boundary: intake, inventory, release, and requests are separated into src/pages/warehouse/WarehouseCheckIn.jsx, src/pages/warehouse/WarehouseInventory.jsx, and src/pages/warehouse/WarehouseReleases.jsx. Transport currently has a dedicated dashboard at src/pages/transport/TransportDashboard.jsx.
Market, Bidding, and Orders
Two commerce-oriented flows exist. Wool listing/bidding is modeled by api/_models/BiddingListing.js and api/_models/Bid.js, exposed from api/bidding.js, and consumed by seller views such as src/pages/seller/Marketplace.jsx, src/pages/seller/Bids.jsx, and src/pages/seller/BidDetail.jsx.
Orders are persisted by api/_models/Order.js and served through api/market.js. Seller order/inventory flows are in src/pages/seller/Inventory.jsx and src/pages/seller/Orders.jsx. A farmer-facing WoolKart storefront has its own cart state and flow in src/context/WoolKartContext.jsx, src/pages/farmer/woolkart/WoolKartRoot.jsx, and src/pages/farmer/woolkart/Checkout.jsx.
Market Data and Learning Services
Market pricing/data is abstracted behind provider interfaces in src/services/market/MarketDataProvider.js, with demo and Agmarknet implementations in src/services/market/DemoDataProvider.js and src/services/market/AgmarknetProvider.js; API interaction is centralized by src/services/market/marketService.js.
Learning content is persisted as api/_models/LearningResource.js and exposed via api/learning-resources.js. Farmer academy and teacher resource-library experiences are src/pages/farmer/Academy.jsx and src/pages/teacher/ResourceLibrary.jsx.
Runtime and Persistence Boundaries
The browser runtime is React on Vite (vite.config.js), while api/*.js are likely Vercel serverless endpoints. Backend models and route handlers share database setup through api/_utils/db.js; users and roles are represented by api/_models/User.js, with registration/login handled in api/register.js and api/login.js. No payment, mapping, or database vendor is identifiable from the supplied tree.
Main entry points: db.js Database connection · WoolBatch.js Wool batches · processing.js Processing API · App.jsx App routing shell
Components 27
React browser app
Vite client for role workspaces and public access.
- Vite bootstrap
src/main.jsx - App routing shell
src/App.jsx - Auth and app state · Authentication, shared state, and WoolKart cart state.
src/context/AuthContext.jsx - Protected routes
src/components/ProtectedRoute.jsx - Role workspaces · Farmer, processor, warehouse, and seller application shells.
src/layouts/FarmerLayout.jsx - Batch tracking UI · Batch management, tracking, and public traceability views.
src/pages/farmer/MyWool.jsx - Traceability timeline
src/components/TraceabilityTimeline.jsx - Inspection and certificates UI · Inspection workflows, certificates, and public verification.
src/pages/inspector/InspectionDetail.jsx - Processing workspace
src/pages/processing/ProcessingDashboard.jsx - Warehouse and transport UI · Check-in, inventory, release, and transport operations.
src/pages/warehouse/WarehouseCheckIn.jsx - Marketplace and WoolKart UI · Listings, bids, orders, inventory, cart, and checkout.
src/pages/seller/Marketplace.jsx - Academy and resource library
src/pages/farmer/Academy.jsx
Serverless API
Vercel route handlers and backend orchestration.
- Authentication API · Registration and login endpoints.
api/login.js - Batch API
api/batches.js - Quality API · Handles inspection requests, certificates, and verification.
api/qa.js - Processing API · Coordinates processing records and CEDA integration.
api/processing.js - Bidding and market APIs · Listing, bid, order, and inventory endpoints.
api/bidding.js - Learning resources API
api/learning-resources.js
Domain persistence
Shared database models.
- Users and roles
api/_models/User.js - Wool batches · Central traceability entity.
api/_models/WoolBatch.js - Inspection and certificates · Inspection requests and quality certificates.
api/_models/InspectionRequest.js - Processing records · Processing requests and conversion records.
api/_models/ProcessingRequest.js - Listings, bids, and orders · Marketplace bidding and order persistence.
api/_models/BiddingListing.js - Learning resources
api/_models/LearningResource.js - Database connection · Shared model and route database setup.
api/_utils/db.js
External integration
- CEDA integration
api/_utils/processingCedaService.js - Market data providers · Demo and Agmarknet market-data implementations.
src/services/market/MarketDataProvider.js
Connections 30
- Vite bootstrap → App routing shell: mounts
- App routing shell → Auth and app state: uses
- App routing shell → Protected routes: routes through
- Protected routes → Role workspaces: authorizes
- Role workspaces → Batch tracking UI: hosts
- Batch tracking UI → Traceability timeline: renders
- Batch tracking UI → Batch API: manages batches
- Inspection and certificates UI → Quality API: inspection workflow
- Processing workspace → Processing API: submits processing
- Warehouse and transport UI → Batch API: updates custody
- Marketplace and WoolKart UI → Bidding and market APIs: trades and orders
- Marketplace and WoolKart UI → Market data providers: reads pricing
- Academy and resource library → Learning resources API: uses resources
- Auth and app state → Authentication API: authenticates
- Authentication API → Users and roles: reads and writes
- Batch API → Wool batches: persists
- Quality API → Wool batches: traces batch
- Quality API → Inspection and certificates: persists
- Processing API → Wool batches: updates lifecycle
- Processing API → Processing records: persists
- Processing API → CEDA integration: integrates
- Bidding and market APIs → Wool batches: lists inventory
- Bidding and market APIs → Listings, bids, and orders: persists
- Learning resources API → Learning resources: persists
- Users and roles → Database connection: connects via
- Wool batches → Database connection: connects via
- Inspection and certificates → Database connection: connects via
- Processing records → Database connection: connects via
- Listings, bids, and orders → Database connection: connects via
- Learning resources → Database connection: connects via