How alexisivanmt/microservice-project-exercisetracker works
Project type and purpose
• This is a full-stack web application with a RESTful API (“Exercise Tracker API”) plus a simple single-page web UI.
• Built on Node.js/Express for the server, MongoDB (via Mongoose) for persistence, and a minimal HTML/CSS frontend under views/ and public/.
File structure
• Top-level entry point: index.js.
• config/db.js: database connection setup (MONGO_URI).
• routes/users.js: defines HTTP routes under /api/users.
• controllers/userController.js: business logic for creating users, logging exercises, fetching logs.
• models/User.js: Mongoose schema/model for user and embedded exercise subdocs.
• views/index.html + public/style.css: the client-side web UI.
• assets folder holds preview image only.
Key README insights
• Exposes endpoints: POST /api/users, GET /api/users, POST /api/users/:_id/exercises, GET /api/users/:_id/logs.
• UI on root (/) interacts with these endpoints.
• Uses environment variables for DB URI and PORT.
a. Main components
• Browser / Web UI (index.html + style.css)
• Express server (index.js + routes + controllers)
• MongoDB database (hosted externally or locally)
• Configuration layer (env variables, config/db.js)
b. Relationships & data flows
• Browser issues HTTP(S) requests to Express endpoints.
• Express routes delegate to controllers, which call Mongoose models.
• Mongoose interacts with MongoDB over the network.
• Responses flow back to the client (JSON for API calls, HTML/CSS for the web page).
c. Architectural patterns
• MVC-style separation: Routes → Controllers → Models
• Layered architecture (Presentation → API → Business Logic → Persistence)
d. Technologies & libraries
• Node.js, Express.js, Mongoose/MongoDB
• HTML/CSS for frontend
• dotenv or environment variables for configuration