# get-convex/turbo-expo-nextjs-clerk-convex-monorepo architecture

> Architecture diagram of the GitHub repository get-convex/turbo-expo-nextjs-clerk-convex-monorepo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/get-convex/turbo-expo-nextjs-clerk-convex-monorepo
- Repository: https://github.com/get-convex/turbo-expo-nextjs-clerk-convex-monorepo

## Overview

##### Main Components
- Frontend Web App (apps/web): Built with Next.js 14, TailwindCSS, and Clerk integration. It provides marketing pages, a dashboard, and note-taking functionality.
- Frontend Mobile App (apps/native): A React Native app using Expo that mirrors the functionality of the web app – dashboard, note-taking, and authentication.
- Backend (packages/backend/convex): Powered by Convex, this contains the database schema, queries, mutations, actions, and other server functions. It serves both the web and native clients through a consistent API.
- External Services:
- Clerk for user authentication.
- OpenAI for AI summarization (if enabled).
- Turborepo for monorepo management.
- Additional utilities (TypeScript, Prettier, Expo, etc.).

##### Out the Relationships and Interactions
- Both the web and native apps as separate client components that communicate with the backend (Convex).
- External integrations:
- Monorepo structure by noting that Turborepo is managing these multiple packages (apps and backend).

##### Architectural Patterns and Design Principles
- The separation of concerns is clear: the frontend apps are responsible solely for UI and client logic, while the backend (Convex) handles data management and server functions.
- End-to-end type safety, where data models and API definitions are shared between the backend and frontends.
- Use of real-time reactivity in Convex, which is key to data subscriptions on both clients.
- The design encourages a central backend API that serves both platforms, which simplifies maintenance and ensures consistency.

- “Web App (Next.js + TailwindCSS + Clerk)”
- “Native App (React Native + Expo)”
- “Backend (Convex: Database & Server Functions)”
- “Authentication (Clerk)”
- “AI Summarization (OpenAI API) – Optional”
- “Monorepo Tooling (Turborepo)”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Monorepo Management
    subgraph "Monorepo Management"
        M("Monorepo Management (Turborepo)")
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        W("Web App (Next.js + TailwindCSS + Clerk)")
        N("Native App (React Native + Expo)")
    end

    %% Backend
    subgraph "Backend"
        B("Backend (Convex: Database & Server Functions)")
    end

    %% External Services
    subgraph "External Services"
        Auth("Authentication (Clerk)")
        AI("AI Summarization (OpenAI API)")
    end

    %% Connections
    W -->|"API_Call"| B
    N -->|"API_Call"| B
    W -->|"Auth_Request"| Auth
    N -->|"Auth_Request"| Auth
    B -.->|"AI_Summarization_Request"| AI
    B -.->|"Real-time_Subscription"| W
    B -.->|"Real-time_Subscription"| N
    M -.-> W
    M -.-> N
    M -.-> B

    %% Click Events
    click W "https://github.com/get-convex/turbo-expo-nextjs-clerk-convex-monorepo/tree/main/apps/web"
    click N "https://github.com/get-convex/turbo-expo-nextjs-clerk-convex-monorepo/tree/main/apps/native"
    click B "https://github.com/get-convex/turbo-expo-nextjs-clerk-convex-monorepo/tree/main/packages/backend/convex"
    click AI "https://github.com/get-convex/turbo-expo-nextjs-clerk-convex-monorepo/blob/main/packages/backend/convex/openai.ts"
    click M "https://github.com/get-convex/turbo-expo-nextjs-clerk-convex-monorepo/blob/main/turbo.json"

    %% Styles
    classDef frontend fill:#bbdefb,stroke:#1e88e5,stroke-width:2px;
    classDef backend fill:#c8e6c9,stroke:#388e3c,stroke-width:2px;
    classDef external fill:#ffe0b2,stroke:#f57c00,stroke-width:2px;
    classDef monorepo fill:#d1c4e9,stroke:#512da8,stroke-width:2px;

    class W,N frontend;
    class B backend;
    class Auth,AI external;
    class M monorepo;
```
