๐Ÿฝ๏ธ What's Cooking Now?

A time-based recipe web app that suggests the perfect recipe based on your current time of day โ€” built with Flask, HTML, CSS & JS, containerized with Docker, and deployed on Amazon Lightsail via GitHub Actions CI/CD.

image image image image image image

Python Flask Docker AWS Lightsail GitHub Actions


๐Ÿ“ธ Preview

Time of Day Recipe Suggested
๐ŸŒ… 6AM โ€“ 11AM Avocado Toast with Poached Eggs
โ˜€๏ธ 11AM โ€“ 1PM Fluffy Banana Pancakes
๐ŸŒž 1PM โ€“ 4PM Grilled Chicken Caesar Wrap
๐ŸŒ† 4PM โ€“ 7PM Honey Garlic Popcorn
๐ŸŒ™ 7PM โ€“ 10PM Creamy Tuscan Garlic Pasta
๐ŸŒƒ 10PM โ€“ 6AM Midnight Nutella Mug Cake

๐Ÿ“ Project Structure

whats-cooking-now/
โ”œโ”€โ”€ app.py                     # Flask backend โ€” API routes & recipe logic
โ”œโ”€โ”€ Dockerfile                 # Docker container configuration
โ”œโ”€โ”€ requirements.txt           # Python dependencies
โ”œโ”€โ”€ static/
โ”‚   โ”œโ”€โ”€ index.html             # Frontend HTML
โ”‚   โ”œโ”€โ”€ style.css              # Styling & animations
โ”‚   โ””โ”€โ”€ script.js              # Frontend logic & API calls
โ””โ”€โ”€ .github/
    โ””โ”€โ”€ workflows/
        โ””โ”€โ”€ deploy.yml          # GitHub Actions CI/CD pipeline

๐Ÿ› ๏ธ Tech Stack

Technology Purpose
Python 3.11 Backend language
Flask 3.0.3 Web framework & REST API
HTML5 Frontend structure
CSS3 Styling, animations, responsive design
JavaScript (Vanilla) Live clock, API calls, countdown timer
Docker Containerization
Amazon Lightsail Cloud hosting (container service)
GitHub Actions CI/CD pipeline โ€” auto deploy on push
AWS IAM Secure access management for deployment

๐Ÿš€ Quick Start โ€” Run Locally

Prerequisites

  • Python 3.11+
  • pip
  • Docker (optional, for container testing)
  • Git

Option 1 โ€” Run with Python directly

# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/whats-cooking-now.git
cd whats-cooking-now

# 2. Install dependencies
pip install flask

# 3. Start Flask
python app.py

# 4. Open in browser
# โ†’ http://localhost:5000

Option 2 โ€” Run with Docker

# 1. Build the Docker image
docker build -t whats-cooking-now .

# 2. Run the container
docker run -p 5000:5000 whats-cooking-now

# 3. Open in browser
# โ†’ http://localhost:5000

๐Ÿ”— API Endpoints

Method Endpoint Description
GET / Serves the frontend app
GET /api/recipe Returns recipe based on current time
GET /api/recipe/breakfast Returns breakfast recipe
GET /api/recipe/brunch Returns brunch recipe
GET /api/recipe/lunch Returns lunch recipe
GET /api/recipe/snack Returns snack recipe
GET /api/recipe/dinner Returns dinner recipe
GET /api/recipe/midnight Returns midnight recipe

Sample Response

{
  "meal_time": "dinner",
  "current_hour": 20,
  "recipe": {
    "emoji": "๐ŸŒ™",
    "meal": "Creamy Tuscan Garlic Pasta ๐Ÿ๐Ÿง„",
    "time_range": "7 PM โ€“ 10 PM",
    "ingredients": [
      "300g fettuccine pasta",
      "3 cloves garlic",
      "1 cup heavy cream",
      "ยฝ cup sun-dried tomatoes",
      "2 cups spinach",
      "Parmesan cheese",
      "Olive oil, salt, pepper"
    ],
    "steps": [
      "Cook pasta according to package instructions.",
      "Sautรฉ garlic in olive oil for 2 minutes.",
      "..."
    ],
    "fun_fact": "Italy has over 350 different pasta shapes! ๐Ÿ‡ฎ๐Ÿ‡น"
  }
}

