Architecture Overview
The BuildAppsWith platform follows a domain-driven architecture that separates concerns into clear domains, each responsible for a specific area of functionality.Core Architecture Principles
- Domain-Driven Design: Code is organized by business domain rather than technical function
- Separation of Concerns: Each module has a single responsibility
- Consistent File Structure: Standard file organization across domains
- Type Safety: Strict TypeScript interfaces for all data structures
Domain Structure
Each domain follows this standard file structure:Core Domains
The platform is divided into these primary domains:1. Authentication (auth)
Manages user authentication, authorization, and session management using Clerk.2. Marketplace
Facilitates builder discovery, profile management, and marketplace analytics. Learn more about Marketplace Architecture3. Scheduling
Handles booking sessions, availability management, and calendar integrations.4. Payment
Processes payments, manages subscriptions, and handles invoicing via Stripe.5. Profile
Manages user profiles, preferences, and account settings. Learn more about Profile Architecture6. Admin
Provides administrative tools and dashboards for platform management.Next.js Application Structure
The application uses Next.js’s App Router and follows this structure:Data Flow
The application follows a clear data flow pattern:- UI Components call client-side API functions from
api.ts - API Functions make requests to API routes or use server actions
- API Routes/Server Actions use server-side service functions
- Service Functions interact with the database and external services
- Database stores and retrieves persistent data
Type System
The type system follows a hierarchy:- Domain Types in
types.tsdefine the core data structures - API Types extend domain types for specific API needs
- Component Props use domain and API types
- Database Schema (Prisma) aligns with domain types
Nx Integration
The platform is transitioning to an Nx monorepo structure with:- Apps: Next.js applications
- Libraries: Shared functionality organized by domain
Best Practices
When working with the BuildAppsWith architecture:-
Use Barrel Exports: Import through the domain’s index.ts
- Maintain Domain Boundaries: Keep functionality within the appropriate domain
- Follow Type Definitions: Ensure all data structures match defined types
- Document with JSDoc: Add JSDoc comments to functions and interfaces