How knightempire/lab-backend works
Project type and purpose
• This is a Node.js-based backend service (“lab-backend”), built with Express.js.
• It exposes RESTful endpoints for lab asset management (products, damaged items, requests, re-issuance, returns, notifications, user/admin profiles).
• It’s designed to run in Docker (Dockerfile + docker-compose), connects to a database, integrates with Google Sheets and an email service, and uses JWT/RSA for auth.
File structure
Top-level components:
• app.js – Express app entrypoint
• config/db.js – database connection setup
• controllers/ – business logic grouped by domain (admin, damaged, login, etc.)
• routers/ – Express route definitions that map URLs → controllers
• models/ – ORM/Mongoose schemas for each domain object
• middleware/
– auth/ (tokencreation.js, tokenvalidate.js)
– mail/ (templating, mail.js)
– googlesheet.js (integration with Google Sheets API)
– rsa/ (key management for JWT or encryption)
• docker-compose.yml & Dockerfile – defines service containers (app + DB)
• .github/workflows – CI pipeline
Architectural patterns:
• MVC-like layering: Routers → Controllers → Models
• Middleware pipeline for cross-cutting concerns (auth, mail, encryption)
• Containerized deployment
README
• Minimal – only project name (“lab-backend”).
Diagramming recommendations
– Blue for API/Middleware
– Green for Business Logic
– Orange for Data Layer
– Gray for external services
• Related components inside labeled containers (e.g., “Auth Middleware,” “Mail Middleware”).
Essential architectural elements to capture
• Docker Compose network boundary showing the two main containers (app + DB).
• Express.js entrypoint with middleware sequence: RSA auth → business controllers → mail/Google Sheets calls.
• Models mapping to persistent storage inside the DB container.
• External service calls separate from core HTTP request flow.