# yeti/yurt architecture

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

- Interactive diagram: https://gitdiagram.com/yeti/yurt
- Repository: https://github.com/yeti/yurt

## Overview

The Yurt project is a monorepo maintained with pnpm workspaces and Lerna. It’s designed as a CLI scaffolding tool that helps generate projects from template packages. These templates currently include:
- A standalone React/Vite App
- A combined React/Vite App with a Node Apollo GraphQL Server

##### Main Components

a. CLI Package:
- Located in packages/cli.
- This is the entry point for users interacting with the tool. It prompts the user and triggers the scaffolding process.
- Represents the user interface (command-line) for initiating the creation of new projects.

b. Template Packages:
- React/Vite App (packages/react)
- React/Vite App with Node Apollo GraphQL Server (packages/react-apollo and packages/backend)
- These packages serve as blueprints. The “react” package is a straightforward front-end template, whereas the “react-apollo” package integrates front-end React code with a backend GraphQL server.

c. Backend Service:
- Found under packages/backend.
- Implements a Node-based Apollo GraphQL server.
- Contains Prisma integration (database schema, migrations, and seed) for ORM functionality.
- Uses modular architecture with directories such as “src/schemaModules” (e.g., the “user” module) and separate configurations for testing and deployment.

##### Relationships and Interactions

a. The CLI component acts as the orchestrator:
- It interacts with the user (via terminal prompts) to select the desired template type.
- On user selection, it writes out the relevant scaffolded project structure using one of the template packages.

b. Template Package Composition:
- For a React/Vite App: It includes all necessary front-end resources, configuration (Vite, ESLint, Prettier, etc.), and setup instructions.
- For the React/Vite App + Node Apollo Server: It integrates both the backend and front-end codebases. The backend (GraphQL server) communicates with the front-end through GraphQL APIs.

c. Deployment and Development Tools:
- Docker files, ESLint configurations, and testing configurations (Jest, for instance) show that the project is prepared for both development and CI/CD.
- The monorepo structure ensures that dependencies and code across packages (CLI, backend, and frontends) are managed centrally by pnpm and Lerna.

##### Architectural Patterns and Technologies

a. Monorepo Architecture:
- Managed by pnpm workspaces and Lerna, allowing shared configurations, dependencies, and synchronous version management.
- This aids in consistency across multiple templates and the CLI tool itself.

b. Modular Structure:
- The backend is split into schema modules (for GraphQL) with separate concerns like plugins, services, and shared utilities.
- The front-end packages follow modern React paradigms with component-based design, routing, and global state management.

c. Separation of Concerns:
- The CLI handles scaffolding and configuration.
- Template packages provide well-defined boundaries between client (React/Vite) and server (Node/Apollo).

d. Use of Modern Technologies:
- React and Vite for the front end for fast development and hot module replacement.
- Node Apollo Server for GraphQL APIs.
- Prisma for database interactions.
- Docker for containerization of tests and deployments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Nodes
    User["User Terminal"]:::user

    %% CLI Package
    subgraph "CLI Package"
        CLI["CLI Scaffolding Tool"]:::cli
    end

    %% Template Packages
    subgraph "Template Packages"
        Option1["React/Vite App Template"]:::template
        subgraph "Full-Stack Template"
            FE["React/Vite Front-end"]:::template
            BE["Node Apollo GraphQL Server (Backend)"]:::backend
            DB["Prisma DB"]:::database
        end
    end

    %% Interactions
    User -->|"runs"| CLI
    CLI -->|"selects_template"| Option1
    CLI -->|"selects_template"| FE
    FE -->|"integrates_with"| BE
    BE -->|"db_operations"| DB

    %% Click Events
    click CLI "https://github.com/yeti/yurt/blob/develop/packages/cli/src/index.ts"
    click Option1 "https://github.com/yeti/yurt/tree/develop/packages/react/"
    click FE "https://github.com/yeti/yurt/tree/develop/packages/react-apollo/"
    click BE "https://github.com/yeti/yurt/tree/develop/packages/backend/"

    %% Styles
    classDef cli fill:#fef3c7,stroke:#f59e0b,stroke-width:2px;
    classDef template fill:#e0f2fe,stroke:#0284c7,stroke-width:2px;
    classDef backend fill:#fee2e2,stroke:#ef4444,stroke-width:2px;
    classDef database fill:#c7f9cc,stroke:#16a34a,stroke-width:2px;
    classDef user fill:#e0e7ff,stroke:#4338ca,stroke-width:2px;
```
