How techops-recsys-lateral-hiring/developer-joi-delivery-nodejs works
This repo is a single-service Node.js/Express backend that exposes a REST API for a hyperlocal delivery domain (food + grocery), currently focused on:
• Cart operations (add product, view cart)
• Inventory health (stubbed endpoint in README)
• Seeded in-memory/data-layer scaffolding for dev/test scenarios
From the tree:
• src/app.js
• Express app composition: server bootstrapping, route wiring (likely), middleware, listening on port 8080.
• src/controllers/*
• HTTP layer (Express route handlers). Includes tests:
• cartController.js + cartController.test.js
• inventoryController.js + inventoryController.test.js
• src/services/*
• Use-case / application services:
• cartService.js
• productService.js
• userService.js
• src/domain/*
• Core business entities / domain model:
• cart.js, product.js, groceryProduct.js, foodProduct.js
• outlet.js, groceryStore.js, restaurant.js, groceryStore.js
• user.js
• src/seedData/seedData.js
• “Data layer” per README: initial population, factories; likely acts as repository substitute.
Architectural pattern to represent: layered Clean Architecture (even if simplified):
Controllers (Interface Adapters) → Services (Use Cases) → Domain (Entities), with SeedData acting like an in-memory repository/data source.
HTTP / Controllers layer
• CartController
• Endpoints: POST /cart/product, GET /cart/view
• InventoryController
• Endpoint: GET /inventory/health (stub)
Application / Services layer
• CartService
• ProductService
• UserService
Domain layer (Entities / Models)
• Cart
• Product (base) → GroceryProduct, FoodProduct (inheritance)
• Outlet (base) → GroceryStore, Restaurant (inheritance)
• User
Data layer substitute
• SeedData (factories + initial datasets for Users/Stores/Products)
• CartController → CartService
• InventoryController → ProductService (and/or inventory logic)
• CartService → ProductService (to fetch/validate product)
• CartService → UserService (to fetch/validate user)
• *Service → SeedData (data retrieval)
• *Service → Domain (construct/update entities like Cart, Product, Outlet, User)
Important principle to encode visually:
• Dependencies should point inward toward domain, consistent with Clean Architecture (even if seedData breaks purity). If seedData is imported directly by services, reflect that honestly.
Domain objects (Cart, Product, Outlet) as created/returned
• Client → CartController: POST /cart/product {userId, productId, outletId}
• CartController → CartService: addProductToCart(userId, productId, outletId)
• CartService → UserService: getUser(userId)
• UserService → SeedData: lookup user
• CartService → ProductService: getProduct(productId, outletId) / validate stock
• ProductService → SeedData: lookup outlet + product inventory
• CartService → SeedData: get/create cart for user
• CartService → Domain: add Product to Cart
• CartService → CartController: return {cart, product, sellingPrice}
• CartController → Client: HTTP 200 + JSON
This provides “most accurate” operational understanding without guessing additional systems.
Component (layered)
• app.js composition
• Controllers
• Services
• Domain entities + inheritance
• SeedData
Sequence for
• POST /cart/product
• (optional) GET /cart/view
Test view (optional but accurate)
• Jest tests (*.test.js) exercising controllers