ParkBankAPI

ParkBankApi CodeFactor License Go CI CodeQL

A comprehensive Go-based REST API with advanced monitoring and metrics capabilities.

Table of Contents

Features

API Endpoints

All of the endpoints are described in detail here

Metrics Dashboard

The project includes an interactive HTML dashboard (readme.html) that provides:

To use the dashboard:

  1. Start the API server
  2. Open readme.html in a web browser
  3. The dashboard will automatically fetch and display metrics

Installation

Prerequisites

Build

go mod tidy
go build -o astelta-api-v2 main.go

Run

./astelta-api-v2

Configuration

Configure the API using environment variables or a .env file:

Environment Variables

Variable Description Default
DATABASE_URL Full PostgreSQL connection string -
DB_HOST Database host -
DB_PORT Database port -
DB_USER Database username -
DB_PASSWORD Database password -
DB_NAME Database name -
CA_CERT_PATH Path to CA certificate for SSL -

Connection Examples

Using DATABASE_URL:

DATABASE_URL="postgres://user:password@host:port/database?sslmode=require"

Using individual variables:

DB_HOST=localhost
DB_PORT=5432
DB_USER=myuser
DB_PASSWORD=mypassword
DB_NAME=mydatabase

Usage

Starting the Server

# With environment variables
export DB_HOST=your-host
export DB_USER=your-user
export DB_PASSWORD=your-password
./astelta-api-v2

# Or with .env file
./astelta-api-v2

Testing Endpoints

# Health check
curl http://localhost:8097/health

# Metrics
curl http://localhost:8097/metrics

# Database status
curl http://localhost:8097/db-status

Development

Project Structure

.
├── main.go           # Main application file
├── readme.html       # Interactive metrics dashboard
├── .gitignore       # Git ignore rules
├── go.mod           # Go module file
├── go.sum           # Go dependencies
└── .env             # Environment configuration (ignored)

Key Components

Adding New Endpoints

  1. Create a handler function:
    func myHandler(w http.ResponseWriter, r *http.Request) {
     // Handler logic
    }
    
  2. Register the endpoint in main():
    http.HandleFunc("/my-endpoint", corsMiddleware(myHandler))
    

Monitoring & Observability

The API provides multiple levels of monitoring:

Use these endpoints with monitoring tools like Prometheus, Grafana, or custom dashboards.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.


Built with Go and PostgreSQL