# encoredev/examples architecture

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

- Interactive diagram: https://gitdiagram.com/encoredev/examples
- Repository: https://github.com/encoredev/examples

## Overview

##### Project type and purpose
- This is a **monorepo** that holds:
– **Starters**: full-stack or microservice example apps (in Go or TypeScript) ready to clone or bootstrap via `encore app create`.
– **Bits**: small reusable code modules demonstrating common integrations (e.g., SendGrid, Pexels, ElevenLabs).
- The README describes two categories: **Starters** (runnable apps) and **Bits** (libraries/snippets).

##### File structure
- **Top-level** contains global assets:
– `.gitignore`, `LICENSE`, `README.md`
– CLI metadata files (`cli-templates.json`, `cli-tutorials.json`)
- **Template folders** – each subfolder (e.g., `ai-chat`, `booking-system`, `url-shortener`, `ts/hello-world`, etc.) is a standalone example:
– Some in Go (root-level directories like `ai-chat`, `booking-system`, `hello-world`).
– Some in TypeScript (under `ts/…`).
– Typically include:
- `encore.app` (Encore configuration)
- `service` or `backend` directories (handlers, migrations, DB code)
- `frontend` (static or React/Next.js code)
- `migrations` folder with SQL files
- `README.md` with usage instructions
- **bits/** folder contains small Go packages (`bits/sendgrid`, `bits/pexels`, etc.) with reusable code and their own README.

##### README for additional insights
- It enumerates all **Starters**, grouped by language (TypeScript vs. Go) and by feature set (e.g., “ts/saas-starter”, “hello-world”, “ts/streaming-chat”).
- It enumerates all **Bits** under `bits/`, describing the primitives they illustrate (APIs, Pub/Sub, Secrets, etc.).

a. **Main Components**
– **Developer** (actor who runs CLI)
– **Encore CLI** (tool that scaffolds a new app)
– **Templates Monorepo**
- **Starters** (folders for full apps)
- **Bits** (folders for reusable modules)
– **GitHub** (remote origin)
– **Local File System** (where CLI copies a selected template)
b. **Relationships & Interactions**
– Developer ➞ runs Encore CLI ➞ queries Templates Monorepo ➞ clones selected Starter (or copy Bits) into new project directory.
– Starter sub-folder ➞ defines backend, frontend, migrations, configs.
– Bits folder ➞ imported into user’s Encore app as dependencies.
– Encore CLI ➞ interprets `encore.app` within each Starter to spin up local dev environment.
c. **Architectural Patterns & Principles**
– **Monorepo** containing many independent projects
– **Template/Scaffolding** pattern: reusable boilerplate
– **Clear separation** between Starters (full apps) and Bits (modules)
– Folder-per-template isolation, each with its own Encore config and code
d. **Key Technologies**
– **Encore** (backend framework & CLI)
– **Go** and **TypeScript** runtimes
– **React/Next.js**, static assets (Vite) in frontends
– **SQL migrations** (PostgreSQL)
– **Pub/Sub** patterns in some templates (e.g., ai-chat)

## Diagram (Mermaid)

```mermaid
flowchart TD
    Developer(("Developer")):::actor
    EncoreCLI["Encore CLI"]:::tooling
    TemplatesRepo["Encore Templates Repository"]:::repo
    LocalFS["Local File System"]:::storage
    GitHub["GitHub (remote origin)"]:::external

    Developer -->|"runs"| EncoreCLI
    EncoreCLI -->|"reads"| TemplatesRepo
    EncoreCLI -->|"scaffolds new app to"| LocalFS
    TemplatesRepo -->|"origin remote"| GitHub

    subgraph "Encore Templates Repository"
        CLItemplates["cli-templates.json"]:::config
        CLItutorials["cli-tutorials.json"]:::config

        subgraph "Starters" 
            subgraph "Go Starters" 
                AIChat["ai-chat"]:::starter
                Booking["booking-system"]:::starter
                Hello["hello-world"]:::starter
                URLShort["url-shortener"]:::starter
            end
            subgraph "TS Starters"
                TSHello["ts/hello-world"]:::starter
                TSAIChat["ts/ai-chat"]:::starter
                TSStream["ts/streaming-chat"]:::starter
                TSSaas["ts/saas-starter"]:::starter
            end
        end

        subgraph "Bits"
            SendGrid["bits/sendgrid"]:::bits
            Pexels["bits/pexels"]:::bits
            ElevenLabs["bits/elevenlabs"]:::bits
        end
    end

    click CLItemplates "https://github.com/encoredev/examples/blob/main/cli-templates.json"
    click CLItutorials "https://github.com/encoredev/examples/blob/main/cli-tutorials.json"

    click SendGrid "https://github.com/encoredev/examples/tree/main/bits/sendgrid"
    click Pexels "https://github.com/encoredev/examples/tree/main/bits/pexels"
    click ElevenLabs "https://github.com/encoredev/examples/tree/main/bits/elevenlabs"

    click AIChat "https://github.com/encoredev/examples/tree/main/ai-chat"
    click Booking "https://github.com/encoredev/examples/tree/main/booking-system"
    click Hello "https://github.com/encoredev/examples/tree/main/hello-world"
    click URLShort "https://github.com/encoredev/examples/tree/main/url-shortener"

    click TSHello "https://github.com/encoredev/examples/tree/main/ts/hello-world"
    click TSAIChat "https://github.com/encoredev/examples/tree/main/ts/ai-chat"
    click TSStream "https://github.com/encoredev/examples/tree/main/ts/streaming-chat"
    click TSSaas "https://github.com/encoredev/examples/tree/main/ts/saas-starter"

    classDef tooling fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef starter fill:#90EE90,stroke:#333,stroke-width:1px
    classDef bits fill:#FFA500,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef actor fill:#CCCCCC,stroke:#333,stroke-width:1px
    classDef repo fill:#FFFFFF,stroke:#333,stroke-width:2px
    classDef storage fill:#EFEFEF,stroke:#333,stroke-width:1px
    classDef external fill:#EFEFEF,stroke:#333,stroke-width:1px
```
