Skip to content

Suraj-kumar00/DevOps-URL2QR

Repository files navigation

DevOps-URL2QR Project

This project focuses on creating a streamlined solution for generating QR codes from user-provided URLs. It features a user-friendly Next.js front end for URL input, a robust FastAPI backend for QR code generation, and a secure storage system for saving the generated codes.

  • Front-End Container: User-facing website for URL input.
  • API Container: Backend service for QR code generation.
  • Storage Container: Secure storage for generated QR codes.

Cloud & DevOps Practices

  • Docker: Used for containerizing the front-end (Next.js) and API (FastAPI) to ensure consistent deployment across environments.

  • GitHub Actions: Implements CI/CD pipelines to automate the deployment of containers when source code changes occur.

  • Terraform: Manages and provisions cloud infrastructure, specifically creating a Kubernetes cluster using Infrastructure as Code (IaC).

  • Kubernetes: Orchestrates the deployment and management of containerized applications, ensuring scalability and high availability.

    • KIND(Kubernetes in Docker) Deploying application to test the functionality localy using Kind Cluster.
    • AWS EKS: Deploying the application on prodcution using AWS EKS cluster.
  • AWS S3: Provides secure storage for generated QR codes, allowing for persistent data storage and easy accessibility.

  • Prometheus: Monitors container and system metrics, offering real-time insights for performance and operational monitoring.

  • Grafana: Visualizes metrics collected from Prometheus and other sources, enhancing observability and aiding in performance monitoring and troubleshooting.

Project Workflow

DevOps URL2QR Project Workflow

End to End CI/CD Pipeline

CICD Pipeline

Quick Start with Docker

This is the fastest way to get the application running on your local machine.

Prerequisites

  • Docker Desktop / Docker Daemon installed on your machine
  • Git (to clone the repository)

Steps to Run with Docker

  1. Clone the repository

    git clone <repository-url>
    cd DevOps-URL2QR
  2. First-time setup

    docker compose up --build

    This command will:

  3. Subsequent runs

    docker compose up

    Use this command when you haven't made any changes to the Dockerfile or dependencies.

  4. Stop the application

    docker compose down

    This will stop and remove all containers, but preserve your images.

Additional Docker Commands

  • To view logs of a specific service:

    docker compose logs frontend  # For frontend logs
    docker compose logs backend   # For backend logs
  • To rebuild a specific service:

    docker compose up --build frontend  # Rebuild frontend only
    docker compose up --build backend   # Rebuild backend only
  • To remove all containers and images (clean slate):

    docker compose down --rmi all

Troubleshooting

  • If you see connection errors, ensure all services are up:

    docker compose ps
  • If the frontend can't connect to the backend, check the logs:

    docker compose logs backend

Running the project locally

Run the Backend

The Backend code exists in the api directory. You can run the API server locally:

  1. Clone this repo
git clone <repository-url>
  1. Make sure you are in the api directory
cd api
  1. Create a virtualenv by typing in the following command:
python -m venv .venv
  1. Install the required packages:
pip install -r requirements.txt
  1. Create a .env file, and add your AWS Access and Secret key, check .env.example just run the below command
cp .env.example .env
  1. Also, change the BUCKET_NAME to your S3 bucket name in main.py
  2. Run the API server:
uvicorn main:app --reload
  1. Your API Server should be running on port http://localhost:8000

Run the Front-end

The front-end code exits in the front-end-nextjs directory. You can run the front-end server locally:

  1. Make sure you are in the front-end-nextjs directory
cd front-end-nextjs
  1. Install the dependencies:
npm install
  1. Run the NextJS Server:
npm run dev
  1. Your Front-end Server should be running on http://localhost:3000

This project is inpired by

Rishab Kumar

Star 🌟 the project

If you like this project so far don't forget to star 🤩 the project for future reference.

License

MIT