# dreamographer/zensync-client architecture

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

- Interactive diagram: https://gitdiagram.com/dreamographer/zensync-client
- Repository: https://github.com/dreamographer/zensync-client

## Overview

##### Project Type and Purpose
- It’s a full-stack web application built with Next.js (using the new app directory structure) intended for real-time collaboration.
- Key functionalities include user authentication (login, signup, verify email), a collaborative dashboard, document publishing with public previews, and real-time meeting rooms (integrating features like audio and shared canvas).

##### Analyzing the File Structure
- The top level includes configuration files (Dockerfile, ESLint, Tailwind, PostCSS, and TS configs) indicating both development environment setup and containerized deployment.
- The src directory is the heart of the application. Within it:
- The /app subdirectory is organized by logical route groups:
▪ "(auth)" handles login, signup, and email verification.
▪ "(landing)" serves the marketing/landing page.
▪ "(main)" splits into sub-sections like "dashboard," "room" (for real-time collaboration in whiteboard or meeting scenarios), and "public" (for published document previews).
- The /api subdirectory under /app contains endpoints such as:
▪ edgestore – likely handling collaborative state storage.
▪ generate – possibly powering document publishing or AI auto-complete features.
▪ livekit – integrating audio connectivity for meeting rooms.
- Dedicated directories for UI components exist (dashboard, editor, room, landing-page, global, videoRoom, etc.), which keep the frontend modular and reusable.
- A /Types folder defines TypeScript types. This ensures strong typing for core entities like document structures, user interfaces, and workspace details.
- Integration with Liveblocks (see liveblocks.config.ts) suggests real-time state sharing among collaborative clients.

a. Main Components:
- Frontend Client:
- Built with Next.js and React.
- Separated user areas: Authentication, Landing Page, Dashboard, Collaborative Room, and Public Preview.
- API Layer / Backend Endpoints:
- RESTful or Route-based API endpoints (e.g., /api/edgestore, /api/generate, /api/livekit) handling data mutations, collaboration state, AI-based operations, and media connectivity.
- Real-Time Collaboration Services:
- Liveblocks integration for real-time state management (e.g., cursor presence, collaborative whiteboard changes).
- Possibly third-party services (e.g., Livekit for audio connectivity).
- Containerization & Deployment:
- Dockerfile indicates that the app is containerized for deployment.
- GitHub Actions (in .github/workflows) for CI/CD processes.
- Static Assets:
- Public directory with logos, banners, and feature imagery.

b. Relationships & Interactions:
- The Frontend interacts with the API endpoints to fetch and update document data, workspace details, and collaboration state.
- Real-time updates propagate via Liveblocks and direct API calls.
- The dashboard serves as the hub where navigation triggers various interactions (e.g., switching workspaces, editing documents, joining a collaborative room).
- For the meeting room, there’s integration with Livekit (audio streaming) and real-time sharing of whiteboard content.
- Authentication flow connects the (auth) routes with secure API endpoints.

c. Architectural Patterns / Design Principles:
- Use of Next.js app directory indicates server-side rendering (SSR) and client-side interactivity.
- Separation of concerns: distinct modules for auth, landing, main functionality (dashboard, room) keep UI and business logic separate.
- API endpoints serve as a microservice-like interface within the project.
- Containerization and CI/CD pipelines promote robust deployment practices.

d. Relevant Technologies and Frameworks:
- Next.js for routing, SSR, and API handling.
- React for building interactive UIs.
- Tailwind CSS for styling.
- Liveblocks for managing real-time collaboration state.
- Possibly AI integration (auto-complete) via endpoints like /api/generate.
- Livekit for handling audio and media streaming.
- TypeScript for static type safety.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Client and Routes
    Browser["Web Browser/Client"]:::client

    subgraph "Next.js Routes"
        Auth["(auth) Authentication"]:::frontend
        Landing["(landing) Landing Page"]:::frontend
        Main["(main) Dashboard & Collaborative Area"]:::frontend
        Public["(public) Public Preview"]:::frontend
    end

    Browser -->|"accesses"| Auth
    Browser -->|"accesses"| Landing
    Browser -->|"accesses"| Main
    Browser -->|"accesses"| Public

    %% API Endpoints
    subgraph "API Endpoints"
        Edgestore["Edgestore Endpoint"]:::backend
        Generate["Generate Endpoint"]:::backend
        LivekitAPI["Livekit API Endpoint"]:::backend
    end

    %% External Real-Time Services
    subgraph "External Real-Time Services"
        Liveblocks["Liveblocks Service"]:::external
        Livekit["Livekit Service"]:::external
    end

    %% Frontend interactions with API endpoints
    Main -->|"collaborative-update"| Edgestore
    Main -->|"auto-complete/publish"| Generate
    Main -->|"audio/connect"| LivekitAPI

    %% API interactions with external services
    Edgestore -->|"state-sync"| Liveblocks
    LivekitAPI -->|"audio-stream"| Livekit

    %% Development and Deployment
    subgraph "Development & Deployment"
        Docker["Dockerfile"]:::deployment
        CICD["GitHub Actions CI/CD"]:::deployment
        TypeDef["Type Definitions (Types)"]:::misc
    end

    %% Connections for development components
    CICD --> Docker
    Auth --- TypeDef
    Landing --- TypeDef
    Main --- TypeDef
    Public --- TypeDef

    %% Click Events
    click Auth "https://github.com/dreamographer/zensync-client/tree/main/src/app/(auth)/"
    click Landing "https://github.com/dreamographer/zensync-client/tree/main/src/app/(landing)/"
    click Main "https://github.com/dreamographer/zensync-client/tree/main/src/app/(main)/dashboard/"
    click Main "https://github.com/dreamographer/zensync-client/tree/main/src/components/dashboard/"
    click Main "https://github.com/dreamographer/zensync-client/tree/main/src/app/(main)/room/"
    click Main "https://github.com/dreamographer/zensync-client/tree/main/src/components/room/"
    click Public "https://github.com/dreamographer/zensync-client/tree/main/src/app/(public)/"
    click Edgestore "https://github.com/dreamographer/zensync-client/tree/main/src/app/api/edgestore/"
    click Generate "https://github.com/dreamographer/zensync-client/tree/main/src/app/api/generate/"
    click LivekitAPI "https://github.com/dreamographer/zensync-client/tree/main/src/app/api/livekit/"
    click Liveblocks "https://github.com/dreamographer/zensync-client/blob/main/src/liveblocks.config.ts"
    click TypeDef "https://github.com/dreamographer/zensync-client/tree/main/src/Types/"
    click Docker "https://github.com/dreamographer/zensync-client/tree/main/Dockerfile"
    click CICD "https://github.com/dreamographer/zensync-client/tree/main/.github/workflows/"

    %% Style Classes
    classDef frontend fill:#A2D2FF,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFB4A2,stroke:#000,stroke-width:2px;
    classDef external fill:#B9FBC0,stroke:#000,stroke-width:2px;
    classDef deployment fill:#F9E2AE,stroke:#000,stroke-width:2px;
    classDef client fill:#F6BDC0,stroke:#000,stroke-width:2px;
    classDef misc fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
