Initial cloud project upload
This commit is contained in:
commit
c1131b7745
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
||||
BIN
Cloud_Notes_Platform_Documentation.docx
Normal file
BIN
Cloud_Notes_Platform_Documentation.docx
Normal file
Binary file not shown.
66
README.md
Normal file
66
README.md
Normal file
@ -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
|
||||
13
app/Dockerfile
Normal file
13
app/Dockerfile
Normal file
@ -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"]
|
||||
414
app/app.py
Normal file
414
app/app.py
Normal file
@ -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 = """
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Cloud Notes Platform</title>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background: linear-gradient(135deg, #0f172a, #1e293b);
|
||||
color: #e2e8f0;
|
||||
min-height: 100vh;
|
||||
padding: 40px 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.hero {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 20px;
|
||||
margin-bottom: 35px;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
font-size: 3rem;
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.hero p {
|
||||
color: #cbd5e1;
|
||||
max-width: 700px;
|
||||
line-height: 1.7;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
background: rgba(16, 185, 129, 0.15);
|
||||
border: 1px solid rgba(16, 185, 129, 0.4);
|
||||
color: #34d399;
|
||||
padding: 12px 20px;
|
||||
border-radius: 999px;
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 25px;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: rgba(15, 23, 42, 0.75);
|
||||
border: 1px solid rgba(255,255,255,0.08);
|
||||
backdrop-filter: blur(10px);
|
||||
border-radius: 22px;
|
||||
padding: 30px;
|
||||
box-shadow: 0 12px 30px rgba(0,0,0,0.3);
|
||||
}
|
||||
|
||||
.card h2 {
|
||||
color: white;
|
||||
margin-bottom: 20px;
|
||||
font-size: 1.4rem;
|
||||
}
|
||||
|
||||
textarea {
|
||||
width: 100%;
|
||||
min-height: 150px;
|
||||
border-radius: 16px;
|
||||
border: 1px solid rgba(255,255,255,0.08);
|
||||
background: #0f172a;
|
||||
color: white;
|
||||
padding: 16px;
|
||||
font-size: 1rem;
|
||||
resize: vertical;
|
||||
outline: none;
|
||||
transition: 0.2s ease;
|
||||
}
|
||||
|
||||
textarea:focus {
|
||||
border-color: #3b82f6;
|
||||
box-shadow: 0 0 0 4px rgba(59,130,246,0.2);
|
||||
}
|
||||
|
||||
button {
|
||||
margin-top: 18px;
|
||||
width: 100%;
|
||||
padding: 15px;
|
||||
border: none;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(135deg, #2563eb, #3b82f6);
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s ease, opacity 0.2s ease;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
transform: translateY(-2px);
|
||||
opacity: 0.95;
|
||||
}
|
||||
|
||||
.notes-container {
|
||||
max-height: 550px;
|
||||
overflow-y: auto;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
.note {
|
||||
background: rgba(255,255,255,0.04);
|
||||
border: 1px solid rgba(255,255,255,0.06);
|
||||
border-radius: 16px;
|
||||
padding: 18px;
|
||||
margin-bottom: 18px;
|
||||
transition: 0.2s ease;
|
||||
}
|
||||
|
||||
.note:hover {
|
||||
transform: translateY(-2px);
|
||||
border-color: rgba(59,130,246,0.35);
|
||||
}
|
||||
|
||||
.note-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
color: #94a3b8;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.note-text {
|
||||
color: #f8fafc;
|
||||
line-height: 1.7;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.stats {
|
||||
display: flex;
|
||||
gap: 18px;
|
||||
margin-top: 25px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.stat-box {
|
||||
flex: 1;
|
||||
min-width: 180px;
|
||||
background: rgba(255,255,255,0.04);
|
||||
border: 1px solid rgba(255,255,255,0.05);
|
||||
border-radius: 16px;
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
.stat-box h3 {
|
||||
color: #94a3b8;
|
||||
font-size: 0.95rem;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.stat-box p {
|
||||
font-size: 1.7rem;
|
||||
font-weight: 700;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.footer {
|
||||
text-align: center;
|
||||
margin-top: 40px;
|
||||
color: #94a3b8;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
|
||||
.grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.hero h1 {
|
||||
font-size: 2.2rem;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="hero">
|
||||
|
||||
<div>
|
||||
<h1>Cloud Notes Platform</h1>
|
||||
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="status-badge">
|
||||
Running Mode: {{ mode }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="grid">
|
||||
|
||||
<div class="card">
|
||||
|
||||
<h2>Create New Note</h2>
|
||||
|
||||
<form method="post">
|
||||
|
||||
<textarea
|
||||
id="text"
|
||||
name="text"
|
||||
placeholder="Write your note here..."
|
||||
required
|
||||
></textarea>
|
||||
|
||||
<button type="submit">
|
||||
Save Note
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="stats">
|
||||
|
||||
<div class="stat-box">
|
||||
<h3>Total Notes</h3>
|
||||
<p>{{ items|length }}</p>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<h3>Infrastructure</h3>
|
||||
<p>K8s</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<h2>Stored Notes</h2>
|
||||
|
||||
<div class="notes-container">
|
||||
|
||||
{% for item in items %}
|
||||
|
||||
<div class="note">
|
||||
|
||||
<div class="note-header">
|
||||
<span>Note #{{ item.id }}</span>
|
||||
<span>{{ item.created }}</span>
|
||||
</div>
|
||||
|
||||
<div class="note-text">
|
||||
{{ item.text }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
|
||||
<div class="note">
|
||||
|
||||
<div class="note-text">
|
||||
No notes stored yet.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
Cloud Technologies Project • Flask • Docker • Kubernetes • Persistent Storage
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
@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)
|
||||
2
app/requirements.txt
Normal file
2
app/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Flask
|
||||
psycopg2-binary
|
||||
50
aws-deploy.sh
Normal file
50
aws-deploy.sh
Normal file
@ -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 <<EOF > .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 "========================================"
|
||||
47
docker-compose.yml
Normal file
47
docker-compose.yml
Normal file
@ -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:
|
||||
14
nginx/nginx.conf
Normal file
14
nginx/nginx.conf
Normal file
@ -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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
17
prepare-app.sh
Normal file
17
prepare-app.sh
Normal file
@ -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"
|
||||
10
remove-app.sh
Normal file
10
remove-app.sh
Normal file
@ -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."
|
||||
BIN
~$oud_Notes_Platform_Documentation.docx
Normal file
BIN
~$oud_Notes_Platform_Documentation.docx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user