Skip to content

About

Node.js TypeScript API backed by PostgreSQL, with GraphQL, REST, Swagger, Zod validation, filtering, pagination, sorting, request logging, and centralized error handling.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

Β 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 NodeMovieApi

TypeScript Node.js Express GraphQL PostgreSQL

A TypeScript-based backend API demonstrating REST + GraphQL parity, advanced filtering, and PostgreSQL-powered query logic.


πŸŽ₯ Architecture Walkthrough

Postgres Movie Platform Walkthrough

🎬 Demo

Yoga - GraphQL

Fetch And Update Movies

πŸ” Fetch Movies

Fetch Movies

✨ Create Movie

Create Movie

✏️ Update Movie

Update Movie

🩹 Patch Movie

Patch Movie

πŸ—‘οΈ Delete Movie

Delete Movie


⭐ Key Concept

This project demonstrates how REST and GraphQL can share the same repository layer and PostgreSQL functionsβ€”avoiding duplicated business logic while supporting multiple API paradigms.

🎯 Why This Project Exists

Modern applications often need to support multiple API paradigms at the same time.

This project was built to demonstrate how REST and GraphQL APIs can coexist while sharing the same PostgreSQL function layer and repository architecture.

The goal was to show:

  • reusable backend architecture
  • centralized business logic
  • API flexibility
  • scalable query patterns
  • production-minded TypeScript organization

Rather than duplicating logic across separate APIs, both REST and GraphQL share the same repository and PostgreSQL query layer, keeping the system predictable, maintainable, and easier to evolve.


πŸ—οΈ Platform Architecture

flowchart TD

subgraph UI["🎨 Frontend Layer"]
  ReactUI["React Movie Dashboard<br/>Filtering β€’ CRUD β€’ API Toggle"]
end

subgraph API["βš™οΈ API Layer"]
  NodeAPI["NodeMovieApi<br/>TypeScript β€’ Express<br/>REST + GraphQL"]
  DotNetAPI["DotNetMovieApi<br/>.NET Minimal APIs β€’ C#<br/>REST + GraphQL"]
end

subgraph DATA["🐘 Data Platform Layer"]
  Functions["PostgreSQL Function Layer<br/>Filtering β€’ Paging β€’ Sorting β€’ CRUD"]
  Tables["Relational Model<br/>movies β€’ genres β€’ movie_genres"]
end

ReactUI --> NodeAPI
NodeAPI --> Functions
Functions --> Tables

ReactUI -. Alternative implementation .-> DotNetAPI
DotNetAPI -. Shares same data layer .-> Functions

classDef frontend fill:#e0f2fe,stroke:#0284c7,stroke-width:2px,color:#0f172a;
classDef primaryApi fill:#dcfce7,stroke:#16a34a,stroke-width:3px,color:#0f172a;
classDef secondaryApi fill:#f3f4f6,stroke:#9ca3af,stroke-width:1px,color:#374151;
classDef data fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#0f172a;

class ReactUI frontend;
class NodeAPI primaryApi;
class DotNetAPI secondaryApi;
class Functions,Tables data;
Loading

This repository is the Node.js / TypeScript implementation of a multi-stack movie platform that shares a common PostgreSQL function layer with the .NET API.

πŸ”„ Request Lifecycle

sequenceDiagram
    participant UI as React Dashboard
    participant API as NodeMovieApi
    participant Repo as Repository Layer
    participant PG as PostgreSQL Functions

    UI->>API: REST or GraphQL request

    alt REST
        API->>API: Express route handler
    else GraphQL
        API->>API: GraphQL resolver
    end

    API->>Repo: Shared repository call

    Repo->>PG: Execute PostgreSQL function

    PG-->>Repo: Query results

    Repo-->>API: Typed response

    API-->>UI: JSON / GraphQL response
Loading

βš™οΈ Tech Stack

  • Node.js + TypeScript
  • Express 5
  • PostgreSQL (reusable SQL function layer)
  • GraphQL Yoga
  • Swagger / OpenAPI
  • Zod (validation)
  • Pino (structured logging)

πŸš€ Features

  • Full CRUD for movies (REST + GraphQL)
  • Advanced filtering, sorting, and pagination
  • Shared repository layer across REST and GraphQL
  • PostgreSQL-backed query logic via functions
  • Centralized error handling with correlation IDs
  • Request logging and CORS support
  • Swagger UI for REST exploration

