go-postgres-rest - PostgreSQL REST API Framework for Go
A comprehensive PostgreSQL REST API framework and Golang backend framework for enterprise-grade applications. This production-ready Postgres API server and open source database API provides high-level abstractions for building scalable REST APIs with advanced query building, schema management, bulk operations, database migrations, and performance optimization.
Overview
go-postgres-rest is an enterprise-grade Postgres database API and Golang REST API toolkit that significantly reduces development overhead when building REST APIs backed by PostgreSQL. This comprehensive Postgres API generator and Golang Postgres toolkit eliminates the need for manual SQL query construction and database connection management by providing a high-level, type-safe service layer with advanced capabilities including query building, schema introspection, bulk operations, and automated performance optimization as a golang rest api postgres framework, an open source postgres rest stack, with golang postgres rest workflows, a golang database api layer, an auto generated rest api, and a postgres api toolkit for production services.
Features
Architecture
-
Go 1.23+, idiomatic design
- Modern Go practices and idioms
- Clean, readable code
- Efficient use of Go features
-
Modular, testable codebase
- Five specialized services (Table, Bulk, Migration, Performance, Relationship) that handle distinct concerns
- Clean separation between business logic (services) and data access (repositories) for testability and maintainability
- Easy to mock for testing
- Supports multiple database backends (PostgreSQL now, extensible for others)
Installation
go get github.com/aptlogica/go-postgres-rest
Configuration
See .env.example for environment variables and configuration options.
Quick Start
package main
import (
"context"
"log"
"github.com/aptlogica/go-postgres-rest/pkg/client"
"github.com/aptlogica/go-postgres-rest/pkg/config"
)
func main() {
// Initialize configuration
cfg := config.New()
cfg.DatabaseURL = "postgres://user:pass@localhost/dbname?sslmode=disable"
// Create client instance
client, err := client.New(cfg)
if err != nil {
log.Fatal("Failed to initialize client:", err)
}
defer client.Close()
// Example: Create a new record
ctx := context.Background()
result, err := client.Table("users").Insert(ctx, map[string]interface{}{
"name": "John Doe",
"email": "john@example.com",
})
if err != nil {
log.Fatal("Insert failed:", err)
}
log.Printf("Created record with ID: %v", result.ID)
}
Development
Local Development
- Clone the repository:
git clone https://github.com/aptlogica/go-postgres-rest.git
- Install dependencies:
go mod download
- Start local development server:
go run ./cmd
- Run with Docker:
docker-compose up --build
Environment Setup
Copy .env.example to .env and configure your database settings:
DATABASE_URL=postgres://user:password@localhost:5432/dbname?sslmode=disable
PORT=8080
LOG_LEVEL=info
Testing
- Run
go test ./... to execute unit tests
Security
See SECURITY.md for reporting vulnerabilities.
License
MIT License. Copyright (c) 2026 Aptlogica Technologies.