RECENGINE-MTHREE/
│
├── docker/ # Docker configuration
│ ├── Dockerfile # Flask container build file
│ └── nginx.conf # Nginx reverse proxy configuration
│
├── grafana/ # Grafana dashboards & provisioning
│ ├── dashboards/ # Grafana dashboard JSON exports
│ │ └── transactions.json
│ └── provisioning/ # Automatic datasource & dashboard provisioning
│ ├── dashboards/
│ │ └── default.yml
│ └── datasources/
│ └── datasource.yml
│
├── prometheus/ # Prometheus monitoring configuration
│ └── prometheus.yml
│
├── src/ # Python backend source code
│ ├── controllers/ # Business Logic Coordination
│ │ ├── reconcile.py # Categorizes transactions across all tables (match/mismatch)
│ │ └── simulate.py # Simulates good and bad transactions
│ │
│ ├── models/ # MODEL LAYER: Database Interactions
│ │ ├── db_pool.py # MySQL Connector connection pool setup
│ │ ├── discrepancy_db.py # SQL executions for recording mismatched entries
│ │ ├── schema.sql # Database schema definition
│ │ └── transaction_db.py # SQL executions for reading/writing transactions
│ │
│ ├── observability/ # Application metrics & tracking
│ │ └── metrics.py # Prometheus instrumentations
│ │
│ └── views/ # HTTP Routes / Endpoints
│ └── api_routes.py # Flask blueprint and API routes
│
├── static/ # Frontend static assets
│ ├── css/
│ │ └── style.css # Custom CSS styling
│ ├── js/
│ │ ├── dashboard.js # Metrics / analytics scripting
│ │ ├── reconciliation.js # Reconciliation page scripts
│ │ └── transactions.js # Transactions view and execution scripts
│ ├── index.html # Main dashboard UI
│ ├── reconciliation.html # Reconciliation summary and details UI
│ └── transactions.html # Transactions list UI
│
├── terraform/ # AWS Infrastructure as Code
│ ├── main.tf # EC2, VPC, Security Groups definitions
│ ├── terraform.tf # Terraform provider configuration
│ └── variables.tf # AWS deployment variables
│
├── app.py # Main Flask entrypoint
├── docker-compose.yml # Multi-container setup (Flask, MySQL, Prometheus, Grafana, Nginx)
└── requirements.txt # Python dependencies
- AWS CLI: Ensure you have the AWS CLI installed locally.
If you do not already have an SSH key, generate one:
ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa
aws configure
cd terraform
terraform init
terraform apply
At this point, the instance is running and visible in your AWS EC2 console. However, it will take approximately 3 minutes for all dependencies to finish installing.
You can monitor the setup progress by SSHing into the instance:
ssh -i ~/.ssh/id_rsa ec2-user@<instance-public-ip>
tail -f -n 10 /var/log/user-data.log
Once finalized, the application will be accessible at: http://<public-ip>/index
terraform destroy# Install Docker
sudo dnf install -y docker
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker $USER
newgrp docker
# Install Docker Compose
sudo curl -SL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m) -o /usr/libexec/docker/cli-plugins/docker-compose
sudo chmod +x /usr/libexec/docker/cli-plugins/docker-compose
docker compose version
# Install buildx (required; missing causes errors)
mkdir -p ~/.docker/cli-plugins
BUILDX_VERSION=$(curl -s https://api.github.com/repos/docker/buildx/releases/latest | grep -oP '"tag_name": "\K[^"]+')
curl -L https://github.com/docker/buildx/releases/download/${BUILDX_VERSION}/buildx-${BUILDX_VERSION}.linux-amd64 -o ~/.docker/cli-plugins/docker-buildx
chmod +x ~/.docker/cli-plugins/docker-buildx
docker buildx version
docker compose up -d --build && docker image prune -f
docker ps
- Remote: http://your-public-ip/index (Requires an EC2 inbound security group rule allowing traffic on port 80)
- Local:
curl http://localhost/index
docker compose logs -f flask
docker compose down -v