# iam-veeramalla/mern-docker-compose architecture

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

- Interactive diagram: https://gitdiagram.com/iam-veeramalla/mern-docker-compose
- Repository: https://github.com/iam-veeramalla/mern-docker-compose

## Overview

##### Project type and purpose
- This is a full-stack MERN (MongoDB, Express, React, Node.js) application packaged and orchestrated via Docker.
- Purpose: a simple records-management UI (React/Vite/Tailwind) communicating with an Express/Node REST API, which in turn reads/writes to MongoDB.

##### File structure
- Top level:
- docker-compose.yaml – defines a three-container setup (frontend, backend, mongodb) on a Docker network named “demo.”
- mern/frontend – React app scaffolded with Vite, styled with Tailwind, plus Cypress end-to-end tests.
- mern/backend – Express server with routes/record.js, MongoDB connection code (db/connection.js), and its own Dockerfile.
- Notice MVC-style breakdown in backend (server.js loads routes; routes call DB connection).
- Frontend includes component folder (Navbar, Record, RecordList), assets, index.html, and Vite config.

##### README for additional insights
- Describes a three-container workflow: build and run frontend & backend images, and a standard MongoDB image.
- Ports: frontend on 5173, backend on 5050, MongoDB on 27017.
- Uses a dedicated Docker network so containers can refer to each other by name.
- Offers an alternative “docker compose up -d” command to launch all services together.

##### Elements
- “HTTP GET/POST” from Browser → Frontend
- “REST API” from Frontend → Backend
- “MongoDB Driver” from Backend → MongoDB
- (Optional) “Cypress E2E Tests” from Test Runner → Frontend

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Global entities
    Browser["User's Browser"]:::browser
    Cypress["Cypress E2E Test Runner"]:::test

    %% Docker Compose Network
    subgraph "Docker Compose (demo network)" 
        direction TB
        Compose["docker-compose.yaml\n(Docker Compose)"]:::compose
        Frontend["Frontend Container\nReact/Vite (5173)"]:::frontend
        Backend["Backend Container\nExpress/Node (5050)"]:::backend
        MongoDB["MongoDB Container\n(27017)"]:::database
    end

    %% Connections
    Browser -->|"HTTP GET/POST"| Frontend
    Frontend -->|"REST API"| Backend
    Backend -->|"MongoDB Driver"| MongoDB
    Cypress -.->|"Cypress E2E Tests"| Frontend

    %% Click Events
    click Compose "https://github.com/iam-veeramalla/mern-docker-compose/blob/compose/docker-compose.yaml"
    click Frontend "https://github.com/iam-veeramalla/mern-docker-compose/tree/compose/mern/frontend"
    click Backend "https://github.com/iam-veeramalla/mern-docker-compose/tree/compose/mern/backend"
    click Cypress "https://github.com/iam-veeramalla/mern-docker-compose/blob/compose/mern/frontend/cypress.json"

    %% Styles
    classDef browser fill:#E0F7FA,stroke:#006064,stroke-width:2px
    classDef frontend fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px
    classDef backend fill:#E3F2FD,stroke:#1565C0,stroke-width:2px
    classDef database fill:#FFF3E0,stroke:#EF6C00,stroke-width:2px
    classDef compose fill:#F3E5F5,stroke:#6A1B9A,stroke-width:2px
    classDef test fill:#ECEFF1,stroke:#455A64,stroke-width:2px,stroke-dasharray: 5 5
```
