# thebuilderdao/kafe architecture

> Architecture diagram of the GitHub repository thebuilderdao/kafe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thebuilderdao/kafe
- Repository: https://github.com/thebuilderdao/kafe

## Overview

##### Main Components

a. Frontend Layer:
- Web Application (/apps/web)
- Documentation Site (/apps/docs)
- Both built with Next.js and TailwindCSS

b. Backend/Smart Contract Layer:
- Solana Programs (/dao-programs)
- Tutorial Program with TypeScript SDK
- Token Management System

c. Content Management Layer:
- Tutorial System
- Markdown Processing Pipeline
- Content Templates

d. Integration Layer:
- External Services Integration (Arweave, Ceramic, The Graph, etc.)
- Blockchain Integration (Solana)
- API Services

**[User Interface Layer]**

- Web App (Next.js)
- Components
- Pages
- Hooks

- Documentation (Nextra)
- Components
- Pages

**[Core Services Layer]**

- Tutorial Management
- Content Processing
- Template Engine
- Markdown Utils

- DAO Programs
- Solana Smart Contracts
- TypeScript SDK
- Migration Scripts

**[Integration Layer]**

- Blockchain Services
- Solana Integration
- Token Management

- External Services
- Arweave
- Ceramic
- The Graph

**[Infrastructure Layer]**

- Build System (Turborepo)
- Package Management (Yarn)
- Deployment (Vercel)

##### Connection Types

- Double lines for API connections

##### Additional Details

Annotations for:
- Authentication flows
- Data persistence paths
- Build/deployment pipelines
- Content creation and review workflows

##### Key Workflows to Highlight

a. Tutorial Creation Flow:
**Author → Proposal → Voting → Content Creation → Review → Publication**

b. User Interaction Flow:
**Web Interface → Wallet Connection → Tutorial Access → Token Integration**

##### Documentation Integration

- Quick reference guides for each major component
- Document integration points and dependencies

This system design should effectively communicate the architecture while maintaining clarity and providing sufficient detail for implementation and maintenance.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        WebApp["Web Application (Next.js)"]
        Docs["Documentation (Nextra)"]
        
        subgraph WebComponents["Web Components"]
            Components["Frontend Components"]:::component
            Pages["Frontend Pages"]:::component
            Hooks["Frontend Hooks"]:::component
        end
    end

    subgraph Core["Core Services Layer"]
        TutorialMgmt["Tutorial Management"]
        
        subgraph ContentProcessing["Content Processing"]
            MarkdownUtils["Markdown Utils"]:::component
            Templates["Content Templates"]:::component
            MDFormatter["Content Processing Pipeline"]:::component
        end
        
        subgraph DAOPrograms["DAO Programs"]
            SolanaContracts["Solana Programs"]:::component
            TypeScriptSDK["TypeScript SDK"]:::component
        end
    end

    subgraph Integration["Integration Layer"]
        BlockchainServices["Blockchain Services"]
        
        subgraph ExternalSvcs["External Services"]
            APIServices["API Services"]:::component
            ExtIntegration["External Services Integration"]:::component
            Arweave(("Arweave"))
            Ceramic(("Ceramic"))
            TheGraph(("The Graph"))
        end
    end

    subgraph Infra["Infrastructure Layer"]
        BuildSystem["Build System (Turborepo)"]:::component
        PackageManagement["Package Management (Yarn)"]:::component
        Deployment["Deployment (Vercel)"]
    end

    %% Connections
    WebApp --> Components
    WebApp --> Pages
    WebApp --> Hooks
    WebApp --> TutorialMgmt
    TutorialMgmt --> MarkdownUtils
    TutorialMgmt --> Templates
    TutorialMgmt --> MDFormatter
    BlockchainServices --> SolanaContracts
    BlockchainServices --> TypeScriptSDK
    ExternalSvcs --> Arweave
    ExternalSvcs --> Ceramic
    ExternalSvcs --> TheGraph
    APIServices --> ExtIntegration

    %% Styles
    classDef component fill:#f9f,stroke:#333,stroke-width:2px
    
    %% Click Events
    click WebApp "https://github.com/thebuilderdao/kafe/tree/dev/apps/web"
    click Docs "https://github.com/thebuilderdao/kafe/tree/dev/apps/docs"
    click Components "https://github.com/thebuilderdao/kafe/tree/dev/apps/web/components"
    click Pages "https://github.com/thebuilderdao/kafe/tree/dev/apps/web/pages"
    click Hooks "https://github.com/thebuilderdao/kafe/tree/dev/apps/web/hooks"
    click MarkdownUtils "https://github.com/thebuilderdao/kafe/tree/dev/packages/md-utils"
    click Templates "https://github.com/thebuilderdao/kafe/tree/dev/templates"
    click MDFormatter "https://github.com/thebuilderdao/kafe/tree/dev/packages/md-formatter"
    click SolanaContracts "https://github.com/thebuilderdao/kafe/tree/dev/dao-programs/programs/tutorial"
    click TypeScriptSDK "https://github.com/thebuilderdao/kafe/tree/dev/dao-programs/programs/tutorial/ts-sdk"
    click APIServices "https://github.com/thebuilderdao/kafe/tree/dev/apps/web/pages/api"
    click ExtIntegration "https://github.com/thebuilderdao/kafe/tree/dev/packages/apis"
    click BuildSystem "https://github.com/thebuilderdao/kafe/blob/dev/turbo.json"
    click PackageManagement "https://github.com/thebuilderdao/kafe/blob/dev/package.json"
```
