Platformatic

repository·main·Indexed 24 days ago

https://github.com/platformatic/platformatic

A high-performance Node.js application server and framework featuring Watt, which runs applications as worker threads for improved scalability and stability. It includes a suite of packages for API gateway management (OpenAPI composition and GraphQL federation), database integration (@platformatic/db-core), inter-thread communication (@platformatic/itc), and integrations for Astro, NestJS, Vite, and TanStack.

Tokens
242.5K
Snippets
513
Records
1.2K
Agent score
64%

What's inside Platformatic

  1. What is Watt and why use it?

    main

    Watt is Platformatic's flagship Node.js Application Server designed to unify the management of databases, APIs, and frontend frameworks into a single application server. Instead of managing fragmented tools for monitoring, deployment, and orchestration, Watt provides a single runtime that handles infrastructure concerns like observability and microservice orchestration.

    Key Capabilities:

    • Database APIs: Auto-generated REST and GraphQL endpoints from SQL databases.
    • HTTP Applications: Custom logic built on Fastify.
    • API Gateways: Aggregation of multiple applications into unified endpoints.
    • Framework Integration: Support for Astro, Next.js, Nitro, Nuxt, React Router, Remix, TanStack Start, Vite, and NestJS.
    • Built-in Authorization: Role-based access control and JWT authentication.
    • Real-time Features: WebSocket and GraphQL subscriptions.
    • Observability: Built-in structured logging, Prometheus metrics, and OpenTelemetry tracing.
  2. Overview of @platformatic/gateway

    main

    Platformatic Gateway is an API gateway designed to aggregate and expose multiple services through a single API. It provides specialized support for:

    • OpenAPI composition: Combining multiple OpenAPI specifications into a unified interface.
    • GraphQL federation: Aggregating multiple GraphQL services into a single federated graph.
  3. What is Watt?

    main
    Watt is a Node.js Application Server designed to integrate multiple Node.js applications and frontend frameworks into a single unified system. It acts as a unified runtime that manages APIs and frontends (like React or Next.js) within a single process, providing built-in observability and simplified deployment. It is conceptually similar to Docker Compose for Node.js applications but optimized for speed, simplicity, and production-ready monitoring.
  4. Key features of Watt

    main

    Watt provides several built-in capabilities for managing Node.js applications:

    • Automatic multithreading: Optimizes resource allocation automatically via a single command.
    • Comprehensive NFR management: Abstracts non-functional requirements (NFRs) such as logging, tracing, and resource allocation.
    • Integrated OpenTelemetry tracing: Provides built-in OpenTelemetry support for real-time monitoring and performance insights.
    • Unified logging with Pino: Uses Pino to ensure structured logging across all managed applications.
  5. Explore Platformatic How-to Guides

    main

    Platformatic provides a comprehensive set of practical guides categorized by development stage and operational needs. Use these guides to solve specific implementation problems, ranging from initial application building to advanced deployment and monitoring.

    Guide Categories:

    • Application Development: Includes building modular monoliths, generating TypeScript frontend clients for REST APIs, integrating Node.js configuration, and using Watt with AI coding agents.
    • Caching & Performance: Covers caching strategies with Watt, profiling applications, capturing flamegraphs during health events, and interactive debugging via REPL.
    • Multi-Repository & Scaling: Guides for managing multiple repositories, choosing between pyramid and funnel architectures, and implementing schedulers for background jobs.
    • Framework Integration: Explains framework capabilities and integration with popular frontend/backend frameworks, including running Next.js Image Optimizer as a dedicated service.
    • Deployment & Operations: Instructions for Dockerizing Watt apps, configuring Kubernetes readiness/liveness probes, deploying TypeScript applications, and deploying Next.js in Kubernetes.
    • Monitoring & Observability: Covers logging configuration (including Elasticsearch integration), metrics with Prometheus and Grafana, and distributed tracing across microservices.
    • Management & Tools: Mastery of the Platformatic CLI tools.
  6. Use the Programmatic API to control Platformatic from Node.js

    main

    The @platformatic/runtime package allows you to start, control, and inspect Platformatic applications (including service, db, gateway, and runtime types) directly from Node.js code without using the CLI. This is ideal for writing tests, custom tooling, or embedding Platformatic within another application.

    To use the API, you typically use create() to build a Runtime instance and then manage its lifecycle using methods like start() and close().

    import { create } from '@platformatic/runtime'
    
    const app = await create('path/to/platformatic.runtime.json')
    const entrypointUrl = await app.start()
    
    const res = await fetch(entrypointUrl)
    console.log(await res.json())
    
    await app.close()
  7. Use Platformatic Runtime for microservice orchestration

    main

    Platformatic Runtime provides a unified environment to run multiple Platformatic microservices as a single monolithic deployment unit. This is ideal for streamlined development and monorepo management.

    Key capabilities include:

    • Programmatic start: Start the runtime within tests or other applications.
    • Inter-application communication: Microservices can communicate via private message passing without binding to OS ports.
    • Optimized execution: Running as a Runtime application enables specific compile and runtime optimizations for performance and resource management.
  8. Features of the Database Service

    main

    The Database Service provides several automated capabilities for rapid API development:

    • Automatic API Generation: Generates complete REST/OpenAPI and GraphQL (including queries, mutations, and subscriptions) APIs from your schema.
    • Interactive Documentation: Provides access to APIs via Scalar (for REST) and GraphiQL IDE (for GraphQL).
    • Apollo Federation: Supports extending your API with federation.
    • Type Safety: Automatically generates TypeScript definitions based on your SQL tables.
    • Security: Supports JWT, Webhooks, HTTP Headers, and Role-Based Access Control (RBAC).
    • Extensibility: Allows adding custom functionality via Fastify plugins or executing raw SQL queries.