Skip to content

Aman09072000/Stakeway-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stakeway - Backend

Overview

1. Backend Development

  • API Endpoints:
    • POST /validators: Creates a new validator request.
    • GET /validators/{request_id}: Retrieves the status of a specific validator request.
    • GET /health: Provides a health check for the API.
    • GET /metrics: Exposes Prometheus metrics for monitoring.
  • Database: SQLite is utilized for persistent data storage.(Postgres -> Production))
  • Containerization: Docker is employed for easy deployment and scalability.
  • Testing: Comprehensive unit and integration tests are implemented.
  • Paths:
    • API Code: /code/internal/api/handlers.go
    • Database Models: /code/internal/models/validator.go
    • Unit Tests: /code/tests/unit/service_test.go, /code/tests/unit/utils_test.go
    • Integration Tests: /code/tests/integration/api_test.go

2. Deployment & Monitoring

  • Kubernetes Deployment:
    • Deployment YAML: /kubernetes/deployment.yaml
    • Service YAML: /kubernetes/service.yaml
  • Monitoring:
    • Prometheus metrics endpoint (/metrics).
    • Grafana dashboard for metric visualization.
    • Alertmanager for alert handling.
    • Alert Rules: /kubernetes/prometheus-alert-rules.yaml.
  • Paths:
    • PostgreSQL: /kubernetes/postgresql.yaml
    • Grafana: /kubernetes/grafana.yaml
    • Alertmanager: /kubernetes/alertmanager.yaml

3. Blockchain Integration

  • Sepolia Testnet:
    • Script to simulate Ethereum staking transactions.
    • Wallet balance query, ETH transfer, and transaction hash logging.
  • Documentation:
    • Setup instructions for Sepolia testnet connection.
    • Script execution steps.
  • Paths:
    • Blockchain Code: /code/blockchain/main.go
    • Blockchain Setup: /code/blockchain/README.md

Setup Instructions

1. Backend API

  1. Clone: git clone && cd stakeway-backend
  2. Dependencies: go mod download
  3. Run: go run cmd/main.go
  4. Test:
    • Create: curl -X POST http://localhost:8080/validators -d '{"num_validators": 5, "fee_recipient": "0x1234567890abcdef1234567890abcdef12345678"}'
    • Status: curl http://localhost:8080/validators/{request_id}
    • Health: curl http://localhost:8080/health
    • Metrics: curl http://localhost:8080/metrics

2. Docker Setup

  1. Build: docker build -t stakeway-backend:latest .
  2. Run: docker run -p 8080:8080 stakeway-backend:latest

3. Kubernetes Deployment

  1. Apply YAMLs:
    kubectl apply -f kubernetes/deployment.yaml
    kubectl apply -f kubernetes/service.yaml
    kubectl apply -f kubernetes/postgresql.yaml
    kubectl apply -f kubernetes/grafana.yaml
    kubectl apply -f kubernetes/alertmanager.yaml
    kubectl apply -f kubernetes/prometheus-alert-rules.yaml
  2. Access:
    • API: Use stakeway-backend service's external IP.
    • Grafana: http://<grafana-service-ip>:3000
    • Alertmanager: http://<alertmanager-service-ip>:9093

4. Blockchain Integration

  1. Dependencies: go get github.com/ethereum/go-ethereum
  2. Run: go run blockchain/main.go
  3. Follow: Query balance, simulate staking, log transaction hash.

Documentation

  • API Documentation: /docs/Api_Documentation.md
  • Setup Instruction: /docs/Setup_Instruction.md
  • Test Coverage: /docs/Test_Coverage.md

What’s Covered

  • Backend API for validator requests.
  • Asynchronous task processing.
  • Basic validation.
  • Unit and integration tests.
  • Kubernetes deployment with Prometheus/Grafana.
  • Sepolia testnet integration.
  • Health check and logging.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published