An open API service indexing awesome lists of open source software.

https://github.com/maevsi/postgraphile

Vibetype's backend interface.
https://github.com/maevsi/postgraphile

Last synced: about 2 months ago
JSON representation

Vibetype's backend interface.

Awesome Lists containing this project

README

          

# πŸš€ @maevsi/postgraphile

> A blazing-fast GraphQL API layer for PostgreSQL, powering the Vibetype event community platform.

## Overview

This is a production-ready **PostGraphile v5** server that automatically generates a powerful GraphQL API directly from your PostgreSQL schema. It's a core service of the [Vibetype](https://github.com/maevsi/vibetype) platform, seamlessly converting database changes into a secure, performant GraphQL interface.

### ✨ Key Features

- **πŸ”„ Auto-Generated GraphQL API**: Full CRUD operations from your PostgreSQL schema
- **🌍 PostGIS Support**: Built-in geospatial capabilities with `@graphile/postgis`
- **πŸ” JWT Authentication**: ES256 ECDSA-signed tokens with claim-based authorization
- **⚑ Grafast Optimizations**: Deep SQL query optimization and N+1 prevention
- **🎨 Amber Preset**: Sensible defaults for a modern development experience
- **πŸ“¦ TypeScript Ready**: Full type safety from database to API
- **🐳 Docker Native**: Containerized with automatic pnpm setup

## Quick Start

### Prerequisites

**Node.js**, **PostgreSQL** with Vibetype schema migrations applied via [sqitch](https://github.com/maevsi/sqitch), and **pnpm**.

### Development

```bash
pnpm install # Install dependencies
pnpm run lint # Lint code

# Docker
docker build -t maevsi/postgraphile .
```

## Architecture

This service is part of the **Vibetype platform**, an event community ecosystem:

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Frontend (Nuxt) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ GraphQL
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ GraphQL API (PostGraphile) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ SQL queries and mutations
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Database (PostgreSQL) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–²β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ SQL schema
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Migrations (Sqitch) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

See [maevsi/stack](https://github.com/maevsi/stack) for the full Docker setup.

## Project Structure

```
src/
β”œβ”€β”€ graphile.config.ts # Main PostGraphile configuration
β”œβ”€β”€ graphile.ts # Scripted logic
└── environment.ts # Type-safe environment utilities
```

### Authentication

Authentication uses ES256 (ECDSA) for signing JWTs; tokens use `postgraphile` as both issuer and audience and are represented in PostgreSQL by the composite type `vibetype.jwt`.

The signing keys and related secrets are best configured via environment variables in [maevsi/stack](https://github.com/maevsi/stack).

### Docker

The included `docker-entrypoint.sh` automatically:
- Loads environment variables from `/run/environment-variables` (Docker secrets)
- Installs dependencies in development mode
- Passes control to the `postgraphile` command

## Resources

- πŸ“– [PostGraphile Documentation](https://www.graphile.org/postgraphile/)
- πŸ—ΊοΈ [PostGIS Reference](https://postgis.net/)
- 🐘 [PostgreSQL Docs](https://www.postgresql.org/docs/)
- πŸŽͺ [Vibetype Platform](https://github.com/maevsi/vibetype)
- πŸ—οΈ [Full Stack (Docker Compose)](https://github.com/maevsi/stack)

---

**Questions or Issues?** [Open an issue](https://github.com/maevsi/postgraphile/issues), we're here to help!