How nirant-nk/smart-growth-tracker works
Project type and purpose
• This is a two-fold project:
• A backend RESTful API implemented in Node.js/Express (under the “api” folder)
• A placeholder for a frontend/UI (under the “ui” folder)
• Its domain: tracking child growth metrics (z-scores, growth standards) and providing recommendations via CRUD endpoints (users, children, growth records, alerts, recommendations).
File structure
• Top-level:
• api/ — contains a typical MVC-style Express service
• ui/ — an empty folder for the eventual front end
• Inside api/:
• package.json & package-lock.json — dependencies and scripts
• public/ — static assets (currently empty)
• src/
– assets/growthStandards.js — domain data source for WHO growth charts
– constants.js — app-wide constants
– controllers/ — route handlers (child, growth, recommendation, user)
– database/connect.js — DB connection logic
– index.js — server entrypoint
– middlewares/ — auth, error handling
– models/ — Mongoose (or similar) schemas for alerts, children, growth, recommendations, users
– routes/ — Express route definitions linking paths to controllers
– utils/ — validators, z-score calculator
• No external services beyond a database (likely MongoDB).
a. Main components
• Frontend (UI) – a web or mobile client
• API Server – Node.js + Express application
• Database – MongoDB (or similar document store)
• Static Data Module – growthStandards.js loaded by the API
• External Auth (optional) – JWT verification in authMiddleware
b. Relationships and data flow
• Frontend sends HTTP(S) requests (REST calls) → API Server
• API Server:
– routes → controller → business logic (utils, assets) → models
– controllers read/write → Database
– middlewares handle auth & errors on both inbound and outbound
• Database returns data → API Server → Frontend
c. Architectural patterns and principles
• MVC/Layered architecture
• Separation of concerns:
– Routes define API surface
– Controllers handle orchestration
– Models handle persistence
– Utils and assets are pure functions/data modules
– Middlewares handle cross-cutting concerns (auth, error handling)
• RESTful design for endpoints
d. Key technologies
• Node.js & Express
• Mongoose (implied) or another MongoDB client
• JWT or similar token-based auth
• WHO growth standard data (in assets module)
• Validation logic (validators.js)
Detail
• Module (authMiddleware, errorHandler, validators) as separate components
• Interactions with the static asset module for z-score computation
• Five resource domains (user, child, growth, recommendation, alert) either as sub-modules in the controller layer or individual route clusters