# fernandoyaguana/restapi architecture

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

- Interactive diagram: https://gitdiagram.com/fernandoyaguana/restapi
- Repository: https://github.com/fernandoyaguana/restapi

## Overview

##### Project Type and Purpose
- This is a simple backend microservice (Node.js + Express) implementing a REST API that returns a “Hello World” JSON message. It can be run locally or as a Docker container.

##### Key Components
a. Client (Browser or API client such as Postman)
b. HTTP Layer (REST API interface)
c. Express.js Application
- index.js (route definition, server startup)
- node_modules (runtime libraries, e.g., express)
d. Node.js Runtime
e. Containerization Layer (Docker Engine + Dockerfile)
f. Deployment Artifact (Docker Image in Docker Hub)

##### Relationships and Data Flow
- The client issues an HTTP GET request to `http://localhost:3000/`.
- The Docker Engine routes the request into the running container.
- Inside the container the Node.js runtime loads Express, which dispatches to the route handler in `index.js`.
- Express builds a JSON response (`{ "message": "Hola Mundo Desde RestApi" }`) and sends it back along the same path.

##### Architectural Patterns and Principles
- REST architectural style: stateless HTTP service, JSON over HTTP.
- Single-responsibility: `index.js` only defines routing and response.
- Containerization: isolation and portability via Docker.

##### Technologies and Artifacts
- Node.js (runtime environment)
- Express.js (web framework)
- Dockerfile → Docker Image → Docker Container
- GitHub Repo (source code) and Docker Hub (image registry)

- Clear labels for all components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actor
    subgraph "External Actor"
        Client["Client (Browser/Postman)"]:::external
    end

    %% Registry & Source
    subgraph "Registry & Source"
        GitHub["GitHub Repo"]:::external
        DockerHub["Docker Hub"]:::external
        README["README.md"]:::code
    end

    %% Container Host
    subgraph "Container Host"
        DockerEngine["Docker Engine"]:::infra
        DockerfileNode["Dockerfile"]:::code
    end

    %% Running Container
    subgraph "Docker Container"
        NodeRuntime["Node.js Runtime"]:::service
        ExpressApp["Express.js App"]:::service
        Index["index.js"]:::code
        NodeModules["node_modules/"]:::code
        PackageJSON["package.json"]:::code
        PackageLock["package-lock.json"]:::code
    end

    %% Connections
    GitHub -->|"docker build & push"| DockerHub
    DockerHub -->|"docker pull & run"| DockerEngine
    DockerEngine -->|"HTTP GET /"| NodeRuntime
    NodeRuntime -->|"loads Express"| ExpressApp
    ExpressApp -->|"route handler"| Index
    ExpressApp --> NodeModules
    ExpressApp --> PackageJSON
    ExpressApp --> PackageLock
    Index -->|"builds JSON response"| ExpressApp
    ExpressApp -->|"sends response"| NodeRuntime
    NodeRuntime -->|"200 OK + JSON"| DockerEngine
    DockerEngine -->|"200 OK + JSON"| Client

    %% Click Events
    click Index "https://github.com/fernandoyaguana/restapi/blob/main/index.js"
    click NodeModules "https://github.com/fernandoyaguana/restapi/tree/main/node_modules/"
    click PackageJSON "https://github.com/fernandoyaguana/restapi/blob/main/package.json"
    click PackageLock "https://github.com/fernandoyaguana/restapi/blob/main/package-lock.json"
    click DockerfileNode "https://github.com/fernandoyaguana/restapi/tree/main/Dockerfile"
    click README "https://github.com/fernandoyaguana/restapi/blob/main/README.md"

    %% Styles
    classDef external fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef service fill:#90EE90,stroke:#000,stroke-width:1px
    classDef infra fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef code fill:#FFA500,stroke:#000,stroke-width:1px
```
