This project is a simple interactive Fortune Cookie application built to learn end-to-end deployment and infrastructure concepts.
The application consists of:
- React frontend
- FastAPI backend
- nginx reverse proxy
- Dockerized services
- AWS EC2 deployment
- React
- Vite
- CSS Animations
- FastAPI
- Uvicorn
- AWS EC2 (Amazon Linux)
- nginx
- Docker
- Docker Compose
Browser
↓
nginx (Frontend Container)
├── React Static Files
└── Reverse Proxy → FastAPI Backend
git clone <your-repo-url>
cd fortune-cookiecd backend
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtuvicorn app.main:app --reloadBackend runs on:
http://localhost:8000
cd frontend
npm install
npm run devFrontend runs on:
http://localhost:5173
FastAPI uses CORS middleware during local development:
allow_origins=["http://localhost:5173", "http://localhost:3000"]This allows the React frontend to communicate with the backend from a different origin during development.
The backend container:
- uses Python 3.12
- installs dependencies
- runs FastAPI using Uvicorn
The frontend container:
- builds the React app using Node.js
- serves static files using nginx
The application is orchestrated using Docker Compose.
Services:
- frontend
- backend
nginx inside the frontend container reverse proxies API calls to the backend container using Docker networking.
From project root:
docker compose up --buildApplication becomes available at:
http://localhost
nginx serves:
- React static frontend
- API proxy requests
Example configuration:
/etc/nginx/nginx.confserver {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri /index.html;
}
location /api/ {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}Docker Compose service discovery allows containers to communicate using service names.
Instance Type:
- t3.micro
OS:
- Amazon Linux
Inbound Rules:
- Port 22 → SSH
- Port 80 → HTTP
- Port 8000 → temporary backend testing (optional)
sudo dnf update -y
sudo dnf install docker -y
sudo systemctl enable docker
sudo systemctl start dockerInstall Docker Compose plugin:
sudo dnf install docker-compose-plugin -ygit clone <repo-url>
cd fortune-cookie
docker compose up -d --buildApplication is accessible using:
http://<EC2_PUBLIC_IP>
Optional:
- DuckDNS free domain setup
- SSL via Certbot
This project helped explore:
- EC2
- EBS volumes
- Security Groups
- Reverse Proxying
- Public vs Private Networking
- Docker Networking
- Containerized Deployments
Potential future enhancements:
- HTTPS with Certbot
- GitHub Actions CI/CD
- AWS Application Load Balancer
- AWS WAF
- Kubernetes Deployment
- ECS/Fargate Migration
- Redis Caching
- PostgreSQL/RDS Integration
Key concepts explored during this project:
- CORS
- nginx reverse proxy
- Docker networking
- Container orchestration
- AWS infrastructure basics
- Linux server administration
- Frontend + backend deployment workflows
sudo rm -rf /usr/share/nginx/html/*
sudo cp -r dist/* /usr/share/nginx/html/