How shivamsingh163248/health_privacy_app works
Project Type and Purpose
• This is a full-stack, monolithic web application built with Flask (Python).
• It provides a web UI (HTML templates) for health-data anonymization, backed by a relational database and supporting utilities.
• It is containerized with Docker, deployed to an Ubuntu EC2 instance via Terraform, and uses GitHub Actions for CI/CD.
Key Directories and Files
• app.py, config.py: Flask application entry point and configuration.
• models/database.py, db/schema.sql: Data layer, ORM setup and schema.
• utils/anonymizer.py: Core anonymization logic.
• templates/*.html: View layer (Jinja2 templates).
• docker-compose.yml, Dockerfile: Local multi-container setup vs. single-service container build.
• terraform/*.tf: Infrastructure-as-code provisioning (EC2 instance, security group).
• .github/workflows: CI/CD pipelines (build, push image, deploy).
Main Components
a. Client & Browser
• End user’s web browser issuing HTTP(S) requests.
b. AWS Infrastructure
• Terraform Provisioner: creates EC2 instance and security group.
• EC2 Instance: Docker host.
c. Containerized Application
• Docker Engine running a single container from the built health_privacy_app image.
• Flask App (app.py):
• Controller layer handling routes (/login, /dashboard, /anonymize).
• Model layer (models/database.py + SQLAlchemy) interacting with the RDBMS.
• Utility layer (utils/anonymizer.py) performing data anonymization.
• View layer serving templates/*.html.
d. Database
• Relational database (e.g., PostgreSQL) defined either in docker-compose or external service.
• Holds donor data before anonymization and possibly audit logs.
e. Outputs
• File storage (outputs/*.csv) where anonymized data is written.
f. CI/CD & Container Registry
• GitHub Actions workflows:
• build.yml: runs tests, builds Docker image.
• DockerHubImagePush.yml: tags & pushes to Docker Hub.
• deploy-image.yml: triggers remote deploy (SSH/Ansible/Terraform apply).
• Docker Hub: stores versioned container images.
Relationships and Data Flows
• Browser → (HTTP/HTTPS) → EC2 Security Group → EC2 Docker Host → Docker Container → Flask Routing →
– If reading data: Flask → ORM → Database → Flask → Browser.
– If anonymizing: Flask → receives file or DB data → utils.anonymizer → writes CSV to outputs → Flask → Browser triggers download.
• CI/CD Flow: GitHub push → Actions → build & test → push image to Docker Hub → trigger Terraform/apply or SSH to EC2 → Docker pull & run new image.
Architectural Patterns & Principles
• MVC-style separation within a monolithic Flask app.
• Container-first deployment (Docker + Docker Compose).
• Infrastructure-as-code (Terraform) for reproducible environments.
• Automated CI/CD (GitHub Actions) for continuous delivery.
• Single responsibility modules (models, utils, templates).
Essential Elements Checklist
• Arrowheads showing direction of HTTP, data, file system, and CI/CD flows.
• Callouts for critical ports (e.g., 80:6000 mapping) and security group rules.