A simple microservices architecture demonstration featuring a Python Flask backend API and a web frontend dashboard, designed for DevOps practices including containerization, monitoring, and CI/CD pipelines.
βββββββββββββββββββ HTTP/REST API ββββββββββββββββββββ
β Frontend βββββββββββββββββββββΊβ Backend β
β Dashboard β β User API β
β (Port 8084) β β (Port 8086) β
βββββββββββββββββββ ββββββββββββββββββββ
- Purpose: RESTful API for user management
- Technology: Python Flask with CORS support
- Port: 8086 (configurable via
PORTenv var) - Features:
- CRUD operations for user management
- Health check endpoint
- Service statistics
- In-memory database (easily replaceable with real DB)
- Comprehensive logging
- Error handling
- Purpose: Web dashboard for user management
- Technology: Python Flask with HTML templates
- Port: 8084 (configurable via
PORTenv var) - Features:
- Web-based user interface
- Real-time service status monitoring
- Add/Delete user functionality
- Service health dashboard
- Responsive design
- Python 3.7+
- pip
cd hiring-account-actions
pip install -r requirements.txtpython backend_service.pyThe backend API will be available at http://localhost:8086
In a new terminal:
python frontend_service.pyThe web dashboard will be available at http://localhost:8084
Open your web browser and navigate to http://localhost:8084 to access the user management dashboard.
GET /healthReturns service health status and metadata.
GET /api/users # Get all users
GET /api/users/{id} # Get specific user
POST /api/users # Create new user
PUT /api/users/{id} # Update user
DELETE /api/users/{id} # Delete userGET /api/stats # Get service statisticsGET / # Main dashboard
GET /health # Frontend health check
POST /add_user # Add user form submission
GET /delete_user/{id} # Delete user action
GET /api/frontend-stats # Frontend service stats| Variable | Default | Description |
|---|---|---|
PORT |
8086 (backend), 8084 (frontend) | Port to run the service |
DEBUG |
False | Enable debug mode |
ENVIRONMENT |
development | Environment name |
BACKEND_URL |
http://localhost:8086 | Backend service URL (frontend only) |
# Backend
export PORT=8086
export DEBUG=true
export ENVIRONMENT=production
# Frontend
export PORT=8084
export BACKEND_URL=http://backend-service:8086
export ENVIRONMENT=productionFROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY backend_service.py .
EXPOSE 8086
CMD ["python", "backend_service.py"]FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY frontend_service.py .
EXPOSE 8084
ENV BACKEND_URL=http://backend:8086
CMD ["python", "frontend_service.py"]version: '3.8'
services:
backend:
build: .
dockerfile: Dockerfile.backend
ports:
- "8086:8086"
environment:
- ENVIRONMENT=docker
frontend:
build: .
dockerfile: Dockerfile.frontend
ports:
- "8084:8084"
environment:
- BACKEND_URL=http://backend:8086
- ENVIRONMENT=docker
depends_on:
- backendapiVersion: apps/v1
kind: Deployment
metadata:
name: backend-service
spec:
replicas: 2
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- name: backend
image: your-registry/backend:latest
ports:
- containerPort: 8086
env:
- name: ENVIRONMENT
value: "kubernetes"
---
apiVersion: v1
kind: Service
metadata:
name: backend-service
spec:
selector:
app: backend
ports:
- port: 8086
targetPort: 8086- Backend:
GET http://localhost:8086/health - Frontend:
GET http://localhost:8084/health
- Backend Stats:
GET http://localhost:8086/api/stats - Frontend Stats:
GET http://localhost:8084/api/frontend-stats
{
"status": "healthy",
"service": "backend-user-service",
"timestamp": "2025-08-12T15:30:00.000Z",
"version": "1.0.0"
}- Services run with CORS enabled for cross-origin requests
- No authentication implemented (demo purposes)
- In-memory storage (data not persistent)
- Implement proper authentication/authorization
- Use HTTPS/TLS encryption
- Implement rate limiting
- Use persistent storage (database)
- Add input validation and sanitization
- Enable security headers
- Start both services
- Open
http://localhost:8084 - Add a new user via the web form
- Verify the user appears in the table
- Delete a user and verify removal
# Test backend health
curl http://localhost:8086/health
# Get all users
curl http://localhost:8086/api/users
# Create a user
curl -X POST http://localhost:8086/api/users \
-H "Content-Type: application/json" \
-d '{"name":"Test User","email":"test@example.com","role":"user"}'
# Get stats
curl http://localhost:8086/api/stats- Verify backend is running on port 8086
- Check
BACKEND_URLenvironment variable - Ensure no firewall blocking connections
# Find process using port
lsof -i :8086
lsof -i :8084
# Kill process if needed
kill -9 <PID># Reinstall dependencies
pip install -r requirements.txthiring-account-actions/
βββ README.md # This file
βββ requirements.txt # Python dependencies
βββ backend_service.py # Backend REST API
βββ frontend_service.py # Frontend web dashboard
βββ delete_user_resources.py # AWS resource cleanup tool
βββ policy.json # AWS IAM policy
βββ user_resource_cleanup.log # Cleanup script logs
- Backend: Add new routes to
backend_service.py - Frontend: Update templates and routes in
frontend_service.py - API: Follow RESTful conventions
- UI: Update HTML templates with proper styling
- Follow PEP 8 style guidelines
- Add proper logging for debugging
- Handle errors gracefully
- Write descriptive commit messages
This project includes AWS resource management tools:
delete_user_resources.py: Cleanup script for AWS resourcespolicy.json: IAM policy for restricted AWS access- See individual files for detailed documentation
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is for demonstration purposes. Use at your own risk in production environments.
Created for DevOps demonstration and learning purposes π