This project implements an ETL (Extract, Transform, Load) pipeline that polls the public Coinbase API every 15 seconds, processes Bitcoin price data, and persists the information to a PostgreSQL database.
├── cmd
│ └── main.go # Application entry point
│
├── internal/database # Data access implementation
│ ├── db.go # Database connection and migration functions
│ ├── logger.go # Logic for writing logs to the database
│ └── repository.go # Persistence layer for entities
│
├── pkg
│ ├── http
│ │ └── client.go # HTTP client for consuming the Coinbase API
│ ├── models
│ │ ├── coin_price.go # Model for cryptocurrency price
│ │ └── log_event.go # Model for log entries
│ └── services
│ └── etl.go # ETL pipeline logic (extract, transform, load)
│
├── .env # Environment variables (do not commit)
├── .gitignore # Files and folders ignored by Git
├── Dockerfile # Docker image configuration
├── go.mod # Go module and dependencies
└── go.sum # Dependency checksums
- Go 1.20+
- GORM (ORM for Go)
- PostgreSQL
- godotenv for loading environment variables
- Docker (optional) for containerization
-
Clone the repository
git clone https://github.com/DanielBrisch/BitCoin-ETL.git cd BitCoin-ETL -
.envfile
Create a.envfile in the project root with the following variables:DB_USER=your_username DB_PASSWORD=your_password DB_HOST=localhost DB_PORT=5432 DB_NAME=etl_bitcoin
-
Initialize the module and install dependencies
go mod download
To run the application locally:
go run cmd/main.goEvery 15 seconds the program will:
- Extract the current Bitcoin price from the Coinbase API.
- Transform the payload into the
CoinPricestructure. - Persist the record into the
coin_pricestable in PostgreSQL. - Log events to the
logstable.
-
coin_prices
id(serial, PK)value(float)crypto(varchar)coin(varchar)timestamp(timestamp)
-
logs
id(serial, PK)level(varchar)message(text)timestamp(timestamp)
This project is licensed under the MIT License.