# nickyhajal/eventlayer architecture

> Architecture diagram of the GitHub repository nickyhajal/eventlayer, 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/nickyhajal/eventlayer
- Repository: https://github.com/nickyhajal/eventlayer

## Overview

##### Main Components
- Apps:
- Web App (located under apps/web): A full-featured SvelteKit application with a complex routing structure (including “(checkin)”, “(manage)”, “(pwa)”, and other route groups) designed to handle different client-side experiences.
- Docs App (mentioned in the README though not explicitly visible in the file tree, it would be structured similarly as a SvelteKit app).
- Packages/Libraries:
- API Package (packages/api): Contains backend logic, routers, procedures, and integration with authentication, media, and other domain-specific operations.
- DB Package (packages/db): Contains database schemas, migration scripts, and seeding logic (using, for example, Drizzle).
- UI Package (packages/ui): A shared Svelte component library that provides common UI elements used by all SvelteKit apps.
- Util Package (packages/util): Shared utilities and helper functions that are imported by other parts of the monorepo.
- Tooling:
- Tool configurations for ESLint, Prettier, Tailwind, and TypeScript. These support code quality, formatting, and styling across the entire repo. (These can be shown as supporting infrastructure rather than “runtime” components.)

##### Relationships and Interactions
- The SvelteKit apps (“web” and “docs”) depend on shared components from the UI package and utilities from the Util package.
- The API package (backend) serves endpoints that the frontend may interact with, and these endpoints depend on database models/schemas defined in the DB package.
- Although not explicitly a separate “backend service” container, the API package encapsulates server-side logic (for instance, via TRPC procedures or explicit routers) which is integrated with the SvelteKit app’s server-side parts.
- The tooling and configuration files at the repo’s root (such as turborepo’s turbo.json, ESLint, Prettier, TypeScript, etc.) provide the necessary development, build, and deployment scaffolding.

##### Architectural Patterns and Principles
- Modularity: Different functionalities are broken down into self-contained packages/apps (separation of concerns between frontend, backend, UI components, and database access).
- Shared-code/Monorepo strategy: Code reuse is enforced by having common libraries (UI and Util) available to multiple applications.
- Full-stack Separation: SvelteKit primarily drives both client- and server-side rendering, while the API package modularizes backend procedures.
- Consistency via Tools: Use of ESLint, Prettier, and strict TypeScript settings ensures code quality across all components.

##### Relevant Technologies, Frameworks, and Libraries
- SvelteKit for building both “web” and “docs” applications.
- TypeScript as the main language across apps and packages.
- TRPC (or similar) for typed API routes.
- Drizzle ORM in the DB package.
- Svelte components in the UI package which include a variety of UI controls (buttons, calendars, modals, etc.).
- Tailwind and PostCSS for styling.
- Node.js/npm (specifically pnpm) for package management.
- Turborepo for efficient build and dependency management across the monorepo.

##### Final Recommendations
- Be thorough: Include every essential element (frontend, backend/API, database, shared libraries, and development tooling).

## Diagram (Mermaid)

```mermaid
flowchart TD

    subgraph "Apps"
        WA["Web App (SvelteKit)"]:::app
        DA["Docs App (SvelteKit)"]:::app
    end

    subgraph "Packages"
        API["API Service / Procedures"]:::package
        DB["Database Module (Drizzle ORM, DB Schemas)"]:::database
        UI["UI Component Library"]:::package
        UT["Utility Library"]:::package
    end

    subgraph "Tooling & Configs"
        TL["Tooling / Configs"]:::tooling
    end

    %% App to Packages connections
    WA -->|"calls"| API
    DA -->|"calls"| API

    WA -->|"uses"| UI
    WA -->|"uses"| UT
    DA -->|"uses"| UI
    DA -->|"uses"| UT

    %% API to Database connection
    API -->|"usesSchema"| DB

    %% Tooling supports all components
    TL -->|"supports"| WA
    TL -->|"supports"| DA
    TL -->|"supports"| API
    TL -->|"supports"| DB
    TL -->|"supports"| UI
    TL -->|"supports"| UT

    %% Click Events
    click WA "https://github.com/nickyhajal/eventlayer/tree/main/apps/web"
    click API "https://github.com/nickyhajal/eventlayer/tree/main/packages/api"
    click DB "https://github.com/nickyhajal/eventlayer/tree/main/packages/db"
    click UI "https://github.com/nickyhajal/eventlayer/tree/main/packages/ui"
    click UT "https://github.com/nickyhajal/eventlayer/tree/main/packages/util"
    click TL "https://github.com/nickyhajal/eventlayer/tree/main/tooling"

    %% Styles
    classDef app fill:#a1c4fd,stroke:#1f497d,stroke-width:2px,color:#000;
    classDef package fill:#c6efce,stroke:#38761d,stroke-width:2px,color:#000;
    classDef database fill:#f4cccc,stroke:#e06666,stroke-width:2px,color:#000;
    classDef tooling fill:#fce5cd,stroke:#e69138,stroke-width:2px,color:#000;
```