โ˜๏ธ AWS Services Used

1. ๐ŸŸ  Amazon Lightsail โ€” Container Service

What it is: Amazon Lightsail is AWS's simplified cloud platform designed for developers who need to deploy apps quickly without managing complex infrastructure. It bundles compute, networking, and storage into simple, predictable monthly pricing.

What we used:

  • Lightsail Container Service โ€” a fully managed environment to run Docker containers
  • Power: nano (512MB RAM, 0.25 vCPU) โ€” perfect for small apps
  • Scale: 1 node
  • Auto-generated HTTPS public endpoint URL

How it works in this project:

GitHub push โ†’ GitHub Actions builds Docker image
           โ†’ Pushes image to Lightsail
           โ†’ Creates deployment
           โ†’ App is live at HTTPS URL

Lightsail Container Service URL format:

https://<service-name>.<random-id>.<region>.cs.amazonlightsail.com

Pricing:


2. ๐Ÿ” AWS IAM โ€” Identity and Access Management

What it is: AWS IAM lets you securely control who can access your AWS resources and what actions they can perform. It follows the principle of least privilege โ€” give only the permissions needed, nothing more.

What we used:

  • Created a dedicated IAM user specifically for GitHub Actions
  • Attached the AmazonLightsailFullAccess policy
  • Generated Access Key ID and Secret Access Key for programmatic access

Why not use root account keys?

โŒ Root account has unlimited access to everything in your AWS account. If leaked, an attacker can delete all your resources, rack up huge bills, or steal data. Always use IAM users with limited permissions.

IAM User Setup Steps:

  1. Go to IAM Console โ†’ Users โ†’ Create User
  2. Username: github-actions-lightsail
  3. Select: "Attach policies directly"
  4. Attach: AmazonLightsailFullAccess
  5. Go to user โ†’ Security credentials โ†’ Create access key
  6. Select: "Application running outside AWS"
  7. Save the Access Key ID and Secret Access Key โ€” shown only once!

Console: https://console.aws.amazon.com/iam/home#/users


3. ๐Ÿ™ GitHub Actions โ€” CI/CD Pipeline

What it is: GitHub Actions is a CI/CD (Continuous Integration / Continuous Deployment) platform built into GitHub. It automatically runs workflows when you push code โ€” in our case, it builds and deploys the app to Lightsail on every push to main.

What we used:

  • Workflow file: .github/workflows/deploy.yml
  • Trigger: Push to main branch
  • Jobs: Build Docker image โ†’ Push to Lightsail โ†’ Deploy โ†’ Print URL

Workflow Steps Explained:

Step What it does
actions/checkout@v4 Pulls your code into the runner
aws-actions/configure-aws-credentials@v4 Authenticates with AWS using your secrets
Install lightsailctl Installs the Lightsail CLI plugin for pushing images
docker build Builds your Docker image locally on the runner
create-container-service Creates Lightsail service if it doesn't exist yet
Wait loop Polls until service state is READY or RUNNING
push-container-image Uploads Docker image to Lightsail
create-container-service-deployment Deploys the new image live
Print URL Outputs the live app URL in the logs

GitHub Secrets Required:

Secret Name Description
AWS_ACCESS_KEY_ID IAM user access key
AWS_SECRET_ACCESS_KEY IAM user secret key
AWS_REGION AWS region e.g. us-east-1
LIGHTSAIL_SERVICE_NAME Your service name e.g. whats-cooking-now

How to add secrets: GitHub Repo โ†’ Settings โ†’ Secrets and variables โ†’ Actions โ†’ New repository secret


4. ๐Ÿณ Docker โ€” Containerization

What it is: Docker packages your application and all its dependencies into a container โ€” a lightweight, portable unit that runs the same way everywhere: your laptop, a teammate's machine, or AWS.

