Final project for my Master's thesis at HTW Berlin - "Building a dynamic carbon-aware infrastructure deployment using IaC"
- Tech Stack
- Python
- Relational: PostgreSQL
- NoSQL: MongoDB
- IaC: Terraform to provision:
- Cloud services (AWS, Azure, GCP)
- Databases (RDS for PostgreSQL)
- Compute instances (EC2 / Lambda for serverless - dedicated to lightweight tasks)
- CI/CD: GitHub Actions
- Containerization: Docker
- AWS (integrates with Terraform, robust set of services for data / compute resources)
- ElectricityMaps for integration carbon-aware infrastructure for future scaling
- Accounting APIs: e.g. Ledger Python
- Authentication / profile management -> likely just by entering public crypto address <> blockchain API
- Fetch balances & transactions via blockchain APIs
- Build tables (from databases) showing all (crypto) transactions
- Generate reports: Calculate income, expenses, and profit based on crypto prices.
- Export financial data for tax purposes (CSV/Excel).
- Install Terraform & setup provider
- Configure python
venv
and install dependencies (pip install fastapi uvicorn web3 psycopg2-binary
)
- Write Terraform scripts for:
- Provisioning a PostgreSQL database (or RDS instance) -> TBD
- Deploying an EC2 instance for hosting your backend.
- Setting up storage for logs or exported reports (e.g., S3 buckets).
Example Terraform for PostgreSQL database:
resource "aws_db_instance" "crypto_db" {
allocated_storage = 20
engine = "postgres"
engine_version = "13"
instance_class = "db.t2.micro"
name = "crypto_accounting"
username = "admin"
password = "secure_password"
parameter_group_name = "default.postgres13"
}
Steps taken:
- Create git repo (https://github.com/JeremLeOuf/IaC-Crypto-Accounting-System)
- Clone in VSCode
- Install
pip
and installvirtualenv
- Create virtual environment "CryptoAccounting"
virtualenv CryptoCompta
- Activate it:
CryptoCompta/bin/activate
2.1. Dev Environment setup: source setup.sh
:
- Install pip, git, unzip
- Create CryptoCompta virtualenv and activate it
- Install requirements
- Install AWS CLI
- Init terraform
- Keep the session alive with the activate virtualenv
6. Create a requirements.txt
file in the root of the project folder with the following dependencies: fastapi uvicorn web3 psycopg2-binary
TO CORRECT
-
Install them:
pip install -r requirements.txt
> After activating venv Should be done only on the production machine -
Install Terraform:
sh install_terraform.sh