Skip to content

Blockdaemon/technical-assessment-sre

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Transaction API Services

This repository contains two implementations of a transaction API service:

Both services provide identical REST APIs for managing financial transactions with PostgreSQL database integration and Prometheus metrics.

Database Setup

The services require a PostgreSQL database with the following configuration:

Local Development with Docker

# Start PostgreSQL database
docker run -d \
  --name transaction-db \
  -e POSTGRES_USER=root \
  -e POSTGRES_PASSWORD=rootpassword \
  -e POSTGRES_DB=transactions \
  -p 5432:5432 \
  postgres:15

Kubernetes Deployment

Deploy the database using the provided Kubernetes templates:

# Deploy PostgreSQL
kubectl apply -f database/postgresql.yaml

The database will be initialized by the Go/Python services on first connection with the required transactions table schema.

Database Schema

The transactions table includes:

  • id (Serial Primary Key)
  • user_id (Integer)
  • amount (Decimal 10,2)
  • type (VARCHAR 20) - 'credit' or 'debit'
  • description (Text)
  • created_at (Timestamp)

API Endpoints

Both services expose identical REST APIs:

  • POST /transactions - Create a new transaction
  • GET /transactions - List transactions (with pagination)
  • GET /transactions/{id} - Get specific transaction
  • GET /health - Health check endpoint
  • GET /metrics - Prometheus metrics

Environment Variables

Both services use the DATABASE_URL environment variable:

DATABASE_URL=postgresql://root:rootpassword@localhost:5432/transactions?sslmode=disable

Quick Start

  1. Start the database:

    docker run -d --name transaction-db -e POSTGRES_USER=root -e POSTGRES_PASSWORD=rootpassword -e POSTGRES_DB=transactions -p 5432:5432 postgres:15
  2. Choose your service implementation:

Kubernetes Deployment

For full Kubernetes deployment with both services:

# Deploy database
kubectl apply -f database/postgresql.yaml

# Deploy Go service  
kubectl apply -f go/k8s/

# Deploy Python service
kubectl apply -f python/k8s/

Architecture

┌─────────────────┐    ┌─────────────────┐
│   Go Service    │    │ Python Service  │
│   (Port 8080)   │    │   (Port 8080)   │
└─────────┬───────┘    └─────────┬───────┘
          │                      │
          └──────────┬───────────┘
                     │
         ┌───────────▼────────────┐
         │   PostgreSQL Database  │
         │      (Port 5432)       │
         └────────────────────────┘

Both services are independently deployable and can run simultaneously, sharing the same PostgreSQL database.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published