Architecture
An overview of the AInstein platform architecture, tech stack, and key design patterns.
The AInstein platform is built on a modern, scalable, and secure architecture designed to support a multi-tenant SaaS application. This document provides a high-level overview of the technology stack and key architectural concepts.
Application Structure
The platform is organized as a monorepo to share code and manage dependencies effectively across different parts of the application.
ainstein/
├── apps/
│ ├── app/ # Main Next.js application
│ ├── api/ # API server
│ ├── web/ # Marketing website
│ └── docs/ # Documentation
├── packages/
│ ├── auth/ # Clerk authentication wrapper
│ ├── collaboration/ # Liveblocks integration
│ ├── database/ # Prisma & database utilities
│ └── design-system/ # Shared UI componentsTechnology Stack
- Framework: Next.js 14 (App Router)
- Database: PostgreSQL with Prisma ORM
- Authentication: Clerk (multi-tenant)
- Real-time Collaboration: Liveblocks
- Editor: Novel (a Tiptap-based editor)
- UI: Tailwind CSS + Radix UI
- Deployment: Vercel
Key Architectural Concepts
Multi-Tenancy
The platform is designed from the ground up as a multi-tenant system with a clear user hierarchy:
- Super Admins: Can access and manage all data across the platform.
- Resellers: Manage their own set of client organizations.
- Clients/Organizations: The end-users of the platform's content and SEO tools.
Data is strictly isolated between tenants at the database level, and all operations are scoped to the user's organization.
Real-time Collaboration
We use Liveblocks to provide a real-time, collaborative editing experience. This includes live cursors, presence indicators, and synchronized document updates. The collaboration features are built into our custom AdvancedEditor component.
Editor Architecture
Our content editor is built on Novel, a modern, Tiptap-based editor that supports a wide range of features, including:
- Rich text editing with Markdown support
- AI-powered content generation
- Image uploads and media handling
- Slash commands for quick content insertion
AI Integration
AI features are integrated throughout the platform, from content generation to SEO analysis. The architecture is designed to be provider-agnostic, allowing for flexibility and scalability.
Security
Security is a core consideration in our architecture. We enforce strict data isolation, role-based access control, and server-side validation on all operations. Our authentication system, built on Clerk, is central to our security model.