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.
go-postgres-rest is a Golang-based REST API service that provides a scalable and secure interface for interacting with PostgreSQL databases. It enables automatic exposure of database tables as REST endpoints, allowing applications to perform CRUD operations through simple HTTP requests. Designed for modern backend architectures, it helps developers rapidly build data-driven applications, internal tools, and low-code platforms while maintaining high performance and full control over database structure. This service simplifies backend development by transforming PostgreSQL into a flexible API layer that integrates seamlessly with web, mobile, and cloud applications.This service is designed to support modern data-driven applications, low-code platforms, and internal tools by simplifying database access through standardized HTTP APIs. It allows developers and teams to quickly build backend functionality while maintaining flexibility, performance, and full control over their data.
-
Advanced Query Builder
- Programmatic construction of complex SQL queries with filtering, sorting, pagination, and joins
- Type-safe query building without string concatenation
- Complex WHERE clauses with AND/OR logic support
- Multi-column sorting capabilities
- Efficient pagination with limit/offset
- Dynamic column selection
- Comprehensive JOIN operations (inner, left, right)
- GROUP BY with aggregation functions
- HAVING clause support
- Nested subquery capabilities
- Auto-generated REST API for Postgres with Postgres backend service functionality
- Efficient pagination with limit/offset
- Dynamic column selection
- Comprehensive JOIN operations (inner, left, right)
- GROUP BY with aggregation functions
- HAVING clause support
- Nested subquery capabilities
-
Schema Management and Migrations
- Create, alter, and introspect database schemas without writing DDL SQL
- Schema version tracking
- Up/down migration support
- Automatic migration table creation
- Migration history and rollback
- Safe, transactional migrations
-
Bulk Operations and Relationship Management
- Transactional bulk insert operations for high-throughput scenarios
- Upsert capabilities with conflict resolution strategies
- Optimized bulk update and delete operations
- Atomic transaction management ensuring data consistency
- Comprehensive relationship modeling (one-to-one, one-to-many, many-to-many)
- Automated join table creation and management
- Foreign key constraint enforcement
- Configurable cascade delete operations
- Runtime relationship introspection
-
Performance Optimization
- Intelligent automatic indexing on foreign key relationships
- Dynamic index creation for frequently queried columns
- Custom index management with performance monitoring
- Comprehensive query performance analytics
- Configurable connection pooling with health monitoring
- Prepared statement caching for optimal execution times
-
Production Features
- Connection pooling with configurable limits
- Transaction management
- Context support for cancellation
- Comprehensive error handling
- Structured logging
- Health check endpoints
- Docker and docker-compose ready
- 80%+ test coverage
-
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)
go get github.com/aptlogica/go-postgres-restSee .env.example for environment variables and configuration options.
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)
}- 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
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- Run
go test ./...to execute unit tests
See SECURITY.md for reporting vulnerabilities.
MIT License. Copyright (c) 2026 Aptlogica Technologies.