# yatharth0045/solar-system architecture

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

- Interactive diagram: https://gitdiagram.com/yatharth0045/solar-system
- Repository: https://github.com/yatharth0045/solar-system

## Overview

##### Project type and purpose
- This is a small full-stack web application (“Solar System NodeJS Application”) that serves static HTML/CSS/JS to display solar system data and uses a MongoDB database to store/retrieve planet and related information. It is packaged in Docker and deployable to Kubernetes, with GitHub Actions handling CI/CD (unit tests, container build & push).

##### File structure
- Top-level files:
- app.js (main Express/NodeJS server entry point)
- app-controller.js (HTTP request handlers)
- index.html + images/ (static assets/frontend)
- app-test.js (unit tests)
- package.json / package-lock.json (dependency manifest)
- Dockerfile / .dockerignore (containerization)
- .github/workflows/workflow-1.yml (CI jobs: test & container push)
- Directories:
- kubernetes/ (dev & prod manifests: Deployment, Service, Ingress)
- solar-dump/ (sample MongoDB dump used to seed or restore the database)

##### Extract additional insights from README
- Backend stack: NodeJS + Express (assumed) + MongoDB
- Database: external MongoDB Atlas or local Docker container seeded from solar-dump
- CI/CD: GitHub Actions workflows run tests, build & push container to GHCR
- Deployment targets: Docker run locally, Kubernetes via minikube & ngrok, production Kubernetes

1) Client / Browser – the user interface serving index.html & assets
2) NodeJS Application – Express server (app.js + controllers + routes)
3) MongoDB Database – either local Docker container or cloud-hosted Atlas cluster
4) CI/CD Pipeline – GitHub Actions (test job, build & push container to GHCR)
5) Container Registry – GitHub Container Registry (GHCR)
6) Container Runtime – Docker Engine on host or Kubernetes Cluster
7) Kubernetes Cluster – dev & prod namespaces running Deployment, Service, Ingress
8) External Tools – ngrok for exposing minikube, kubectl for orchestration

- Client → HTTP GET/POST → NodeJS App
- NodeJS App → MongoDB Driver → MongoDB Database
- GitHub Actions → build/push → GHCR
- Kubernetes (Ingress) → routes external traffic → Service → Deployment Pods (NodeJS App)
- Docker Engine → runs container in local dev / CI test
- ngrok → tunnels internet traffic → Kubernetes Ingress → NodeJS App

c. Architectural patterns & principles:
- MVC-style separation (controllers in app-controller.js)
- 12-factor app principles (config via environment variables: MONGO_URI, MONGO_USERNAME, MONGO_PASSWORD)
- Immutable containers & declarative infrastructure (Dockerfile + k8s manifests)
- CI/CD automation (GitHub Actions)

d. Key technologies & libraries:
- Node.js & Express.js
- MongoDB + mongosh / mongodump CLI tools
- Docker & Dockerfile
- Kubernetes (Deployment, Service, Ingress manifests)
- GitHub Actions & GHCR
- ngrok (tunneling)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline" 
        GH_REPO["GitHub Repo"]:::cicd
        ACTIONS["GitHub Actions\n(Test → Build & Push)"]:::cicd
        GHCR["GitHub Container Registry"]:::cicd
        GH_REPO -->|"triggers"| ACTIONS
        ACTIONS -->|"docker build & push"| GHCR
    end

    %% Client Layer
    subgraph "Client / Browser" 
        CLIENT["index.html + images"]:::frontend
    end

    %% Server Layer
    subgraph "NodeJS Application" 
        EXPRESS["Express HTTP Server\n(app.js)"]:::backend
        CONTROLLERS["Controllers\n(app-controller.js)"]:::backend
        PACKAGE["Dependencies\n(package.json & package-lock.json)"]:::backend
        TESTS["Unit Tests\n(app-test.js)"]:::cicd
        EXPRESS -->|uses| CONTROLLERS
        EXPRESS -->|env vars: MONGO_URI etc| PACKAGE
        TESTS -->|validates| EXPRESS
    end

    %% Data Layer
    subgraph "MongoDB Database" 
        MONGO["MongoDB Instance\n(Container or Atlas)"]:::database
        SEED["Seed Data\n(solar-dump/)"]:::database
        SEED -->|mongorestore| MONGO
    end

    %% Container Runtime & Orchestration
    subgraph "Container Runtime & Kubernetes" 
        DOCKER["Docker Engine\n(local & CI)"]:::container
        K8S_ING["Kubernetes Ingress"]:::infra
        K8S_SVC["Service"]:::infra
        K8S_DEP["Deployment\n(Deployment.yaml)"]:::infra
        DOCKER -->|"runs container"| EXPRESS
        GHCR -->|"pull image"| DOCKER
        GHCR -->|"pull image"| K8S_DEP
        K8S_DEP -->|"runs pods"| EXPRESS
        K8S_SVC -->|"routes to pods"| K8S_DEP
        K8S_ING -->|"external HTTP traffic"| K8S_SVC
    end

    %% External Tools
    subgraph "External Tools / Dev & Prod" 
        NGROK["ngrok"]:::infra
        KUBECTL["kubectl"]:::infra
        NGROK -->|"tunnels to"| K8S_ING
        KUBECTL -->|"manages"| K8S_DEP
    end

    %% Client to Server and Server to DB
    CLIENT -->|"HTTP GET/POST"| EXPRESS
    EXPRESS -->|"MongoDB Driver\nTCP 27017"| MONGO

    %% Kubernetes Manifests Reference
    subgraph "Kubernetes Manifests" 
        DEV_DEP["dev/deployment.yaml"]:::infra
        DEV_SVC["dev/service.yaml"]:::infra
        DEV_ING["dev/ingress.yaml"]:::infra
        PROD_DEP["prod/deployment.yaml"]:::infra
        PROD_SVC["prod/service.yaml"]:::infra
        PROD_ING["prod/ingress.yaml"]:::infra
    end
    DEV_DEP --> DEV_SVC --> DEV_ING
    PROD_DEP --> PROD_SVC --> PROD_ING

    %% Legend & Config
    subgraph "Configuration & Docs"
        README["README.md"]:::docs
        GITIGNORE[".gitignore"]:::docs
    end

    %% Click Events
    click CLIENT "https://github.com/yatharth0045/solar-system/blob/main/index.html"
    click CLIENT "https://github.com/yatharth0045/solar-system/tree/main/images/"
    click EXPRESS "https://github.com/yatharth0045/solar-system/blob/main/app.js"
    click CONTROLLERS "https://github.com/yatharth0045/solar-system/blob/main/app-controller.js"
    click PACKAGE "https://github.com/yatharth0045/solar-system/blob/main/package.json"
    click PACKAGE "https://github.com/yatharth0045/solar-system/blob/main/package-lock.json"
    click TESTS "https://github.com/yatharth0045/solar-system/blob/main/app-test.js"
    click SEED "https://github.com/yatharth0045/solar-system/tree/main/solar-dump/"
    click DOCKER "https://github.com/yatharth0045/solar-system/tree/main/Dockerfile"
    click DOCKER "https://github.com/yatharth0045/solar-system/blob/main/.dockerignore"
    click ACTIONS "https://github.com/yatharth0045/solar-system/blob/main/.github/workflows/workflow-1.yml"
    click DEV_DEP "https://github.com/yatharth0045/solar-system/blob/main/kubernetes/development/deployment.yaml"
    click DEV_SVC "https://github.com/yatharth0045/solar-system/blob/main/kubernetes/development/service.yaml"
    click DEV_ING "https://github.com/yatharth0045/solar-system/blob/main/kubernetes/development/ingress.yaml"
    click PROD_DEP "https://github.com/yatharth0045/solar-system/blob/main/kubernetes/production/deployment.yaml"
    click PROD_SVC "https://github.com/yatharth0045/solar-system/blob/main/kubernetes/production/service.yaml"
    click PROD_ING "https://github.com/yatharth0045/solar-system/blob/main/kubernetes/production/ingress.yaml"
    click README "https://github.com/yatharth0045/solar-system/blob/main/README.md"
    click GITIGNORE "https://github.com/yatharth0045/solar-system/blob/main/.gitignore"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085;
    classDef backend fill:#e2e3e5,stroke:#6c757d,color:#383d41;
    classDef database fill:#d4edda,stroke:#155724,color:#155724;
    classDef cicd fill:#fff3cd,stroke:#856404,color:#856404;
    classDef container fill:#f5c6cb,stroke:#721c24,color:#721c24;
    classDef infra fill:#e2e3e5,stroke:#6f42c1,color:#6f42c1;
    classDef docs fill:#d1ecf1,stroke:#0c5460,color:#0c5460;
```
