API Integration Overview
API Integration Overview
Section titled “API Integration Overview”Introduction
Section titled “Introduction”The banyan-core platform automatically generates external-facing APIs from your service contracts with zero configuration. Services expose their functionality through REST, GraphQL, and WebSocket endpoints without writing any HTTP code.
Core Philosophy
Section titled “Core Philosophy”Services never handle HTTP. They define contracts, and the API Gateway automatically:
- Generates RESTful endpoints
- Creates GraphQL schemas
- Establishes WebSocket subscriptions
- Handles authentication and rate limiting
- Manages protocol translation to RabbitMQ
Available API Protocols
Section titled “Available API Protocols”REST API
Section titled “REST API”- Auto-generated RESTful endpoints from command and query contracts
- Standard HTTP methods (GET, POST, PUT, DELETE)
- Resource-based URLs following REST conventions
- JSON request/response bodies
- Available at
http://localhost:3003/api/*
GraphQL API
Section titled “GraphQL API”- Dynamic schema generation from contracts
- Permission-filtered queries and mutations
- Type-safe operations with auto-generated types
- Introspection and GraphiQL playground
- Available at
http://localhost:3003/graphql
WebSocket API
Section titled “WebSocket API”- Real-time event subscriptions for domain events
- Bi-directional communication
- Automatic reconnection and error handling
- Correlation ID propagation for tracing
- Available at
ws://localhost:3003/ws
How It Works
Section titled “How It Works”External Client (REST/GraphQL/WebSocket) ↓API Gateway (Port 3003) ↓ Protocol TranslationRabbitMQ Message Bus ↓Service Handler (Pure Business Logic)Request Flow
Section titled “Request Flow”- Client makes HTTP/GraphQL/WS request to API Gateway
- API Gateway validates authentication and permissions
- Gateway translates protocol to RabbitMQ message
- Message routed to target service via message bus
- Service handler processes business logic
- Response flows back through same path
Key Benefits
Section titled “Key Benefits”- Zero HTTP code in services - only domain logic
- Automatic API generation from contracts
- Type safety end-to-end with TypeScript
- Protocol independence - services don’t know about REST/GraphQL
- Automatic documentation via OpenAPI and GraphQL introspection
- Built-in observability with distributed tracing
API Gateway Port
Section titled “API Gateway Port”All external APIs are served on port 3003:
# REST APIhttp://localhost:3003/api/users
# GraphQL APIhttp://localhost:3003/graphql
# WebSocket APIws://localhost:3003/wsAuthentication
Section titled “Authentication”All API requests must include authentication:
# JWT Bearer tokencurl -H "Authorization: Bearer eyJhbGc..." \ http://localhost:3003/api/usersSee API Security for authentication details.
Rate Limiting
Section titled “Rate Limiting”API Gateway enforces rate limits per user:
- 100 requests per minute for authenticated users
- 10 requests per minute for anonymous users
- 429 Too Many Requests when limit exceeded
See API Security for rate limit configuration.
API Documentation
Section titled “API Documentation”OpenAPI/Swagger
Section titled “OpenAPI/Swagger”Auto-generated REST API documentation:
http://localhost:3003/api-docsGraphQL Playground
Section titled “GraphQL Playground”Interactive GraphQL explorer:
http://localhost:3003/graphqlNext Steps
Section titled “Next Steps”- REST API Guide - Building RESTful endpoints
- GraphQL API Guide - Creating GraphQL schemas
- API Contracts - Defining public contracts
- API Security - Authentication and authorization