Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

funish/vertex

Repository files navigation

Funish Vertex - A Multi-Organization Developer Platform with Better Auth

For AI Developers: This document is the core reference for the Funish Vertex project. Please read it thoroughly before starting development.

🎯 Project Overview

Project Positioning

Funish Vertex is an enterprise-grade, multi-organization developer platform built on Better Auth. It leverages a plugin-based architecture to provide a complete infrastructure solution for modern applications. The platform features a dual-layer authentication architecture: a platform layer manages organizations and users, while each organization is provided with its own independent, configurable Better Auth instance and plugin ecosystem.

Core Features

  • Dual-Layer Authentication: Platform management + isolated Better Auth instances for each organization.
  • Plugin-Powered Ecosystem: Functional extensions based on the Better Auth plugin system.
  • Multi-Organization Isolation: Complete isolation of data, storage, and configuration between organizations.
  • Flexible Configuration: Organizations can freely enable, disable, and configure the plugins they need.
  • Unified API: Standardized RESTful API design.

Technology Stack

  • Authentication Framework: Better Auth (Core) + Custom Plugin Ecosystem
  • Frontend: Nuxt 4 + Vue 3 + UnoCSS + PrimeVue
  • Backend: Nitro (API Gateway) + Better Auth (Authentication)
  • Database: Kysely (ORM) + PostgreSQL + Dynamic Schema Management
  • Storage: Unstorage (Multi-Driver Abstraction) + Storage Server
  • AI Integration: Vercel AI SDK + Provider Registry

πŸ—οΈ System Architecture

Architectural Layers

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Platform Layer β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Platform β”‚ β”‚ Universal Plugin Registry β”‚ β”‚
β”‚ β”‚ Configuration β”‚ β”‚ βœ“ Storage Plugin β”‚ β”‚
β”‚ β”‚ - Base Plugins β”‚ β”‚ βœ“ Database Plugin β”‚ β”‚
β”‚ β”‚ - Global Rules β”‚ β”‚ βœ“ AI Router Plugin β”‚ β”‚
β”‚ β”‚ - Rate Limits β”‚ β”‚ βœ“ ...and other official plugins β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 β”‚ (Provides)
 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Organization Layer β”‚
β”‚ Organization A Organization B Organization C β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Org A Config β”‚ β”‚ Org B Config β”‚ β”‚ Org C Config β”‚ β”‚
β”‚ β”‚ β”œ + Storage(S3) β”‚ β”‚ β”œ + Storage(R2) β”‚ β”‚ β”œ + Database β”‚ β”‚
β”‚ β”‚ β”” + AI Router β”‚ β”‚ β”” + Analytics β”‚ β”‚ β”” + AI Routerβ”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 β”‚ (Configures)
 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Runtime Instances β”‚
β”‚ Better Auth Instance A Better Auth Instance B etc. β”‚
β”‚ (Platform + Org A Config) (Platform + Org B Config) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Plugin Ecosystem

Our platform is built around a powerful plugin system, managed by our Plugin Registry. This registry allows administrators to discover, enable, and configure plugins for each organization.

  • Gateway Plugin: A comprehensive API gateway that provides routing, rate limiting, and API key authentication.
  • Storage Plugin: Based on unstorage, providing multi-driver support (S3, R2, etc.) and tenant-isolated storage.
  • Database Plugin: Based on Kysely, allowing for dynamic, isolated database schemas per organization.
  • AI Router Plugin: Based on the Vercel AI SDK, enabling routing to multiple AI providers like OpenAI, Anthropic, and Groq.
  • ...and many more, including official Better Auth plugins for payments, analytics, etc.

πŸ—„οΈ Data Architecture

  • Platform-Level Data: Manages core tables for user, session, organization, and organization_plugin_config.
  • Organization-Level Data: Each organization gets its own database schema (e.g., org_123_schema), ensuring complete data isolation. Plugin-specific tables are created within this schema when a plugin is enabled.

πŸ“š Documentation

For Developers

For Contributors

πŸ“š API Design

/api/v1/
β”œβ”€β”€ platform/ # Platform Management API
β”‚ β”œβ”€β”€ auth/ # Platform-level authentication
β”‚ └── plugins/ # Plugin Registry discovery
└── {orgId}/ # Organization-specific API
 β”œβ”€β”€ auth/ # Organization-level authentication
 └── ... # Plugin-specific routes (e.g., /storage/*)

πŸš€ Development Progress

Phase 1: Core Architecture (βœ… Completed)

  • Project initialization and documentation design
  • Better Auth platform-level setup
  • Plugin Registry architecture design and implementation
  • Multi-organization dynamic schema management
  • Basic API framework

Phase 2: Core Plugin Development (βœ… Completed)

  • Storage Plugin (Unstorage integration)
  • Database Plugin (Kysely integration)
  • AI Router Plugin (Vercel AI SDK integration)
  • Gateway Plugin (Routing, Rate Limiting, API Keys)
  • Tenant Plugin (Multi-organization support)
  • Permission Plugin (Access control and role management)

Phase 3: Frontend Development (πŸ”„ In Progress)

  • Better Auth Vue client setup
  • Basic authentication middleware
  • Authentication UI components (Login, Register, etc.)
  • Organization management interface
  • Plugin marketplace UI
  • Dashboard and admin panels

⚠️ Development Guidelines

  1. Align with Better Auth: All plugins must be compatible with the BetterAuthPlugin interface.
  2. Type Safety: Use TypeScript strict mode and avoid any.
  3. Organization Isolation: Ensure complete data and configuration isolation between organizations.
  4. API Versioning: Maintain stable and versioned APIs.

Key Implementation Concepts

1. Dynamic betterAuth Instance Creation

// Simplified example from server/utils/auth.ts
import { betterAuth } from "better-auth";
import { getEnabledPlugins } from "@funish/vertex/plugins/registry";
// Factory function to create a Better Auth instance for a specific organization
export const createAuthForOrganization = async (orgId: string) => {
 const allPluginConfigs = await loadAllOrgPluginConfigsFromDB();
 const { server: serverPlugins } = getEnabledPlugins(orgId, allPluginConfigs);
 return betterAuth({
 // ... base config
 plugins: serverPlugins, // Pass the dynamically instantiated plugins
 });
};

2. Plugin Registration

// Simplified example from packages/vertex/src/plugins/registry/register.ts
import { globalPluginRegistry } from "./registry";
import { storagePluginDefinition } from "../storage";
// Register all built-in plugins on startup
export function registerBuiltinPlugins() {
 globalPluginRegistry.register(storagePluginDefinition);
 // ... register other plugins
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /