Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Developed GitHub Actions Workflow for a NodeJS Application

Notifications You must be signed in to change notification settings

shashi2504/nodejs-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

89 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌌 Solar System Explorer

A full-stack web application that provides an interactive exploration of our solar system's planets. Built with Node.js, Express, MongoDB, and deployed using Kubernetes with a comprehensive CI/CD pipeline.

Node.js MongoDB Docker Kubernetes GitHub Actions

πŸ“Έ Project Outcome

Solar System Explorer - Main View

Solar System Explorer - Planet Detail View

πŸš€ Features

  • Interactive Planet Explorer: Browse through 8 planets of our solar system with detailed information
  • Dynamic Data Loading: Real-time planet data fetched from MongoDB database
  • Responsive Design: Beautiful UI with animated solar system background
  • Health Monitoring: Built-in health check endpoints for production monitoring
  • Container-Ready: Fully containerized application with Docker support
  • Cloud-Native: Kubernetes-ready with separate development and production configurations

πŸ› οΈ Tech Stack

Backend

  • Runtime: Node.js (v18, v20)
  • Framework: Express.js
  • Database: MongoDB with Mongoose ODM
  • Testing: Mocha, Chai, NYC for code coverage

Frontend

  • HTML5/CSS3: Responsive design with custom animations
  • JavaScript: Vanilla JS for client-side interactions
  • Styling: Custom CSS with gradient backgrounds and animations

DevOps

  • Containerization: Docker
  • Orchestration: Kubernetes
  • CI/CD: GitHub Actions
  • Cloud Storage: AWS S3 for test reports
  • Monitoring: Slack notifications

πŸ“‹ Prerequisites

  • Node.js (v18 or v20)
  • MongoDB (local or cloud instance)
  • Docker (for containerization)
  • Kubernetes cluster (for deployment)

πŸ”§ Installation

Local Development

  1. Clone the repository

    git clone <repository-url>
    cd solar-system
    
    
  2. Install dependencies

    npm install
    
  3. Set up environment variables Create a `.env` file in the root directory:

    MONGO_URI=mongodb://localhost:27017/superData
    MONGO_USERNAME=your-username
    MONGO_PASSWORD=your-password
    NODE_ENV=development
    
    
  4. Start the application

    npm start

    The application will be available at `http://localhost:3000\`

Docker Setup

  1. Build the Docker image
    docker build -t solar-system:latest .
    
  2. Run the container
    docker run -d \
      -p 3000:3000 \
      -e MONGO_URI=your-mongo-uri \
      -e MONGO_USERNAME=your-username \
      -e MONGO_PASSWORD=your-password \
      solar-system:latest
    
    

πŸ§ͺ Testing

Run Unit Tests

npm test

Run Tests with Coverage

npm run coverage

Test Endpoints

  • Health Check: `GET /live` - Returns `{"status": "live"}`
  • Readiness Check: `GET /ready` - Returns `{"status": "ready"}`
  • OS Info: `GET /os` - Returns pod hostname and environment
  • Planet Data: `POST /planet` - Returns planet information

πŸ“ Project Structure

solar-system/
β”œβ”€β”€ app.js                  # Express application setup
β”œβ”€β”€ app-controller.js       # Client-side JavaScript
β”œβ”€β”€ app.test.js            # Test suite
β”œβ”€β”€ index.html             # Frontend interface
β”œβ”€β”€ package.json           # Dependencies and scripts
β”œβ”€β”€ Dockerfile             # Container configuration
β”œβ”€β”€ .github/
β”‚   β”œβ”€β”€ workflows/
β”‚   β”‚   β”œβ”€β”€ solar-system.yml      # Main CI/CD pipeline
β”‚   β”‚   └── reuse-deployments.yml # Reusable deployment workflow
β”‚   └── custom-actions/           # Custom GitHub Actions
β”œβ”€β”€ kubernetes/
β”‚   β”œβ”€β”€ development/       # Dev environment K8s manifests
β”‚   └── production/        # Prod environment K8s manifests
└── images/               # Static assets

πŸš€ CI/CD Pipeline

The project includes a comprehensive GitHub Actions pipeline that:

  1. Unit Testing: Runs tests on Node.js v18 and v20
  2. Code Coverage: Generates coverage reports with NYC/Istanbul
  3. Containerization: Builds and pushes Docker images to Docker Hub and GHCR
  4. Artifact Storage: Uploads test reports to AWS S3
  5. Deployment: Automated deployment to Kubernetes (dev/prod)
  6. Integration Testing: Validates deployment health
  7. Notifications: Sends status updates to Slack

Pipeline Triggers

  • Main branch: Deploys to production
  • Feature branches: Deploys to development

🌐 API Documentation

Get Planet Information

POST /planet
Content-Type: application/json

{
  "id": 3
}

Response:

{
  "id": 3,
  "name": "Earth",
  "description": "Earth is the third planet from the Sun...",
  "image": "https://example.com/earth.jpg",
  "velocity": "29.78 km/s",
  "distance": "149.6 million km"
}

🐳 Kubernetes Deployment

Deploy to Development

kubectl apply -f kubernetes/development/

Deploy to Production

kubectl apply -f kubernetes/production/

Required Secrets

kubectl create secret generic mongo-db-creds \
  --from-literal=MONGO_URI=your-uri \
  --from-literal=MONGO_USERNAME=your-username \
  --from-literal=MONGO_PASSWORD=your-password

πŸ”’ Security

  • MongoDB credentials stored as Kubernetes secrets
  • Environment-specific configurations
  • Health check endpoints for monitoring
  • Secure container registry (GHCR)

πŸ‘₯ Contact

For questions or support, please open an issue in the GitHub repository.


Note: Make sure to populate your MongoDB with planet data before running the application. The application expects planets with IDs 1-8 in the database.

About

Developed GitHub Actions Workflow for a NodeJS Application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages