Platformatic
repository·main·Indexed 24 days ago
https://github.com/platformatic/platformaticA 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.
What's inside Platformatic
- The Platformatic DB OpenAPI plugin automatically starts a REST API server powered by Fastify. This server provides full CRUD (Create, Read, Update, Delete) functionality for each entity defined in your database configuration.
What is Watt and why use it?
mainWatt 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.
Overview of @platformatic/gateway
mainPlatformatic 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.
What is Watt?
mainWatt 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.Overview of Watt (wattpm)
mainWatt is Platformatic's Node.js application server designed to centrally manage multiple Node.js applications. It provides a virtual mesh network and built-in integrations for:
- Logging: Fast logging via Pino.
- Monitoring: Integration with Prometheus.
- Observability: OpenTelemetry support.
Watt is compatible with popular web frameworks including Next.js, Astro, Express, and Fastify.
What is @platformatic/sql-events?
mainThe@platformatic/sql-eventspackage allows you to emit entity change events whenever database records are created, updated, or deleted. It uses MQEmitter as the underlying mechanism for event emission. For detailed configuration and usage, refer to the official documentation.Use Platformatic DB GraphQL
mainThe Platformatic DB GraphQL plugin starts a GraphQL server and exposes it via the/graphqlendpoint. This endpoint allows you to execute queries and mutations against your defined entities. The plugin is powered by Mercurius.Key features of Watt
mainWatt 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.
Explore Platformatic How-to Guides
mainPlatformatic 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.
Use the Programmatic API to control Platformatic from Node.js
mainThe
@platformatic/runtimepackage allows you to start, control, and inspect Platformatic applications (includingservice,db,gateway, andruntimetypes) 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 aRuntimeinstance and then manage its lifecycle using methods likestart()andclose().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()Use Platformatic Runtime for microservice orchestration
mainPlatformatic 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.
Features of the Database Service
mainThe 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.