# betorobson/nodejs-environment-development-in-docker architecture

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

- Interactive diagram: https://gitdiagram.com/betorobson/nodejs-environment-development-in-docker
- Repository: https://github.com/betorobson/nodejs-environment-development-in-docker

## Overview

##### Project type and purpose
- This is a boilerplate “development-environment template” rather than a user-facing application. Its goal is to provide a consistent, Docker-based NodeJS (and optional PHP) environment for developers, complete with VSCode debugging support, automatic rebuilds via nodemon, and version-bump CI workflows.

##### File structure
- Top-level Docker orchestration:
- Dockerfile + docker-compose.yml at project root define your NodeJS service (and any dependencies you add).
- php/Dockerfile + php/docker-compose.yml define a side-by-side PHP service.
- NodeJS source under src/:
- src/index.ts is the main entry point.
- src/helpers houses shared utilities (api-response.js, teste.ts, workers.js).
- tsconfig.json + tsconfig.worker.json configure your main process and worker builds.
- Configuration files:
- nodemon.json drives hot-reload in the Node container.
- .eslintrc, .prettierrc standardize linting/formatting.
- CI/CD:
- .github/workflows/*.yml handle bumping versions, tests, and master/develop branch automations.

##### README for additional insights
- Emphasis on “docker-compose up” to stand up the entire stack.
- VSCode debug configuration named “My NodeJS: Attach to Docker.”
- Minimal external dependencies aside from Docker and Node.
- PHP is optional but provided for polyglot demos—therefore treated as a separate service.

a. Main components
- Developer Workstation (VSCode + Docker CLI)
- Docker Engine (running locally)
- Container A: NodeJS Service
– Entrypoint: src/index.ts
– Hot-reload via nodemon
– Worker threads/processes (tsconfig.worker.json)
– Helpers library
- Container B: PHP Service (optional)
– Entrypoint: php/src/index.php
- Network: Docker Compose bridge network
- CI/CD GitHub Actions (version-bump, test pipelines)
b. Relationships and interactions
- Developer triggers “docker-compose up” → Docker Engine
- Docker Engine launches NodeJS container and PHP container
- VSCode attaches (via remote debugger) to NodeJS container’s debug port
- NodeJS container mounts host src/ directory for live code updates
- Optionally, NodeJS ↔ PHP container could communicate over HTTP if configured
c. Architectural patterns
- Service-based separation: each language/service in its own container
- Volume-mounted source directories for 1:1 parity dev environment
- Clear config segregation: tsconfig vs. tsconfig.worker for multi-process builds
- CI/CD pipelines external to runtime (GitHub Actions)
d. Key technologies/frameworks
- Docker & Docker Compose
- NodeJS + TypeScript + nodemon
- VSCode Remote Debugger
- PHP (via official PHP image)
- ESLint, Prettier, EditorConfig for code quality
- GitHub Actions for CI/CD

##### Detail without overthinking
- Break the NodeJS container into sub-components: entrypoint, hot-reload, workers, helper modules.
- Optional PHP service as a parallel container.
- Continuous integration pipeline triggering on bump-version commits.
- Cross-cutting concerns (lint, format, debug).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Project Configuration
    subgraph "Project Configuration" 
        DF["Dockerfile"]:::service
        DC["docker-compose.yml"]:::service
        click DF "https://github.com/betorobson/nodejs-environment-development-in-docker/tree/master/Dockerfile"
        click DC "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/docker-compose.yml"
    end

    %% Developer Workstation
    subgraph "Developer Workstation" 
        VS["VSCode"]:::dev
        CLI["Docker CLI"]:::dev
        click VS "https://github.com/betorobson/nodejs-environment-development-in-docker/tree/master/.vscode/"
    end

    %% Infrastructure
    DOCKER["Docker Engine"]:::infra

    %% Application Services
    subgraph "Docker Compose Network"
        direction TB
        subgraph "NodeJS Container" 
            direction TB
            ENTRY["src/index.ts"]:::service
            HELPER_GROUP["Helpers Library"]:::service
            HR["nodemon.json"]:::service
            TSC["tsconfig.json"]:::service
            TSW["tsconfig.worker.json"]:::service
            PKG["package.json"]:::service

            subgraph Helpers
                direction TB
                H1["api-response.js"]:::service
                H2["teste.ts"]:::service
                H3["workers.js"]:::service
                click H1 "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/src/helpers/api-response.js"
                click H2 "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/src/helpers/teste.ts"
                click H3 "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/src/helpers/workers.js"
            end

            click ENTRY "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/src/index.ts"
            click HR "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/nodemon.json"
            click TSC "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/tsconfig.json"
            click TSW "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/tsconfig.worker.json"
            click PKG "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/package.json"
        end

        subgraph "PHP Container (optional)"
            direction TB
            PHP_ENTRY["php/src/index.php"]:::service
            click PHP_ENTRY "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/php/src/index.php"
        end
    end

    %% CI/CD
    CI["GitHub Actions"]:::cicd
    click CI "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/.github/workflows/bump-version.yml"
    click CI "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/.github/workflows/develop.yml"
    click CI "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/.github/workflows/master.yml"
    click CI "https://github.com/betorobson/nodejs-environment-development-in-docker/blob/master/.github/workflows/test-version.yml"

    %% Connections
    VS -->|attach debugger| ENTRY
    CLI -->|runs docker-compose up| DC
    DC -->|orchestrates| DOCKER
    DOCKER -->|launches| ENTRY
    DOCKER -->|launches| PHP_ENTRY
    ENTRY <-->|volume mount| DC
    ENTRY <-->|network| PHP_ENTRY
    CI <-->|trigger on push| DC

    %% Styles
    classDef dev fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef infra fill:#F0F0F0,stroke:#666666,color:#333333;
    classDef service fill:#E6FFED,stroke:#28A745,color:#234F1E;
    classDef cicd fill:#FFF5E6,stroke:#D9822B,color:#A35B00;
```
