How uzibytes/knitkraft works
Purpose and runtime
KnitKraft is a role-based wool-industry platform spanning farm production, services, storage/transport, trading, education, and market information. It is a server-rendered Node.js/Express application using EJS, backed by MongoDB, with deployment intended for Render. Primary startup chain: package.json → bin/www → app.js.
HTTP application boundary
Express application setup, middleware, static asset hosting, view rendering, and route mounting are centralized in app.js. Browser requests enter page routes and API/auth routes through routes/index.js, routes/users.js, and routes/api.js; responses are predominantly rendered EJS pages rather than a separate SPA/API client.
Authentication and role access
Account registration/login and user-facing identity operations are handled by src/controllers/auth.controller.js and src/controllers/user.controller.js. JWT authentication and signup validation form the primary access-control boundary in src/middleware/authJwt.js, src/middleware/verifySignUp.js, and src/middleware/index.js. Role-specific interfaces are represented by separate views, including farmer, teacher, transport, warehouse, seller, and service areas.
Persistence model
MongoDB connection ownership is isolated in src/db/db.js. Mongoose-style domain entities cover users plus core operational records: models/userregister.js, models/Transport.js, models/Warehouse.js, models/Service.js, and models/Meeting.js. These models are the persistence boundary for identities, logistics/storage requests, service workflows, and learning sessions.
Wool supply-chain operations
The product’s operational flow starts with farmer actions, then crosses service, transport, and warehousing functions before marketplace-oriented buying/selling. Relevant workflow screens include views/farmer/index.ejs, views/input/Transportation.ejs, views/input/Warehouse.ejs, views/table/Farmer-Transportation.ejs, and views/table/Farmer-Warehouse.ejs. Transport and warehouse partners have dedicated landing interfaces at views/transport/index.ejs and views/warehouse/index.ejs.
Marketplace and service catalog
Trading and service discovery are delivered as server-rendered modules. Wool marketplace screens reside in views/Woolkart/index.ejs and views/Woolkart/buynow.ejs; negotiation has views/Pages/negotiate.ejs. Service offerings—such as transport, warehousing, grading, insurance, processing, and veterinary support—are organized under views/Services/index.ejs and service-specific EJS pages, with service records represented by models/Service.js.
Education, analytics, and localization
Training/live or recorded learning experiences are grouped in views/Learning/index.ejs, views/Learning/meetPage.ejs, and views/Learning/video.ejs, with meetings persisted in models/Meeting.js. Market/statistics presentation is represented by views/Statistics/index.ejs. English and Hindi translation resources are supplied via lang/eng.json and lang/hin.json.
Presentation and client delivery
EJS templates compose shared navigation and layout through views/partials/header.ejs, views/partials/AppSidebar.ejs, and views/partials/footer.ejs. Mobile-oriented static frontend assets, including service-worker artifacts, are served from public/__manifest.json, public/__service-worker.js, and public/assets/; Bootstrap/SASS-based styling and JavaScript enhancements remain client-side presentation concerns.
Main entry points: index.js Page and API routes · userregister.js Operational models · app.js Express application · Transportation.ejs Transport and warehouse
Components 18
Runtime
- Package startup · Starts the Express runtime chain.
package.json - HTTP launcher
bin/www
Server & Access
- Express application · Owns middleware, static delivery, views, and route mounting.
app.js - Page and API routes
routes/index.js - Auth controllers
src/controllers/auth.controller.js - User controller
src/controllers/user.controller.js - JWT and signup guards
src/middleware/index.js - MongoDB connection
src/db/db.js
Supply Chain
- Operational models · Users, transport, warehouse, service, and meeting records.
models/userregister.js - Farmer workflow
views/farmer/index.ejs - Transport and warehouse · Captures logistics and storage requests and partner work.
views/input/Transportation.ejs - Service catalog · Discover transport, storage, grading, insurance, processing, and veterinary services.
views/Services/index.ejs - Wool marketplace · Buying, selling, and negotiation screens.
views/Woolkart/index.ejs
Rendered Experience
- Learning sessions · Live and recorded learning experiences.
views/Learning/index.ejs - Market statistics
views/Statistics/index.ejs - Shared EJS layout · Navigation, sidebar, and footer compose rendered pages.
views/partials/header.ejs - English and Hindi
lang/eng.json - Mobile static assets · Manifest, service worker, and client assets.
public/__manifest.json
Connections 23
- Package startup → HTTP launcher: starts
- HTTP launcher → Express application: loads
- Express application → Page and API routes: mounts
- Express application → JWT and signup guards: applies
- Express application → Shared EJS layout: renders
- Express application → Mobile static assets: serves
- Page and API routes → Auth controllers: identity requests
- Page and API routes → User controller: user requests
- JWT and signup guards → Auth controllers: protects
- Auth controllers → Operational models: accounts
- User controller → Operational models: users
- Operational models → MongoDB connection: persists through
- Page and API routes → Farmer workflow: renders
- Farmer workflow → Transport and warehouse: initiates requests
- Transport and warehouse → Service catalog: uses offerings
- Transport and warehouse → Operational models: stores workflows
- Service catalog → Operational models: uses service records
- Wool marketplace → Operational models: uses operational data
- Learning sessions → Operational models: stores meetings
- Page and API routes → Wool marketplace: renders
- Page and API routes → Learning sessions: renders
- Page and API routes → Market statistics: renders
- Shared EJS layout → English and Hindi: localizes