BaasixBaasix

BAASIX - Backend as a Source

Introduction

BAASIX is a powerful, flexible Backend as a Source (BaaS) platform that enables rapid development of web and mobile applications. It provides a comprehensive API for common backend functionality, allowing developers to focus on building frontend experiences without worrying about the underlying infrastructure.

This documentation is designed to be AI-friendly, with clear cross-links between conceptual guides and API references.

Key Features

  • Dynamic Database Management: Create and modify data models on the fly with a flexible schema system
  • Powerful Query API: Complex filtering, sorting, pagination, aggregation, and full-text search capabilities
  • Authentication & Authorization: Complete user management with JWT, cookie-based auth, and role-based permissions
  • Database Migrations: Version-controlled migrations with rollback support, auto-upgrade detection, and admin UI
  • Workflow Automation: Visual workflow builder with 17 node types, 4 trigger types, and real-time monitoring
  • Notification System: Built-in user notification system with real-time delivery via Socket.IO
  • File Storage & Processing: Upload, manage and transform files with image optimization and video metadata
  • PostGIS Geospatial Support: Advanced spatial data operations with PostGIS integration
  • Reporting & Analytics: Generate complex reports and statistics with grouping and aggregation
  • Hooks System: Extend functionality with custom hooks that trigger on specific events
  • Task Management System: Built-in background task coordination with caching and state management
  • Multi-tenant Architecture: Host multiple isolated client organizations within a single instance
  • Real-time Updates: Socket.IO integration with Redis clustering for live data synchronization
  • Caching System: Redis-based caching with configurable TTL for improved performance
  • Rate Limiting & Security: Comprehensive security with CORS management and rate limiting
  • Pino Logger: High-performance structured logging with configurable transports (Datadog, Loki, Elasticsearch)
  • Extensibility: Add custom endpoints, services, and business logic through extensions
  • AI Integration (MCP): Connect AI assistants like Claude, GitHub Copilot, and Cursor directly to your backend

Documentation

JavaScript SDK

The official TypeScript/JavaScript SDK for web, Node.js, and React Native applications:

  • JavaScript SDK Guide - Complete SDK documentation with TypeScript support, realtime subscriptions, and all modules

👉 npm: @baasix/sdk | GitHub

npm install @baasix/sdk

Shared Types Package

The @baasix/types package provides shared TypeScript type definitions for SDK, plugin development, and API integration:

👉 npm: @baasix/types

npm install @baasix/types

Includes types for:

  • Authentication (User, Role, Permission, Accountability)
  • Query operations (Filter, Sort, QueryParams, Aggregation)
  • Schema definitions (FieldDefinition, RelationshipType)
  • Plugin development (PluginDefinition, PluginContext, Service interfaces)
  • Files, Workflows, Spatial data (GeoJSON), and more

Command-Line Interface (CLI)

The official CLI for project scaffolding, type generation, and migrations:

  • CLI Guide - Complete CLI documentation with all commands

👉 npm: baasix

# Install globally
npm install -g baasix

# Or use with npx
npx baasix init

Key Features:

  • baasix init - Interactive project scaffolding with API, Next.js templates
  • baasix generate - Generate TypeScript types from schemas
  • baasix extension - Scaffold hooks, endpoints, and schedules
  • baasix migrate - Run database migrations

Core Concepts

API Routes Documentation

AI Integration

Setup and Deployment

Quick Start

Prerequisites

  • Node.js (v18+)
  • PostgreSQL (v14+) with PostGIS extension
  • Redis (v6+)
  • npm or yarn

Installation

  1. Create a new project:

    mkdir my-baasix-app
    cd my-baasix-app
    npm init -y
  2. Install Baasix:

    npm install @baasix/baasix
  3. Create server.js:

    import { startServer } from '@baasix/baasix';
    
    startServer().catch((error) => {
      console.error('Failed to start server:', error);
      process.exit(1);
    });
  4. Update package.json to use ES modules:

    {
      "type": "module"
    }
  5. Configure environment variables (create a .env file):

    # Database connection
    DATABASE_URL="postgresql://postgres:postgres@localhost:5432/baasix"
    
    # Authentication
    SECRET_KEY=your-secret-key-min-32-chars
    
    # Server
    PORT=8056
    
    # Cache (optional - defaults to memory)
    # CACHE_ADAPTER=redis
    # CACHE_REDIS_URL=redis://localhost:6379
  6. Start the server:

    npm run dev

Visit http://localhost:8056/ to verify the server is running.

Sample Project

For a complete working example with all deployment configurations (Docker, PM2, Kubernetes), check out our sample repository:

👉 github.com/baasix/baasix/samples/sample

Production Deployment

For detailed deployment instructions including Docker, PM2, Kubernetes, and manual server setup, see the Deployment Guide.

Configuration Options

BAASIX can be configured through environment variables. Here are the most important ones:

Core Configuration

VariableDescriptionDefault
NODE_ENVApplication environmentdevelopment
PORTServer port8056
SECRET_KEYJWT secret key (min 32 chars)-
LOG_LEVELLog level (fatal/error/warn/info/debug/trace)info

Database Configuration

VariableDescriptionDefault
DATABASE_URLPostgreSQL connection URL-
DATABASE_MAX_RETRYConnection retry attempts3
DATABASE_POOL_MAXMax pool connections20
DATABASE_POSTGISEnable PostGIS extensionfalse

Cache Configuration

VariableDescriptionDefault
CACHE_ENABLEDEnable cachingtrue
CACHE_ADAPTERCache adapter (memory/redis/upstash)memory
CACHE_REDIS_URLRedis connection URL-
CACHE_TTLCache TTL in seconds300

Security & CORS

VariableDescriptionDefault
AUTH_CORS_ALLOWED_ORIGINSAllowed CORS origins (comma-separated)localhost:8056
AUTH_CORS_ALLOW_ANY_PORTAllow any port for CORSfalse
RATE_LIMITMax requests per window100
RATE_LIMIT_INTERVALRate limit window (ms)5000
RATE_LIMIT_BY_USERRate limit by user ID instead of IP (for authenticated users)false

Features

VariableDescriptionDefault
MULTI_TENANTEnable multi-tenant modefalse
SOCKET_ENABLEDEnable Socket.IOfalse
PUBLIC_REGISTRATIONAllow public user registrationtrue

For complete configuration options, see the Deployment Guide.

Examples

Creating a Schema

POST /schemas
Content-Type: application/json
Authorization: Bearer <token>

{
  "collectionName": "products",
  "schema": {
    "name": "Product",
    "timestamps": true,
    "fields": {
      "id": {
        "type": "UUID",
        "primaryKey": true,
        "defaultValue": {
          "type": "UUIDV4"
        }
      },
      "name": {
        "type": "String",
        "allowNull": false
      },
      "price": {
        "type": "Decimal",
        "values": {
          "precision": 10,
          "scale": 2
        }
      }
    }
  }
}

Creating an Item

POST /items/products
Content-Type: application/json
Authorization: Bearer <token>

{
  "name": "Awesome Product",
  "price": 19.99
}

Querying Items

GET /items/products?filter={"price":{"gt":10}}&sort={"price":"desc"}&fields=id,name,price&limit=20
Authorization: Bearer <token>

Security

BAASIX includes comprehensive security features:

  • JSON Web Token (JWT) authentication
  • Cookie-based authentication
  • Role-based access control (RBAC)
  • Field-level permissions
  • Conditional permissions using dynamic variables
  • Input validation and sanitization

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

On this page