# jeanmeijer/analog architecture

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

- Interactive diagram: https://gitdiagram.com/jeanmeijer/analog
- Repository: https://github.com/jeanmeijer/analog

## Overview

##### Project type and purpose
- This is a monorepo (TurboRepo) for a full-stack Next.js application (“apps/web”) backed by a tRPC/Node API (“packages/api”) with modular packages for authentication (“packages/auth”), database schema (Drizzle ORM in “packages/db”), environment management (“packages/env”), and a Google Calendar SDK (“packages/google-calendar”). It’s intended to deliver a web UI, API endpoints, and integrations with third-party services.

##### File structure
- Top-level:
- apps/web: Next.js 13+ app directory (React, server/client components, API routes for auth & tRPC)
- packages/api: Express or Fastify (via tRPC router definitions under src/routers)
- packages/auth: shared auth logic (client & server sign-in)
- packages/db: Drizzle ORM config & schema (auth tables, etc.)
- packages/env: environment‐variable validation & loaders
- packages/google-calendar: standalone TypeScript SDK for Google Calendar REST API
- tooling: shared ESLint and TSConfig presets
- Configuration: turbro.json orchestrates pipelines, root tsconfig.json, package.json with workspace settings.

##### README for additional insights
- README is generic Next.js scaffold; no custom architecture docs. The key insights come from file tree: using Next.js App Router, next/font, TRPC, Drizzle, monorepo tooling.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (apps/web)" 
        direction TB
        AppRouter["src/app (App Router)"]:::frontend
        AuthRoute["src/app/api/auth/[...all]/route.ts"]:::frontend
        TrpcRoute["src/app/api/trpc/[trpc]/route.ts"]:::frontend
        TrpcLib["src/lib/trpc (tRPC Client Utils)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB
        subgraph "packages/api (tRPC Server)"
            TRPCSetup["src/trpc.ts"]:::backend
            ServerEntry["src/root.ts"]:::backend
            Routers["src/routers"]:::backend
        end
        subgraph "packages/auth (Auth Service)"
            AuthClientLib["src/client.ts"]:::backend
            AuthServerLib["src/server.ts"]:::backend
        end
    end

    %% Data Layer
    subgraph "Database (packages/db)"
        direction TB
        DBConfig["drizzle.config.ts"]:::data
        DBIndex["src/index.ts"]:::data
        DBSchema["src/schema"]:::data
    end

    %% Shared Layer
    subgraph "Shared Packages"
        direction TB
        EnvClient["packages/env/src/client.ts"]:::shared
        EnvServer["packages/env/src/server.ts"]:::shared
    end

    %% External Integrations
    subgraph "External Services"
        direction TB
        GCalIndex["src/index.ts"]:::external
        GCalApi["src/api-promise.ts"]:::external
        GCalClient["src/client.ts"]:::external
        GCalResources["src/resources"]:::external
        Internet["Google Calendar API"]:::external
    end

    %% Tooling & CI
    subgraph "Tooling & CI"
        direction TB
        Turbo["turbo.json"]:::tooling
        ESLintBase["eslint-config/base.js"]:::tooling
        ESLintNext["eslint-config/next.js"]:::tooling
        ESLintReact["eslint-config/react.js"]:::tooling
        TSBase["typescript-config/base.json"]:::tooling
        TSNext["typescript-config/next.json"]:::tooling
        TSReact["typescript-config/react.json"]:::tooling
    end

    %% Connections
    AppRouter -->|uses RPC client| TrpcLib
    AppRouter -->|routes| AuthRoute
    AppRouter -->|routes| TrpcRoute
    TrpcRoute -->|"RPC calls"| TRPCSetup
    AuthRoute -->|"Auth calls"| AuthServerLib
    TRPCSetup -->|"loads env"| EnvServer
    ServerEntry -->|"loads env"| EnvServer
    ServerEntry -->|"imports routers"| Routers
    TRPCSetup -->|"uses routers"| Routers
    Routers -->|"queries"| DBIndex
    DBIndex -->|"config from"| DBConfig
    Routers -->|"reads schema"| DBSchema
    AuthServerLib -->|"queries"| DBIndex
    AuthServerLib -->|"uses env"| EnvServer
    ServerEntry -->|"uses auth client lib"| AuthClientLib
    TRPCSetup -->|"uses auth server lib"| AuthServerLib
    ServerEntry -->|"calls Google SDK"| GCalIndex
    GCalIndex -->|"wraps REST"| GCalApi
    GCalClient -->|"helpers for"| GCalIndex
    GCalResources -->|"implements resources"| GCalIndex
    GCalIndex -->|"REST calls"| Internet

    %% Shared usage
    AppRouter -->|"loads env"| EnvClient
    TrpcRoute -->|"loads env"| EnvClient

    %% Tooling usage
    Turbo -->|orchestrates| AppRouter
    Turbo -->|orchestrates| TRPCSetup
    Turbo -->|orchestrates| DBConfig
    Turbo -->|orchestrates| GCalIndex
    ESLintBase -->|extends| AppRouter
    ESLintNext -->|extends| AppRouter
    ESLintReact -->|extends| AppRouter
    TSBase -->|extends| AppRouter
    TSNext -->|extends| AppRouter
    TSReact -->|extends| AppRouter

    %% Click Events
    click AppRouter "https://github.com/jeanmeijer/analog/tree/main/apps/web/src/app"
    click AuthRoute "https://github.com/jeanmeijer/analog/blob/main/apps/web/src/app/api/auth/[...all]/route.ts"
    click TrpcRoute "https://github.com/jeanmeijer/analog/blob/main/apps/web/src/app/api/trpc/[trpc]/route.ts"
    click TrpcLib "https://github.com/jeanmeijer/analog/tree/main/apps/web/src/lib/trpc"
    click TRPCSetup "https://github.com/jeanmeijer/analog/blob/main/packages/api/src/trpc.ts"
    click ServerEntry "https://github.com/jeanmeijer/analog/blob/main/packages/api/src/root.ts"
    click Routers "https://github.com/jeanmeijer/analog/tree/main/packages/api/src/routers"
    click AuthClientLib "https://github.com/jeanmeijer/analog/blob/main/packages/auth/src/client.ts"
    click AuthServerLib "https://github.com/jeanmeijer/analog/blob/main/packages/auth/src/server.ts"
    click DBConfig "https://github.com/jeanmeijer/analog/blob/main/packages/db/drizzle.config.ts"
    click DBIndex "https://github.com/jeanmeijer/analog/blob/main/packages/db/src/index.ts"
    click DBSchema "https://github.com/jeanmeijer/analog/tree/main/packages/db/src/schema"
    click EnvClient "https://github.com/jeanmeijer/analog/blob/main/packages/env/src/client.ts"
    click EnvServer "https://github.com/jeanmeijer/analog/blob/main/packages/env/src/server.ts"
    click GCalIndex "https://github.com/jeanmeijer/analog/blob/main/packages/google-calendar/src/index.ts"
    click GCalApi "https://github.com/jeanmeijer/analog/blob/main/packages/google-calendar/src/api-promise.ts"
    click GCalClient "https://github.com/jeanmeijer/analog/blob/main/packages/google-calendar/src/client.ts"
    click GCalResources "https://github.com/jeanmeijer/analog/tree/main/packages/google-calendar/src/resources"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#024,stroke-width:1px
    classDef backend fill:#DFFFD0,stroke:#092,stroke-width:1px
    classDef data fill:#FFE0B2,stroke:#E65,stroke-width:1px
    classDef external fill:#FFF5B1,stroke:#B87,stroke-width:1px
    classDef shared fill:#E0E0E0,stroke:#666,stroke-width:1px
    classDef tooling fill:#F0F0F0,stroke:#444,stroke-width:1px
```
