# obviant/exercise-3 architecture

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

- Interactive diagram: https://gitdiagram.com/obviant/exercise-3
- Repository: https://github.com/obviant/exercise-3

## Overview

##### Main components
- Monorepo (root container) that houses all apps and packages.
- Apps:
- Web App (apps/web): A Next.js application with its own routing (pages, app structure, TRPC client hooks).
- API Server (apps/api-server): A Node.js/TypeScript server with routing (express-like router files, TRPC endpoints).
- Packages:
- Database Package (packages/database): Contains Drizzle ORM configuration, SQL migrations, and schema definitions.
- Shared configurations (packages/eslint-config and packages/tsconfig): Provide linting rules and TypeScript configurations that are used throughout.
- (Optionally) Docker and Build Tools:
- docker-compose.yaml indicates that containerization or local deployment orchestration is supported.
- Turborepo’s configuration (turbo.json, pnpm-workspace.yaml, and pnpm-lock.yaml) that manage task running and caching within the monorepo.

##### Relationships and interactions
- The web application likely interacts with the API server, possibly via TRPC endpoints, as both the apps/api-server and apps/web have TRPC-related code.
- The API server interacts with the database package for data persistence, using Drizzle ORM configurations and migrations.
- Shared configuration packages (eslint and tsconfig) act as foundational dependencies for both apps.
- The overall Turborepo setup binds these components together by enabling consistent builds, caching (including remote caching with Vercel as per the README), and development workflows.
- The docker-compose file may be used to orchestrate these components during containerized development or deployment.

##### Important architectural patterns and design principles
- Separation of Concerns: Clearly dividing the frontend (web app), backend/API (api-server), and database layer.
- Shared Library and Config Approach: Reusing configuration and tooling across different parts of the monorepo.
- TRPC Integration: Providing strong typing and remote procedure calls between client (web) and server (api-server).
- Monorepo Structure: Encouraging reusability and centralized management of packages/apps.
- Containerization Support: Through Docker for local development and/or deployment.

##### Relevant technologies and frameworks to highlight
- Next.js for the web app.
- Node.js with TypeScript for the API server.
- Drizzle ORM for database interactions.
- TRPC for type-safe API calls.
- Turborepo for task and build management.
- ESLint and Prettier for code quality.
- Docker (via docker-compose) for environment orchestration.

## Diagram (Mermaid)

```mermaid
graph TD
    ROOT["Monorepo (Turborepo Root)"]:::monorepo

    subgraph "Apps"
        WEB["Web App (Next.js)"]:::app
        API["API Server (Node.js/TypeScript)"]:::app
    end

    subgraph "Packages"
        DB["Database Package (Drizzle ORM)"]:::package
        ESLINT["ESLint Config"]:::package
        TSCONFIG["TSConfig Package"]:::package
    end

    TURBO["Turborepo Build System"]:::build
    DOCKER["Docker Deployment (docker-compose)"]:::deployment

    ROOT --> TURBO
    TURBO --> WEB
    TURBO --> API
    TURBO --> ESLINT
    TURBO --> TSCONFIG
    TURBO --> DB

    WEB -->|"TRPC calls"| API
    API -->|"Data access/ORM"| DB

    DOCKER --> WEB
    DOCKER --> API

    click ROOT "https://github.com/obviant/exercise-3/blob/main/."
    click WEB "https://github.com/obviant/exercise-3/tree/main/apps/web"
    click API "https://github.com/obviant/exercise-3/tree/main/apps/api-server"
    click DB "https://github.com/obviant/exercise-3/tree/main/packages/database"
    click ESLINT "https://github.com/obviant/exercise-3/tree/main/packages/eslint-config"
    click TSCONFIG "https://github.com/obviant/exercise-3/tree/main/packages/tsconfig"
    click DOCKER "https://github.com/obviant/exercise-3/blob/main/docker-compose.yaml"
    click TURBO "https://github.com/obviant/exercise-3/blob/main/turbo.json"
    click TURBO "https://github.com/obviant/exercise-3/blob/main/pnpm-workspace.yaml"

    classDef monorepo fill:#f3722c,stroke:#333,stroke-width:2px;
    classDef app fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef package fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef build fill:#f94144,stroke:#333,stroke-width:2px;
    classDef deployment fill:#577590,stroke:#333,stroke-width:2px;
```
