Skip to content

ktfth/red-velvet-workspace

Repository files navigation

Red Velvet Workspace

This project is a digital banking application that uses Kafka for event streaming and PostgreSQL for data persistence. The application supports checking accounts, credit cards, and PIX transfers.

Features

  • Checking Account Management
    • Create accounts
    • Deposit and withdraw funds
    • Check balance
  • Credit Card Operations
    • Issue new credit cards
    • Make purchases
    • Process payments
  • PIX Transfers
    • Register PIX keys
    • Send and receive instant transfers
  • Transaction History
    • Track all account movements
    • Filter by transaction type

Prerequisites

  • Docker and Docker Compose
  • Kubernetes cluster (Docker Desktop Kubernetes, Minikube, or Kind)
  • Tilt
  • Go 1.21 or higher
  • k6 (for load testing)

Running with Docker Compose

  1. Start all services:
docker-compose up -d
  1. Check the services:
  1. Stop all services:
docker-compose down

Database Management

PostgreSQL Configuration

The application uses PostgreSQL with the following default settings:

  • Database: banco_digital
  • User: admin
  • Password: admin123
  • Port: 5432

pgAdmin Access

The project includes pgAdmin 4 for database management through a web interface.

  1. Access pgAdmin at http://localhost:5050

  2. Login credentials:

  3. To connect to the PostgreSQL database:

    1. Click "Add New Server"
    2. In "General" tab:
      • Name: Banco Digital (or any name you prefer)
    3. In "Connection" tab:
      • Host: postgres
      • Port: 5432
      • Database: banco_digital
      • Username: admin
      • Password: admin123

Available features in pgAdmin:

  • Database structure visualization
  • SQL query execution
  • Table management
  • Backup and restore
  • Performance monitoring

Running with Kubernetes (Tilt)

  1. Make sure your Kubernetes cluster is running:
kubectl cluster-info
  1. Start the application with Tilt:
tilt up
  1. Access the Tilt UI at http://localhost:10350

  2. To stop the application:

tilt down

API Endpoints

Account Operations

  • POST /accounts - Create a new account
  • POST /accounts/credit-cards - Issue a new credit card
  • POST /accounts/pix-keys - Register a PIX key
  • POST /accounts/transactions - Make a transaction

Load Testing

We use k6 for load testing. The test scripts are in the tests/k6 directory.

  1. Install k6:
# Windows (Chocolatey)
choco install k6

# macOS
brew install k6
  1. Run the load tests:
k6 run tests/k6/load-test.js

The load test simulates:

  • Account creation
  • Credit card issuance
  • PIX key registration
  • Deposits
  • Credit card purchases
  • PIX transfers

API Testing with Postman

We use Postman to test the API endpoints.

postman login --with-api-key $POSTMAN_API_KEY
postman collection run 6394192-bd1fe6cf-24a1-4514-b211-c52c62ba9c9e

Project Structure

.
├── cmd/
│   └── main.go                # Application entry point
├── internal/
│   ├── domain/
│   │   └── models/           # Domain models
│   ├── application/
│   │   └── services/         # Business logic
│   ├── infrastructure/
│   │   └── database/         # Database configuration
│   └── interfaces/
│       └── http/
│           └── handlers/     # HTTP handlers
├── k8s/                      # Kubernetes manifests
├── tests/
│   └── k6/                   # Load test scripts
├── docker-compose.yml        # Docker Compose configuration
├── Dockerfile               # Docker build configuration
├── Tiltfile                # Tilt configuration
└── README.md               # This file

API Documentation

The API documentation is available at http://localhost:8080/swagger/index.html when the application is running.

Monitoring

About

Bank use case with scalability in mind

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published