commit c1131b77458bd6de78d78ff86e013d0368442c6c Author: Nihal Ahmed Date: Tue May 19 22:47:34 2026 +0000 Initial cloud project upload diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2eea525 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env \ No newline at end of file diff --git a/Cloud_Notes_Platform_Documentation.docx b/Cloud_Notes_Platform_Documentation.docx new file mode 100644 index 0000000..df3ef0a Binary files /dev/null and b/Cloud_Notes_Platform_Documentation.docx differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..c54cb65 --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +# Cloud Notes Platform – Cloud-Native Notes Management Application + +## Author + +Muhilan + +--- + +# Overview + +Cloud Notes Platform is a modern cloud-native notes management web application developed using containerized deployment architecture and public cloud infrastructure. + +The application allows users to: +- create notes +- store notes persistently +- manage lightweight note workflows +- access the application securely over HTTPS + +The system is designed using a multi-component architecture consisting of: +- Flask backend application +- PostgreSQL database +- NGINX reverse proxy + +The application is deployed on an AWS EC2 virtual machine using Docker Compose orchestration and HTTPS reverse proxy configuration. + +The project demonstrates practical cloud deployment concepts including: +- containerization +- reverse proxy configuration +- persistent storage +- automated deployment +- cloud-hosted infrastructure +- HTTPS certificate management +- environment-based configuration + +--- + +# Features + +- Create and manage notes +- Persistent PostgreSQL database storage +- Responsive modern web interface +- Dockerized application services +- AWS cloud deployment +- HTTPS secure communication +- DuckDNS public domain +- Reverse proxy architecture +- Automated deployment scripts +- Environment variable configuration +- Automatic container restart policies +- Database backup support +- Access log monitoring + +--- + +# Application Architecture + +## High-Level Architecture + +```text +User Browser + ↓ +NGINX Reverse Proxy (HTTPS) + ↓ +Flask Backend Container + ↓ +PostgreSQL Database Container \ No newline at end of file diff --git a/app/Dockerfile b/app/Dockerfile new file mode 100644 index 0000000..013cd75 --- /dev/null +++ b/app/Dockerfile @@ -0,0 +1,13 @@ +FROM python:3.11-slim + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE 5000 + +CMD ["python", "app.py"] \ No newline at end of file diff --git a/app/app.py b/app/app.py new file mode 100644 index 0000000..c4f6654 --- /dev/null +++ b/app/app.py @@ -0,0 +1,414 @@ +from flask import Flask, request, redirect, url_for, render_template_string +import os +import psycopg2 + + + +app = Flask(__name__) + +DB_HOST = os.getenv("DB_HOST") +DB_NAME = os.getenv("DB_NAME") +DB_USER = os.getenv("DB_USER") +DB_PASSWORD = os.getenv("DB_PASSWORD") + +def get_db(): + conn = psycopg2.connect( + host=DB_HOST, + database=DB_NAME, + user=DB_USER, + password=DB_PASSWORD + ) + + return conn + +def init_db(): + conn = get_db() + cur = conn.cursor() + + cur.execute(""" + CREATE TABLE IF NOT EXISTS items ( + id SERIAL PRIMARY KEY, + text TEXT NOT NULL, + created TIMESTAMP DEFAULT CURRENT_TIMESTAMP + ) + """) + + conn.commit() + + cur.close() + conn.close() +init_db() + +TEMPLATE = """ + + + + + + + Cloud Notes Platform + + + + + + + + +
+ +
+ +
+

Cloud Notes Platform

+ +

+ A modern cloud-native Flask application deployed with Kubernetes, + Docker containers, persistent storage, and automated deployment workflows. + This platform demonstrates scalable cloud infrastructure concepts and + production-ready deployment architecture. +

+
+ +
+ Running Mode: {{ mode }} +
+ +
+ +
+ +
+ +

Create New Note

+ +
+ + + + + +
+ +
+ +
+

Total Notes

+

{{ items|length }}

+
+ +
+

Infrastructure

+

K8s

+
+ +
+ +
+ +
+ +

Stored Notes

