The Pets Application is a learning project that demonstrates a full Django CRUD workflow—creating, reading, updating, and deleting pets and their veterinary records—then deploys the stack to AWS[...]
The application is designed to run on AWS infrastructure, utilizing services such as RDS for the database and S3 for static file storage.
Tool | Version | Notes |
---|---|---|
Python | 3.12 | Confirm with python --version |
pip | ≥23 | python -m pip install --upgrade pip |
virtualenv | any | or python -m venv |
AWS CLI | 2.x | aws configure set default profile |
EB CLI | 3.x | pip install awsebcli |
Git | ≥2.30 |
Pets_Application/
├── django/
│ ├── hello_app/ # sample landing app
│ │ ├── views.py
│ │ └── urls.py
│ ├── pets_app/ # main CRUD app
│ │ ├── migrations/
│ │ ├── templates/pets_app/
│ │ ├── admin.py
│ │ ├── models.py
│ │ ├── tests.py
│ │ └── views.py
│ ├── pets_project/
│ │ ├── settings.py
│ │ ├── urls.py
│ │ ├── wsgi.py
│ │ └── __init__.py
│ ├── manage.py
│ └── requirements.txt
├── media/ # uploaded pet photos (dev)
├── static/ # Tailwind CSS build output
├── .ebextensions/ # EB config files (prod only)
└── README.md # ← you are here
-
Database: MySQL database hosted on Amazon RDS
-
Static Files: Stored on Amazon S3
The application utilizes the following AWS resources:
-
EC2: Hosts the Django application
-
RDS: MySQL database for storing pet info(owner,breed,name,weight,height,vet visits,vaccinations.)
-
S3: Stores static files and media uploads
-
Elastic Beanstalk: Manages the application deployment and scaling
This diagram illustrates the high-level AWS architecture of the Django Pets Application. It shows how the different AWS services (EC2, RDS, S3, and Elastic Beanstalk) interact with the Django applicat[...]
# clone & enter repo
$ git clone https://github.com/Levi-Breedlove/Pets_Application.git
# django directory
$ cd django
# create virt‑env
$ python -m venv .venv && source .venv/bin/activate
# install deps
$ pip install -r requirements.txt # Django 5.2, pillow, mysqlclient (optional)
# prepare data migrations
python manage.py makemigrations
# migrations, sample data
$ python manage.py migrate
# (Optional) load starter data
$ python manage.py loaddata savedata.json # located in django/fixtures/
# run Tailwind build (if used)
$ npx tailwindcss -i ./static/src.css -o ./static/styles.css --watch &
# launch dev server
$ python manage.py runserver
# create user for admin console
$ python manage.py createsuperuser
Open http://127.0.0.1:8000 for the public site and /admin
for the admin console.
-
You can click a pet card to view information, of the pet, breed, owner, and vaccination records.
-
Demo button is included to mimic auto fill data for vaccine information upon visit/date.
-
SQL query to verify the Pets Table has loaded:
sqlite3 db.sqlite3 -header -column \ "SELECT id, name, owner, birth FROM pets_app_pet LIMIT 5;"
To manage your pet cards, owners, pet visits, vaccination records and users via Django's built-in admin interface, follow these steps:
-
Create a Superuser:
- Run this from the
django/
directorypython manage.py createsuperuser
- You'll be prompted to enter a username, email address and password.
- Run this from the
-
Start the Development Server:
python manage.py runserver
-
Sign In to the Admin Console:
- Open your browser at http://localhost:8000/admin/
-
Once signed in, you'll see the following sections in the admin dashboard:
-
Authentication and Authorization
- Groups — create, edit or delete user groups.
- Users — manage site users and their permissions.
-
Pets-App
- Breeds — view, add, edit or delete pet breeds.
- Pets — browse, create and edit pet profiles.
- Vaccination Records — add, update or remove vaccination cards.
- Vet Visits — record and review veterinary visits for each pet.
-
Recent actions — quick link to edits you've made most recently.
-
-
Log in to the admin at
http://localhost:8000/admin/
with your superuser credentials. -
Under Pets-APP, click Pets ➔ Add
-
Fill out the form:
-
We'll need to add a Breed to register the pet as and upload a photo:
-
Click Save.
-
You'll now see Pierre listed under Pets – you can click the ID number to edit it anytime.
This guide provides detailed instructions for deploying the Pets Application to AWS using Elastic Beanstalk, RDS for MySQL database, and S3 for static files.
Before deploying to AWS, you need to set up several tools and accounts. This section provides the essential setup steps needed for deployment.
-
Create an AWS Account:
- Visit AWS Sign Up
- Complete the registration process
- After verification, you'll have access to the AWS Management Console
-
Create an IAM User with Administrative Access:
- Log in to the AWS Management Console
- Navigate to IAM (Identity and Access Management)
- Create a new user with programmatic access
- Attach the "AdministratorAccess" policy
- Save the generated Access Key ID and Secret Access Key
# Install AWS CLI on Linux/macOS
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
# Verify installation
aws --version
# Configure AWS CLI with your credentials
aws configure
# Enter your Access Key ID when prompted
# Enter your Secret Access Key when prompted
# Enter your preferred region (e.g., us-west-2)
# Enter your preferred output format (json)
For other operating systems, visit the AWS CLI installation guide.
# Install EB CLI using pip
pip install awsebcli
# Verify installation
eb --version
If you encounter permission issues, you may need to use:
pip install --user awsebcli
# For Ubuntu/Debian
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y ppa:deadsnakes/ppa
sudo apt update
sudo apt install -y python3.12 python3.12-venv python3.12-dev
# Verify installation
python3.12 --version
# For Ubuntu/Debian
sudo apt update
sudo apt install -y git
# Verify installation
git --version
Now that you have all the prerequisites installed and configured, you're ready to proceed with deploying the Pets Application to AWS.
- Navigate to the IAM console in AWS
- Create a new role for Elastic Beanstalk with the following policies:
AWSElasticBeanstalkWebTier
AWSElasticBeanstalkWorkerTier
AmazonS3FullAccess
AmazonRDSFullAccess
-
Create an S3 bucket for static files:
aws s3 mb s3://pets-application-static --region your-region
-
Configure bucket permissions to allow public read access for static files:
aws s3api put-bucket-policy --bucket pets-application-static --policy file://s3-policy.json
Create a file named
s3-policy.json
with:{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadGetObject", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::pets-application-static/*" } ] }
-
Enable static website hosting:
aws s3 website s3://pets-application-static --index-document index.html --error-document error.html
-
Create a parameter group for MySQL:
aws rds create-db-parameter-group \ --db-parameter-group-name pets-app-mysql \ --db-parameter-group-family mysql8.0 \ --description "Parameter group for Pets Application"
-
Create MySQL database:
aws rds create-db-instance \ --db-instance-identifier pets-app-db \ --db-instance-class db.t3.micro \ --engine mysql \ --allocated-storage 20 \ --master-username admin \ --master-user-password YOUR_SECURE_PASSWORD \ --vpc-security-groups YOUR_SECURITY_GROUP_ID \ --db-parameter-group-name pets-app-mysql \ --db-name petsapp
-
Note the endpoint URL from the output for your database configuration.
-
Navigate to your project directory:
cd Pets_Application/django
-
Ensure you have the required files:
requirements.txt
with all dependenciesProcfile
with the content:web: gunicorn pets_project.wsgi
-
Create or update
.ebextensions/django.config
:option_settings: aws:elasticbeanstalk:container:python: WSGIPath: pets_project.wsgi:application aws:elasticbeanstalk:environment:proxy:staticfiles: /static: static container_commands: 01_migrate: command: "source /var/app/venv/*/bin/activate && python manage.py migrate --noinput" leader_only: true 02_collectstatic: command: "source /var/app/venv/*/bin/activate && python manage.py collectstatic --noinput" 03_createsu: command: "source /var/app/venv/*/bin/activate && python manage.py createsu" leader_only: true
-
Create a
.ebignore
file to exclude unnecessary files:.venv/ *.pyc __pycache__/ db.sqlite3 media/ html2/ .DS_Store .git/ .gitignore
-
Update your Django settings to support both local development and AWS deployment:
# Settings for database
if os.getenv("USE_SQLITE", "1") == "1":
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": BASE_DIR / "db.sqlite3",
}
}
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.mysql",
"NAME": os.getenv("DB_NAME", "pets"),
"USER": os.getenv("DB_USER", "django"),
"PASSWORD": os.getenv("DB_PASSWORD", ""),
"HOST": os.getenv("DB_HOST", "localhost"),
"PORT": os.getenv("DB_PORT", "3306"),
"OPTIONS": {"init_command": "SET sql_mode='STRICT_TRANS_TABLES'"},
}
}
# Settings for static files
if os.getenv("USE_S3", "0") == "1":
# AWS S3 settings
AWS_STORAGE_BUCKET_NAME = os.getenv('AWS_STORAGE_BUCKET_NAME', 'pets-application-static')
AWS_S3_CUSTOM_DOMAIN = f'{AWS_STORAGE_BUCKET_NAME}.s3.amazonaws.com'
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_LOCATION = 'static'
STATIC_URL = f'https://{AWS_S3_CUSTOM_DOMAIN}/{AWS_LOCATION}/'
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
# Media files settings
DEFAULT_FILE_STORAGE = 'pets_project.storage_backends.MediaStorage'
else:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
- Create a storage backend file
pets_project/storage_backends.py
:
from storages.backends.s3boto3 import S3Boto3Storage
class MediaStorage(S3Boto3Storage):
location = 'media'
file_overwrite = False
-
Initialize Elastic Beanstalk in your project:
eb init -p python-3.12 pets-application --region us-west-2
Follow the prompts to select your region and application settings.
-
Create the Elastic Beanstalk environment:
eb create pets-env
-
Set the required environment variables:
eb setenv DJANGO_SECRET_KEY=your_secret_key \ USE_SQLITE=0 \ DB_NAME=petsapp \ DB_USER=admin \ DB_PASSWORD=YOUR_SECURE_PASSWORD \ DB_HOST=your-rds-endpoint.rds.amazonaws.com \ DB_PORT=3306 \ USE_S3=1 \ AWS_STORAGE_BUCKET_NAME=pets-application-static \ AWS_ACCESS_KEY_ID=your_access_key \ AWS_SECRET_ACCESS_KEY=your_secret_key
-
Deploy your application:
eb deploy
-
Open your application:
eb open
-
SSH into your Elastic Beanstalk instance:
eb ssh
-
Activate the virtual environment and create a superuser:
source /var/app/venv/*/bin/activate cd /var/app/current python manage.py createsuperuser
-
View application logs:
eb logs
-
Monitor application health:
eb health
-
Scale your application:
eb scale 2 # Scale to 2 instances
-
Update your application:
- Make changes locally
- Test locally
- Commit changes
- Deploy with
eb deploy
-
Database Connection Issues:
- Verify security group settings to ensure the EC2 instance can connect to RDS
- Check environment variables for database connection
- Test connection from EB SSH session
-
Static Files Not Loading:
- Ensure S3 bucket permissions are correctly set
- Verify AWS credentials are valid
- Check CORS configuration for S3 bucket
-
Deployment Failures:
- Review logs with
eb logs
- Ensure all dependencies are in
requirements.txt
- Check
.ebextensions
configurations for syntax errors
- Review logs with
-
Application Errors:
- SSH into the instance and check application logs
- Verify environment variables are set correctly
- Test the application locally with production settings
- Use IAM roles with minimal required permissions
- Store sensitive information as environment variables, not in code
- Enable HTTPS for your Elastic Beanstalk environment
- Regularly update dependencies and apply security patches
- Implement proper input validation and sanitization in your application
- Consider using AWS WAF for additional protection
Pet Club community portal:
-
User requests arrive at the Django application.
-
Django processes the request, interacting with the MySQL database on RDS as needed.
-
For product images and static files, Django interacts with the configured S3 bucket.
-
The response is generated and sent back to the user.
[User] <-> [Django App] <-> [RDS MySQL] ^ | v [S3 Bucket]
The current Pets Application offers core features for pet record management via the Django admin. But there are major opportunities to expand this into a full-fledged Pet Club community portal.
-
User Features to Add:
- User Registration & Login
- User Profiles with Pet Cards
- Forum or Club Wall
- Photo Gallery Uploads
- Pet Matching or Friend System
- Search and Filter System
-
Communication Features:
- Email Notifications
- Admin-to-User Messaging
- Pet Adoption Inquiry Forms
-
Technical Improvements:
- Frontend Styling Upgrade
- Responsive Design
- Test Coverage
- Security Hardening
© 2025 Levi Breedlove – MIT License Amazon Web Services