Our Dockerfile explained:

FROM python:3.11-slim        # Use lightweight Python 3.11 base image

WORKDIR /app                 # Set working directory inside container

COPY requirements.txt .      # Copy dependencies file first (layer caching)
RUN pip install --no-cache-dir -r requirements.txt  # Install dependencies

COPY . .                     # Copy all project files

EXPOSE 5000                  # Tell Docker the app runs on port 5000

CMD ["python", "app.py"]     # Command to start the Flask app

Useful Docker commands:

# Build image
docker build -t whats-cooking-now .

# Run container
docker run -p 5000:5000 whats-cooking-now

# Run in background
docker run -d -p 5000:5000 whats-cooking-now

# List running containers
docker ps

# Stop container
docker stop <container-id>

# Remove image
docker rmi whats-cooking-now

๐Ÿ”ง Full Deployment Setup Guide

Step 1 โ€” Create IAM User

  1. Open IAM Console
  2. Create user: github-actions-lightsail
  3. Attach policy: AmazonLightsailFullAccess
  4. Create access key โ†’ save both keys

Step 2 โ€” Add GitHub Secrets

  1. Go to your GitHub repo โ†’ Settings โ†’ Secrets and variables โ†’ Actions
  2. Add these 4 secrets:
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
    • AWS_REGION (e.g. us-east-1)
    • LIGHTSAIL_SERVICE_NAME (e.g. whats-cooking-now)

Step 3 โ€” Push to GitHub

git init
git add .
git commit -m "Initial commit โ€” What's Cooking Now"
git branch -M main
git remote add origin https://github.com/Santhosh-p653/aws-lightsail.git
git push -u origin main

Step 4 โ€” Watch GitHub Actions Deploy

  1. Go to your repo โ†’ Actions tab
  2. Watch the workflow run in real time
  3. When complete, click the last step "Get App URL"
  4. Copy your live HTTPS URL ๐ŸŽ‰

Step 5 โ€” Open Your Live App

https://whats-cooking-now.xxxxxxxx.<region>.cs.amazonlightsail.com

๐Ÿงช Testing the API Locally

# Current time recipe
curl http://localhost:5000/api/recipe

# Specific meal
curl http://localhost:5000/api/recipe/dinner

# Pretty print
curl http://localhost:5000/api/recipe | python -m json.tool

# Test invalid (should return 404)
curl -i http://localhost:5000/api/recipe/pizza

๐Ÿงน Cleanup Guide

Disable (Pause โ€” keeps data, stops compute charges)

aws lightsail update-container-service \
  --service-name whats-cooking-now \
  --is-disabled

Full Delete (Permanent โ€” cannot be undone)

aws lightsail delete-container-service \
  --service-name whats-cooking-now

Or via Console: Lightsail Console โ†’ Click service โ†’ Three dots menu โ†’ Delete

Full Cleanup Checklist

  • โœ… Delete Lightsail container service
  • โœ… Delete IAM user (github-actions-lightsail)
  • โœ… Remove GitHub repository secrets
  • โœ… Delete any unused Lightsail Static IPs
  • โœ… Delete any Lightsail snapshots

โš ๏ธ Static IPs are billed even when unattached โ€” always check Lightsail Networking.


๐Ÿ› Troubleshooting

Problem Fix
CSS/JS not loading Make sure paths are /static/style.css and /static/script.js
404 on /api/recipe Flask is not running โ€” check python app.py
Docker build fails Check requirements.txt exists in root folder
GitHub Actions fails at AWS step Verify all 4 GitHub Secrets are set correctly
Lightsail service stuck in PENDING Wait 2โ€“3 minutes, it's provisioning for the first time
App URL returns 503 Service is disabled โ€” re-enable from Lightsail console

๐Ÿ“„ License

MIT License โ€” free to use, modify, and distribute.


๐Ÿ™Œ Built With


๐Ÿ’ก Tip: Star โญ this repo if you found it helpful!

Built With

Share this project:

Updates