# sujaykundu777/mern-docker architecture

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

- Interactive diagram: https://gitdiagram.com/sujaykundu777/mern-docker
- Repository: https://github.com/sujaykundu777/mern-docker

## Overview

##### Project type and purpose
- This is a full-stack MERN (MongoDB, Express, React, Node) web application scaffolded with Docker.
- The client folder holds a React single-page application. The server folder holds an Express/Node API that connects to MongoDB.
- Docker and Docker Compose orchestrate the multi-container setup for both development and production modes.

##### File structure
- Top-level:
- client/ – React front-end (“npm start” on port 3000, served via webpack and optionally nginx).
- server/ – Express/Node back-end (“node index.js” on port 8080, connects to MongoDB).
- docker-compose*.yml – Compose configs for dev, prod, and default.
- Dockerfile at root – typically for root-level orchestration.
- client/:
- Dockerfile, nginx-site.conf – configures a container running nginx to serve the built React app.
- src/, public/ – React source code, assets.
- server/:
- src/config – MongoDB config.
- src/models, src/routes – Mongoose schema and REST endpoints.
- index.dev.js / index.prod.js – environment-specific entrypoints.
- webpack/ – server bundling for modern JS syntax.
- Config files (.env, .babelrc, package.json) indicate environment variables, transpilation, dependencies.

##### README for additional insights
- Tier 1: React client container behind nginx.
- Tier 2: Express API container.
- Tier 3: MongoDB container (external service).
- Docker Compose brings up all containers and networks them.

##### Final checklist
- All components labeled (Client, Server, Database, Compose network).
- Environment overlays (dev/prod) if needed.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Docker Compose" 
        direction TB
        C["React + nginx\n(client container)"]:::container
        S["Express/Node API\n(server container)"]:::container
        DB["MongoDB\n(database container)"]:::database
        DF["Root Dockerfile"]:::config
        ENVS["Env & Build Config\n(.env, .babelrc,\npackage.json)"]:::config
    end

    Browser["Developer Browser"]:::client

    Browser -->|"HTTP 3000"| C
    C -->|"AJAX/Fetch 8080"| S
    S -->|"TCP 27017"| DB

    click C "https://github.com/sujaykundu777/mern-docker/tree/master/client/"
    click C "https://github.com/sujaykundu777/mern-docker/tree/master/client/Dockerfile"
    click C "https://github.com/sujaykundu777/mern-docker/blob/master/client/nginx-site.conf"
    click C "https://github.com/sujaykundu777/mern-docker/tree/master/client/src/"
    click C "https://github.com/sujaykundu777/mern-docker/tree/master/client/public/"
    click S "https://github.com/sujaykundu777/mern-docker/tree/master/server/"
    click S "https://github.com/sujaykundu777/mern-docker/tree/master/server/Dockerfile"
    click S "https://github.com/sujaykundu777/mern-docker/blob/master/server/src/index.dev.js"
    click S "https://github.com/sujaykundu777/mern-docker/blob/master/server/src/index.prod.js"
    click S "https://github.com/sujaykundu777/mern-docker/blob/master/server/src/index.js"
    click S "https://github.com/sujaykundu777/mern-docker/blob/master/server/src/config/mongodb.config.js"
    click S "https://github.com/sujaykundu777/mern-docker/blob/master/server/src/models/post.model.js"
    click S "https://github.com/sujaykundu777/mern-docker/blob/master/server/src/routes/post.routes.js"
    click S "https://github.com/sujaykundu777/mern-docker/blob/master/server/src/routes/index.js"
    click S "https://github.com/sujaykundu777/mern-docker/tree/master/server/webpack/"
    click DB "https://github.com/sujaykundu777/mern-docker/blob/master/docker-compose.yml"
    click DB "https://github.com/sujaykundu777/mern-docker/blob/master/docker-compose-dev.yml"
    click DB "https://github.com/sujaykundu777/mern-docker/blob/master/docker-compose-prod.yml"
    click DF "https://github.com/sujaykundu777/mern-docker/tree/master/Dockerfile"
    click ENVS "https://github.com/sujaykundu777/mern-docker/blob/master/.env"
    click ENVS "https://github.com/sujaykundu777/mern-docker/blob/master/server/.env"
    click ENVS "https://github.com/sujaykundu777/mern-docker/blob/master/.babelrc"
    click ENVS "https://github.com/sujaykundu777/mern-docker/blob/master/server/.babelrc"
    click ENVS "https://github.com/sujaykundu777/mern-docker/blob/master/client/package.json"
    click ENVS "https://github.com/sujaykundu777/mern-docker/blob/master/client/package-lock.json"
    click ENVS "https://github.com/sujaykundu777/mern-docker/blob/master/server/package.json"
    click ENVS "https://github.com/sujaykundu777/mern-docker/blob/master/server/package-lock.json"

    classDef container fill:#BBDEFB,stroke:#1E88E5,color:#0D47A1;
    classDef database fill:#C8E6C9,stroke:#388E3C,color:#1B5E20,shape:cylinder;
    classDef compose fill:#CFD8DC,stroke:#455A64,color:#263238;
    classDef client fill:#FFE0B2,stroke:#FB8C00,color:#E65100;
    classDef config fill:#E1BEE7,stroke:#8E24AA,color:#4A148C;
```
