Skip to content

NpgsqlRestAutomatic PostgreSQL Web Server

Create professional, high-performance HTTP REST APIs for PostgreSQL databases in minutes and generate type-safe client code automatically.

NpgsqlRest
NpgsqlRest Architecture - PostgreSQL at the center with automatic REST API, TypeScript generation, authentication, caching, and more

Clean PostgreSQL Architecture - PostgreSQL First Architecture - PostgreSQL Driven Architecture

  • โœ“ Schema as contract โ€” Tables, views, and functions become REST endpoints
  • โœ“ SQL comments as config โ€” Routes, auth, caching declared where the logic lives
  • โœ“ Types flow outward โ€” PostgreSQL types generate TypeScript clients automatically
  • โœ“ No middle tier โ€” No ORM mismatch, no N+1 queries, no boilerplate

Declarative Annotations โ€‹

Simple comment annotations turn PostgreSQL functions into fully-featured REST endpoints.

sql
-- REST endpoint with custom path and authentication
create function api.get_user(p_id int)
returns setof user_info as $$
select id, name, email, role from users where id = p_id;
$$ language sql;

comment on function api.get_user(int) is '
HTTP GET /users/{p_id}
@authorize admin, user
@cached
@cache_expires_in 300
@rate_limiter_policy standard
';

-- Server-Sent Events for real-time updates
comment on function live_notifications() is '
HTTP
@sse
';

-- File upload with validation
comment on function upload_image(json) is '
HTTP POST
@upload for file_system
@param _meta is upload metadata
@included_mime_types = image/*
';

-- Rate-limited public API
comment on function search(text) is '
HTTP GET /search
@allow_anonymous
@rate_limiter_policy fixed
@validate _query using required
';
โœ“Database-First Approach
โœ“Static Type Checking End-To-End
โœ“Declarative API Design
AI Estimate
55-85%
reduction in API development time across backend and frontend, plus ongoing maintenance savings
Real World Project
~7,300 LOC
lines of code saved with ~57% reduction in codebase size
AI Coding Assistants
1 Function
per feature โ€” the single-function approach means less context for AI, fewer hallucinations, faster iteration

Built for the AI Coding Era โ€‹

Traditional backends require AI to coordinate across 8-12 files per endpoint โ€” controllers, services, repositories, DTOs, mappers, DI configuration. One mistake in any layer breaks everything.

With NpgsqlRest, the AI needs exactly two things: your schema and one SQL function. That's the entire context.

  • โœ“ Schema is the full context โ€” dump it, hand it to any AI, start building
  • โœ“ SQL is the best-understood language โ€” LLMs have seen more SQL than any framework
  • โœ“ One artifact per feature โ€” no coordinating across layers, fewer hallucinations
  • โœ“ Instant verification โ€” test the function in psql, not through 7 layers of abstraction
SQL Functions vs DDD/ORM

Why fight the database when you can embrace it?

Blog โ€‹



Build, Test, Publish and ReleaseLicenseGitHub StarsGitHub ForksCrafted with Claude
โค๏ธ Support this project: Patreon ยท Buy Me a Coffee
Released under the MIT License.
Copyright ยฉ 2024-2026 VB Consulting