# se-uulm/snowballr-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/se-uulm/snowballr-frontend
- Repository: https://github.com/se-uulm/snowballr-frontend

## Overview

##### Main System Components
- Frontend Application: The core is a SvelteKit application found under the “src” folder, with clear separation between routes, UI components, and libraries.
- UI Components: Organized into “primitives” (atomic components like buttons, input fields, dialogs, etc.) and “composites” (more advanced, compound UI elements such as navigation bars, paper views, project components, etc.).
- API Integration: There’s a dedicated API layer (e.g., “src/grpc-api.ts”) and instructions in the README to compile proto files and configure the backend API URL via environment variables.
- Testing Infrastructure: Unit, integration, and end-to-end tests are clearly separated in the “tests” directory, indicating a design that emphasizes automated quality assurance.
- Build and Deployment Tools: GitHub workflows and other configuration files (e.g., vite.config.ts, svelte.config.js, tailwind.config.js) support continuous integration and deployment, as well as code quality checks.
- External Tools: Lighthouse is used for auditing performance and accessibility, with reports output to the “lighthouse-reports” folder.

a. Frontend Layer:
- A large block to represent the SvelteKit application’s structure.
- Sub-blocks for “Routes” (src/routes) and “UI Components” (split between “primitives” and “composites”). Highlight how page routes (e.g., auth paths, project-specific paths, settings, paper views, etc.) consume the UI components.
b. API Service:
- Mention that API specifics are maintained externally (git submodule with proto files), so denote it as an “External Backend”.
c. Testing & Quality Assurance:
d. Build & Configuration:
- A block detailing tooling: Vite, Tailwind, ESLint, Prettier, and other configuration files.
- That configuration (like environment variables from .env) ties into how the frontend initializes and interacts with the API.

##### Architectural Patterns and Design Principles
- Component-Based Architecture: The clear separation between primitives and composites reflects a design that encourages reusability and modular UI development.
- Separation of Concerns: Dividing routes for authentication, project management, settings, etc., supports distinct business domains.
- Integration of External Services: A dedicated API module shows decoupling of frontend and backend responsibilities.
- Test-Driven and CI/CD Focus: Emphasis on unit, integration, and end-to-end tests promotes a maintainable quality assurance process.

- “Routes” (pages for auth, projects, paper, settings, etc.)
- “Components” further divided into “Primitives” and “Composites.” Make note of key composites like Navigation Bars, Paper Components, and Project Components.
d. A “Testing & CI/CD” block that includes:
- “Unit Tests” (tests/unit)
- “Integration & E2E Tests” (tests/integration & tests/e2e)
- “GitHub Workflows” and “Lighthouse Audits”
e. Finally, have a separate section for “Build & Configuration Tools” (listing Vite, Tailwind, ESLint, etc.), tied into the overall deployment process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    client["Client Browser"]:::external

    %% SvelteKit Frontend Subgraph
    subgraph "SvelteKit Frontend"
        direction TB
        frontendApp["SvelteKit Frontend"]:::frontend
        routes["Routes (src/routes)"]:::frontend
        appShell["Application Shell (src/app.html & src/app.css)"]:::frontend
        subgraph "UI Components"
            direction TB
            primitives["Primitives (src/lib/components/primitives)"]:::frontend
            composites["Composites (src/lib/components/composites)"]:::frontend
        end
    end

    %% API Service
    api["API Service (src/grpc-api.ts)"]:::api
    apiModels["API Models (src/lib/model/api)"]:::api

    %% Testing & CI/CD Subgraph
    subgraph "Testing & CI/CD"
        direction TB
        testsUnit["Unit Tests (tests/unit)"]:::testing
        testsInt["Integration Tests (tests/integration)"]:::testing
        testsE2E["E2E Tests (tests/e2e)"]:::testing
        githubWorkflow["GitHub Workflows (.github/workflows/)"]:::testing
    end

    %% Build & Configuration Subgraph
    subgraph "Build & Configuration"
        direction TB
        buildVite["Vite Config (vite.config.ts)"]:::build
        buildSvelte["Svelte Config (svelte.config.js)"]:::build
        buildTailwind["Tailwind Config (tailwind.config.js)"]:::build
        buildEnv["Env Example (.env.example)"]:::build
    end

    %% External Tools
    lighthouse["Lighthouse Reports (lighthouse-reports/)"]:::build

    %% Connections
    client -->|"access"| frontendApp
    frontendApp -->|"routes"| routes
    frontendApp -->|"renders"| appShell
    routes -->|"renders"| primitives
    routes -->|"renders"| composites
    appShell -->|"calls_API_using_PUBLIC_API_BASE_URL"| api
    api -->|"uses"| apiModels

    githubWorkflow -->|"triggers_tests"| testsUnit
    githubWorkflow -->|"triggers_tests"| testsInt
    githubWorkflow -->|"triggers_tests"| testsE2E
    githubWorkflow -->|"runs"| lighthouse

    buildVite -->|"configures"| appShell
    buildSvelte -->|"configures"| appShell
    buildTailwind -->|"styles"| appShell
    buildEnv -->|"provides_env_vars"| appShell

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef api fill:#90EE90,stroke:#333,stroke-width:2px
    classDef testing fill:#FFA500,stroke:#333,stroke-width:2px
    classDef build fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef external fill:#FFB6C1,stroke:#333,stroke-width:2px

    %% Click Events
    click frontendApp "https://github.com/se-uulm/snowballr-frontend/tree/develop/src/"
    click routes "https://github.com/se-uulm/snowballr-frontend/tree/develop/src/routes"
    click appShell "https://github.com/se-uulm/snowballr-frontend/blob/develop/src/app.html"
    click appShell "https://github.com/se-uulm/snowballr-frontend/blob/develop/src/app.css"
    click primitives "https://github.com/se-uulm/snowballr-frontend/tree/develop/src/lib/components/primitives"
    click composites "https://github.com/se-uulm/snowballr-frontend/tree/develop/src/lib/components/composites"
    click api "https://github.com/se-uulm/snowballr-frontend/blob/develop/src/grpc-api.ts"
    click apiModels "https://github.com/se-uulm/snowballr-frontend/tree/develop/src/lib/model/api"
    click testsUnit "https://github.com/se-uulm/snowballr-frontend/tree/develop/tests/unit"
    click testsInt "https://github.com/se-uulm/snowballr-frontend/tree/develop/tests/integration"
    click testsE2E "https://github.com/se-uulm/snowballr-frontend/tree/develop/tests/e2e"
    click githubWorkflow "https://github.com/se-uulm/snowballr-frontend/tree/develop/.github/workflows/"
    click buildVite "https://github.com/se-uulm/snowballr-frontend/blob/develop/vite.config.ts"
    click buildSvelte "https://github.com/se-uulm/snowballr-frontend/blob/develop/svelte.config.js"
    click buildTailwind "https://github.com/se-uulm/snowballr-frontend/blob/develop/tailwind.config.js"
    click buildEnv "https://github.com/se-uulm/snowballr-frontend/blob/develop/.env.example"
    click lighthouse "https://github.com/se-uulm/snowballr-frontend/tree/develop/lighthouse-reports/"
```