+ +
+ + {% for item in items %} + +
+ +
+ Note #{{ item.id }} + {{ item.created }} +
+ +
+ {{ item.text }} +
+ +
+ + {% else %} + +
+ +
+ No notes stored yet. +
+ +
+ + {% endfor %} + +
+ +
+ +
+ + + +
+ + + +""" + +@app.route("/", methods=["GET", "POST"]) +def index(): + + if request.method == "POST": + text = request.form.get("text", "").strip() + + if text: + + conn = get_db() + cur = conn.cursor() + + cur.execute( + "INSERT INTO items (text) VALUES (%s)", + (text,) + ) + + conn.commit() + + cur.close() + conn.close() + + return redirect(url_for("index")) + + conn = get_db() + cur = conn.cursor() + + cur.execute( + "SELECT id, text, created FROM items ORDER BY id DESC" + ) + + rows = cur.fetchall() + + items = [] + + for row in rows: + items.append({ + "id": row[0], + "text": row[1], + "created": row[2] + }) + + cur.close() + conn.close() + + mode = "Docker Compose + PostgreSQL" + + return render_template_string( + TEMPLATE, + items=items, + mode=mode + ) + + +if __name__ == "__main__": + app.run(host="0.0.0.0", port=5000) \ No newline at end of file diff --git a/app/requirements.txt b/app/requirements.txt new file mode 100644 index 0000000..88c17be --- /dev/null +++ b/app/requirements.txt @@ -0,0 +1,2 @@ +Flask +psycopg2-binary \ No newline at end of file diff --git a/aws-deploy.sh b/aws-deploy.sh new file mode 100644 index 0000000..43d45b5 --- /dev/null +++ b/aws-deploy.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +echo "========================================" +echo "Cloud Notes Platform AWS Deployment" +echo "========================================" + +echo "" +echo "Updating Ubuntu packages..." +sudo apt update -y + +echo "" +echo "Installing Docker..." +sudo apt install docker.io docker-compose-v2 git nginx certbot python3-certbot-nginx -y + +echo "" +echo "Starting Docker service..." +sudo systemctl enable docker +sudo systemctl start docker + +echo "" +echo "Adding ubuntu user to Docker group..." +sudo usermod -aG docker ubuntu + +echo "" +echo "Creating environment configuration..." + +cat < .env +POSTGRES_PASSWORD=StrongPassword123 +EOF + +echo "" +echo "Building and starting containers..." +docker compose up -d --build + +echo "" +echo "Waiting for services..." +sleep 10 + +echo "" +echo "Currently running containers:" +docker ps + +echo "" +echo "Deployment completed successfully." + +echo "" +echo "Application URL:" +echo "https://notecloud.duckdns.org" + +echo "========================================" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1cc2f76 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,47 @@ +version: '3.8' + +services: + + backend: + build: ./app + container_name: flask-backend + restart: always + + environment: + DB_HOST: postgres + DB_NAME: mydb + DB_USER: admin + DB_PASSWORD: ${POSTGRES_PASSWORD} + + depends_on: + - postgres + + postgres: + image: postgres:15 + container_name: postgres-db + restart: always + + environment: + POSTGRES_DB: mydb + POSTGRES_USER: admin + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + + volumes: + - postgres_data:/var/lib/postgresql/data + + nginx: + image: nginx:latest + container_name: nginx-proxy + restart: always + + ports: + - "80:80" + + volumes: + - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf + + depends_on: + - backend + +volumes: + postgres_data: \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..c399d0b --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,14 @@ +server { + + listen 80; + + location / { + + proxy_pass http://backend:5000; + + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + + } + +} \ No newline at end of file diff --git a/prepare-app.sh b/prepare-app.sh new file mode 100644 index 0000000..d5476d8 --- /dev/null +++ b/prepare-app.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Starting Cloud Notes Platform deployment..." + +echo "Building and starting Docker containers..." +docker compose up -d --build + +echo "Waiting for containers to initialize..." +sleep 10 + +echo "Running containers:" +docker ps + +echo "Deployment completed successfully." + +echo "Application URL:" +echo "https://notecloud.duckdns.org" \ No newline at end of file diff --git a/remove-app.sh b/remove-app.sh new file mode 100644 index 0000000..347deb1 --- /dev/null +++ b/remove-app.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Stopping Cloud Notes Platform..." + +docker compose down + +echo "Removing unused Docker resources..." +docker system prune -f + +echo "Application removed successfully." \ No newline at end of file diff --git a/~$oud_Notes_Platform_Documentation.docx b/~$oud_Notes_Platform_Documentation.docx new file mode 100644 index 0000000..b5f34d0 Binary files /dev/null and b/~$oud_Notes_Platform_Documentation.docx differ