How himanshumishra-03/university-procurement-portal works
Purpose and Runtime
This is a role-oriented academic procurement and inventory system: users request consumables/materials, inventory staff review and fulfill them, purchasing solicits supplier quotations and compares offers, and administrators manage users, courses, calendar, and requests. It runs as a Next.js frontend plus Express API, backed by PostgreSQL through Prisma. Container deployment is defined in docker-compose.yml, backend/Dockerfile, frontend/Dockerfile, and render.yaml.
Application Entry Points
The API composition root is backend/server.js, which performs dependency injection across repositories, services, controllers, middleware, and Express routes. The browser application uses the Next.js App Router from frontend/src/app/layout.js, with landing and login entry pages at frontend/src/app/page.js and frontend/src/app/login/page.jsx. Client API access is centralized in frontend/src/lib/api.js.
HTTP and Authorization Boundary
Express route modules expose domain APIs for authentication, inventory, requests, purchasing, students, and administration: backend/app_routes/auth.routes.js, backend/app_routes/inventory.routes.js, and backend/app_routes/purchasing.routes.js. Controllers translate HTTP requests to use-case calls, including backend/app_controllers/MaterialRequestController.js, backend/app_controllers/InventoryController.js, and backend/app_controllers/PurchasingController.js. backend/middleware/auth.middleware.js is the authentication/authorization boundary, using JWTs; credentials and session issuance are handled by backend/services/AuthService.js.
Domain Service and Persistence Layers
Business workflows reside in service classes: requests in backend/services/MaterialRequestService.js, stock/borrowing in backend/services/InventoryService.js, and supplier quotation/purchase work in backend/services/PurchasingService.js. These call repository interfaces and Prisma implementations, keeping database operations isolated: backend/repositories/MaterialRequestRepository.js, backend/repositories/prisma/PrismaMaterialRequestRepository.js, and backend/repositories/prisma/PrismaInventoryRepository.js. PostgreSQL schema evolution is owned by backend/prisma/schema.prisma and its migrations.
Request-to-Procurement Flow
Faculty and students initiate material or consumable needs through dashboard/request screens, such as frontend/src/app/dashboard/faculty/request/page.jsx and frontend/src/app/student/consumables/request/page.jsx. Requests flow through inventory review (frontend/src/app/dashboard/inventory/review/page.jsx), then purchasing request and quotation views (frontend/src/app/dashboard/purchasing/requests/page.jsx, frontend/src/app/dashboard/purchasing/quotations/page.jsx). Purchasing manages suppliers and compares quotations through backend/services/SupplierService.js, backend/repositories/prisma/PrismaSupplierRepository.js, and backend/repositories/prisma/PrismaQuotationRepository.js.
Inventory Lifecycle
Inventory personnel manage catalog/stock, borrowing, history, and material-request fulfillment from frontend/src/app/dashboard/inventory/manage/page.jsx, frontend/src/app/dashboard/inventory/borrow/page.jsx, and frontend/src/app/dashboard/inventory/history/page.jsx. Backend inventory behavior is concentrated in backend/services/InventoryService.js and backend/repositories/InventoryRepository.js; resulting inventory state is persisted through Prisma and can feed request decisions.
External Interaction and Scheduled Operations
Supplier-facing RFQ access is exposed as a tokenized public frontend route at frontend/src/app/portal/rfq/[token]/page.jsx, separating external supplier interaction from authenticated dashboards. Email integration is encapsulated by backend/services/EmailService.js; operational scripts include overdue reminder dispatch in backend/scripts/overdueReminders.js and data/bootstrap scripts under backend/scripts/. Administrative functions are represented by backend/services/AdminService.js and frontend/src/app/dashboard/admin/page.jsx.
Main entry points: layout.js App Router · MaterialRequestController.js HTTP controllers · api.js Client API · PrismaMaterialRequestRepository.js Prisma repositories
Components 20
Next.js frontend
- App Router
frontend/src/app/layout.js - Request screens
frontend/src/app/dashboard/faculty/request/page.jsx - Inventory screens · Manage, borrow, review, and history workflows.
frontend/src/app/dashboard/inventory/manage/page.jsx - Purchasing screens · Request and quotation management.
frontend/src/app/dashboard/purchasing/requests/page.jsx - Public RFQ portal · Supplier-facing quotation access outside authenticated dashboards.
frontend/src/app/portal/rfq/[token]/page.jsx - Client API
frontend/src/lib/api.js
Express API
- API composition root · Wires repositories, services, controllers, middleware, and routes.
backend/server.js - JWT authorization
backend/middleware/auth.middleware.js - Domain routes · Authentication, inventory, requests, purchasing, student, and administration APIs.
backend/app_routes/inventory.routes.js - HTTP controllers · Translates HTTP operations to use cases.
backend/app_controllers/MaterialRequestController.js
Domain services
- Authentication · Validates credentials and issues sessions.
backend/services/AuthService.js - Material requests · Coordinates request review and fulfillment decisions.
backend/services/MaterialRequestService.js - Inventory lifecycle · Manages catalog, stock, borrowing, history, and fulfillment.
backend/services/InventoryService.js - Purchasing and quotations · Solicits, compares, and processes supplier offers.
backend/services/PurchasingService.js
Persistence
- Prisma repositories · Isolate request, inventory, supplier, and quotation database operations.
backend/repositories/prisma/PrismaMaterialRequestRepository.js - PostgreSQL · Schema and migrations are Prisma-owned.
backend/prisma/schema.prisma
External and operations
- Email integration · Delivers operational and supplier communications.
backend/services/EmailService.js - Overdue reminders
backend/scripts/overdueReminders.js - Container deployment · Runs frontend, API, and database services.
docker-compose.yml
Other components
- Browser users · Faculty, students, inventory, purchasing, and administrators.
Connections 27
- Browser users → App Router: uses
- App Router → Request screens: renders
- App Router → Inventory screens: renders
- App Router → Purchasing screens: renders
- App Router → Public RFQ portal: exposes
- Request screens → Client API: submits requests
- Inventory screens → Client API: manages stock
- Purchasing screens → Client API: manages procurement
- Public RFQ portal → Client API: submits quotations
- Client API → API composition root: HTTP
- API composition root → JWT authorization: protects routes
- JWT authorization → Domain routes: authorizes
- Domain routes → HTTP controllers: dispatches
- HTTP controllers → Authentication: auth operations
- HTTP controllers → Material requests: request operations
- HTTP controllers → Inventory lifecycle: inventory operations
- HTTP controllers → Purchasing and quotations: purchasing operations
- Material requests → Prisma repositories: persists requests
- Inventory lifecycle → Prisma repositories: persists inventory
- Purchasing and quotations → Prisma repositories: persists offers
- Prisma repositories → PostgreSQL: Prisma queries
- Purchasing and quotations → Email integration: sends RFQ communication
- Overdue reminders → Inventory lifecycle: checks overdue borrowing
- Overdue reminders → Email integration: sends reminders
- Container deployment → App Router: deploys
- Container deployment → API composition root: deploys
- Container deployment → PostgreSQL: provisions