πŸ“‘ API Overview

REST

  • GET /movies
  • GET /movies/{id}
  • POST /movies
  • PUT /movies/{id}
  • PATCH /movies/{id}
  • DELETE /movies/{id}
  • GET /genres
  • GET /genres/{id}
  • GET /health

πŸ‘‰ Swagger UI: http://localhost:5001/swagger


GraphQL

  • GET /graphql
  • POST /graphql

Example Query

query {
  movies(filters: { search: "avatar", searchMode: "general", page: 1, pageSize: 10 }) {
    items {
      id
      movieName
      releaseDate
      genres
    }
    totalCount
    totalPages
  }
}

Example Mutation

mutation {
  updateMovie(
    id: "00000000-0000-0000-0000-000000000000"
    patch: { movieName: "Updated Title", genreNames: ["Action", "Sci-Fi"] }
  ) {
    id
    movieName
    genres
    updatedAt
  }
}

🧠 Query Capabilities

The /movies endpoint supports:

  • Search (general, starts, ends, contains)
  • Pagination (page, pageSize)
  • Sorting (sortBy, sortDirection)
  • Date range filtering
  • Financial filters (budget, gross)
  • Genre filtering

πŸ› οΈ Running Locally

Requirements

  • Node.js
  • PostgreSQL

Setup

npm install
npm run dev

Environment

NODE_ENV=development
PORT=5001
CORS_ALLOW_ORIGINS=http://localhost:5173,http://localhost:3000
POSTGRES_CONNECTION_STRING=postgresql://user:password@localhost:55432/wickers_db

πŸ“ Project Structure

src/
β”œβ”€β”€ graphql/        # GraphQL schema + resolvers
β”œβ”€β”€ repositories/   # Shared data access layer
β”œβ”€β”€ routes/         # REST endpoints
β”œβ”€β”€ middleware/     # Logging, errors, CORS
β”œβ”€β”€ validation/     # Zod validation schemas
β”œβ”€β”€ db/             # PostgreSQL integration
β”œβ”€β”€ types/          # Shared TypeScript types
└── server.ts       # App entry point

πŸ”— Related Projects

ASP.NET Core Minimal API implementation built on top of the Postgres Movie Platform, exposing shared PostgreSQL functions through REST and GraphQL endpoints. Project

React + TypeScript frontend application showcasing REST and GraphQL integration, advanced filtering, pagination, sorting, and reusable UI architecture. Project

🧠 DevAssist-AI

Production-minded Retrieval-Augmented Generation (RAG) application using OpenAI embeddings, semantic retrieval, and centralized AI orchestration workflows. Project

Centralized PostgreSQL data platform featuring Dockerized infrastructure, overloaded SQL functions, reusable query architecture, and shared business logic powering multiple APIs and applications. Project


πŸ’‘ Highlights

  • Demonstrates real-world backend architecture patterns
  • Demonstrates GraphQL + REST parity without duplicated business logic
  • Uses PostgreSQL functions for complex querying
  • Designed as a portfolio-ready API demonstrating production-minded engineering concerns

🧠 Production-Minded Engineering

This project emphasizes:

  • centralized query logic
  • reusable repository patterns
  • API consistency
  • scalable filtering and pagination
  • separation of concerns
  • typed validation with Zod
  • structured logging
  • PostgreSQL-backed business logic

The architecture is designed to support multiple API consumers while keeping the underlying data access predictable and maintainable.

πŸš€ Future Enhancements

  • Authentication (JWT)
  • Rate limiting
  • Dockerized full-stack environment
  • C# API parity

πŸ“¬ Contact

πŸ‘¨β€πŸ’» Author

Steven Wickers Senior Frontend Engineer

React β€’ TypeScript β€’ Node.js β€’ C# β€’ PostgreSQL β€’ Cloud


πŸ” Keywords

Node.js API, TypeScript backend, PostgreSQL, GraphQL, REST API, Swagger, OpenAPI, backend architecture

About

Node.js TypeScript API backed by PostgreSQL, with GraphQL, REST, Swagger, Zod validation, filtering, pagination, sorting, request logging, and centralized error handling.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages