# alexisivanmt/microservice-project-exercisetracker architecture

> Architecture diagram of the GitHub repository alexisivanmt/microservice-project-exercisetracker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexisivanmt/microservice-project-exercisetracker
- Repository: https://github.com/alexisivanmt/microservice-project-exercisetracker

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client Layer"
        Browser["Browser"]:::client
        IndexHTML["index.html"]:::client
        StyleCSS["style.css"]:::client
    end

    subgraph "Server Layer"
        Config["config/db.js"]:::config
        Entry["index.js"]:::server
        Routes["routes/users.js"]:::server
        Controllers["controllers/userController.js"]:::server
        Models["models/User.js"]:::persistence
    end

    Database[(MongoDB)]:::database

    %% Client to Server
    IndexHTML -->|"served as HTML"| Browser
    StyleCSS -->|"served as CSS"| Browser
    Browser -->|"HTTP GET /"| Entry
    Browser -->|"HTTP POST /api/users"| Entry
    Browser -->|"HTTP GET /api/users"| Entry
    Browser -->|"HTTP POST /api/users/:_id/exercises"| Entry
    Browser -->|"HTTP GET /api/users/:_id/logs"| Entry

    %% Server internal flows
    Entry -->|"loads DB config"| Config
    Entry -->|"routes API calls"| Routes
    Routes -->|"delegates to"| Controllers
    Controllers -->|"invokes schema"| Models
    Models -->|"performs queries"| Database

    %% Response flows
    Database -->|"data results"| Models
    Models -->|"returns to controller"| Controllers
    Controllers -->|"responds to routes"| Routes
    Routes -->|"sends response"| Entry
    Entry -->|"HTTP response"| Browser

    %% Click Events
    click IndexHTML "https://github.com/alexisivanmt/microservice-project-exercisetracker/blob/main/views/index.html"
    click StyleCSS "https://github.com/alexisivanmt/microservice-project-exercisetracker/blob/main/public/style.css"
    click Entry "https://github.com/alexisivanmt/microservice-project-exercisetracker/blob/main/index.js"
    click Routes "https://github.com/alexisivanmt/microservice-project-exercisetracker/blob/main/routes/users.js"
    click Controllers "https://github.com/alexisivanmt/microservice-project-exercisetracker/blob/main/controllers/userController.js"
    click Config "https://github.com/alexisivanmt/microservice-project-exercisetracker/blob/main/config/db.js"
    click Models "https://github.com/alexisivanmt/microservice-project-exercisetracker/blob/main/models/User.js"

    classDef client fill:#f0f8ff,stroke:#333,stroke-width:1px
    classDef server fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef config fill:#e6ffe6,stroke:#333,stroke-width:1px
    classDef persistence fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef database fill:#a2d5ab,stroke:#333,stroke-width:1px
```
