Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 68 additions & 122 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,125 +1,71 @@
# DevOps Assignment

This project consists of a FastAPI backend and a Next.js frontend that communicates with the backend.

## Project Structure

```
.
├── backend/ # FastAPI backend
│ ├── app/
│ │ └── main.py # Main FastAPI application
│ └── requirements.txt # Python dependencies
└── frontend/ # Next.js frontend
├── pages/
│ └── index.js # Main page
├── public/ # Static files
└── package.json # Node.js dependencies
```

## Prerequisites

- Python 3.8+
- Node.js 16+
- npm or yarn

## Backend Setup

1. Navigate to the backend directory:
```bash
cd backend
```

2. Create a virtual environment (recommended):
```bash
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
```

3. Install dependencies:
```bash
pip install -r requirements.txt
```

4. Run the FastAPI server:
```bash
uvicorn app.main:app --reload --port 8000
```

The backend will be available at `http://localhost:8000`

## Frontend Setup

1. Navigate to the frontend directory:
```bash
cd frontend
```

2. Install dependencies:
```bash
npm install
# or
yarn
```

3. Configure the backend URL (if different from default):
- Open `.env.local`
- Update `NEXT_PUBLIC_API_URL` with your backend URL
- Example: `NEXT_PUBLIC_API_URL=https://your-backend-url.com`

4. Run the development server:
```bash
npm run dev
# or
yarn dev
```

The frontend will be available at `http://localhost:3000`

## Changing the Backend URL

To change the backend URL that the frontend connects to:

1. Open the `.env.local` file in the frontend directory
2. Update the `NEXT_PUBLIC_API_URL` variable with your new backend URL
3. Save the file
4. Restart the Next.js development server for changes to take effect

Example:
```
NEXT_PUBLIC_API_URL=https://your-new-backend-url.com
```

## For deployment:
```bash
npm run build
# or
yarn build
```

AND

```bash
npm run start
# or
yarn start
```

The frontend will be available at `http://localhost:3000`

## Testing the Integration

1. Ensure both backend and frontend servers are running
2. Open the frontend in your browser (default: http://localhost:3000)
3. If everything is working correctly, you should see:
- A status message indicating the backend is connected
- The message from the backend: "You've successfully integrated the backend!"
- The current backend URL being used
Multi-Cloud Infrastructure Design – DevOps Assignment

## API Endpoints
Overview

- `GET /api/health`: Health check endpoint
- Returns: `{"status": "healthy", "message": "Backend is running successfully"}`
This project demonstrates a structured multi-cloud infrastructure design across:
• Amazon Web Services (AWS)
• Google Cloud Platform (GCP)

The focus of this assignment is infrastructure thinking, scalability planning, and environment separation rather than application complexity.


Cloud & Region Selection

AWS
Region: ap-south-1 (Mumbai)
Reason: Low latency and cost efficiency.

GCP
Region: asia-south1
Reason: Geographic alignment and service availability.


Environment Strategy

Each cloud contains:
• Dev – Single small virtual machine
• Staging – Medium-sized virtual machine
• Production – Multiple instances with auto-scaling concept

This ensures environment isolation and safe promotion of changes.


Infrastructure as Code

Terraform is used to define infrastructure resources.

State Management Design:
• AWS: S3 backend with DynamoDB locking (design intention)
• GCP: Cloud Storage backend (design intention)
• Separate configuration per environment


Scalability & Availability

Production environments are designed to scale horizontally to handle traffic spikes.

Instance failure handling:
• Auto-scaling replaces failed instances.
• Load balancer routes traffic only to healthy instances.


Future Improvements
• Multi-region deployment
• CI/CD automation pipeline
• Kubernetes-based container orchestration
• Web Application Firewall integration

11. What Was Intentionally Not Implemented
• Kubernetes (overkill for this application)
• Multi-region failover
• CI/CD automation pipeline
• Web Application Firewall

Reason:
Focused on foundational infrastructure clarity within assignment constraints.

- `GET /api/message`: Get the integration message
- Returns: `{"message": "You've successfully integrated the backend!"}`
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
provider "google" {
region = "asia-south1"
}

resource "google_compute_instance" "dev_vm" {
name = "dev-vm"
machine_type = "e2-micro"
zone = "asia-south1-a"

boot_disk {
initialize_params {
image = "debian-cloud/debian-11"
}
}

network_interface {
network = "default"
access_config {}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
provider "aws" {
region = "ap-south-1"
}

resource "aws_launch_template" "prod_template" {
name_prefix = "prod-template"
image_id = "ami-12345678"
instance_type = "t2.micro"
}

resource "aws_autoscaling_group" "prod_asg" {
desired_capacity = 2
max_size = 4
min_size = 2
vpc_zone_identifier = ["subnet-123456"]

launch_template {
id = aws_launch_template.prod_template.id
version = "$Latest"
}

tag {
key = "Environment"
value = "prod"
propagate_at_launch = true
}
}
13 changes: 13 additions & 0 deletions infrastructure/aws/dev/infrastructure/aws/staging/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
provider "aws" {
region = "ap-south-1"
}

resource "aws_instance" "staging_instance" {
ami = "ami-12345678"
instance_type = "t2.small"

tags = {
Name = "staging-instance"
Environment = "staging"
}
}
13 changes: 13 additions & 0 deletions infrastructure/aws/dev/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
provider "aws" {
region = "ap-south-1"
}

resource "aws_instance" "dev_instance" {
ami = "ami-12345678"
instance_type = "t2.micro"

tags = {
Name = "dev-instance"
Environment = "dev"
}
}