# ldanilova/fest architecture

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

- Interactive diagram: https://gitdiagram.com/ldanilova/fest
- Repository: https://github.com/ldanilova/fest

## Overview

##### Project Type and Purpose
- This is a single‐page R Shiny application (“FEST”) for analyzing TCR sequencing data from peptide-stimulated cultures.
- It provides an interactive web UI (app.r) that talks to server logic (app.r + manafest_shiny_functions.r) to process input data, run analyses, and render plots/tables.

##### File Structure Analysis
- app.r – Main Shiny entry point; defines UI and server function.
- manafest_shiny_functions.r – Library of data-processing and analysis functions used by the server.
- userManual.html – Static user guide displayed via the app or provided separately.
- README.md, .gitignore – Documentation and version-control exclusions.

##### Key Architectural Components
a. Shiny UI Layer
– Defines page layout, input controls (file upload, parameter selectors), output placeholders (plots, tables).
b. Shiny Server Layer
– Reactives and observers that respond to UI inputs, call analysis functions, manage data flow, and push results back to the UI.
c. Analysis Functions Module
– Encapsulated routines in manafest_shiny_functions.r (data cleaning, statistical tests, clonotype expansion analysis).
d. Data Inputs/Outputs
– Input: uploaded TCR sequencing files (CSV/TSV), user parameters.
– Output: dynamic plots (ggplot2?), tables (DT?), downloadable reports.
e. Documentation Component
– userManual.html is served as static content or via an iframe/tab in the UI.
f. External Dependencies
– R packages: shiny, data.table/dplyr, ggplot2, htmltools, etc.
– Web server hosting (e.g., Shiny Server or RStudio Connect).

##### Relationships and Data Flows
- User interacts with UI controls →
- UI triggers reactive expressions in Server →
- Server invokes functions from manafest_shiny_functions.r →
- Functions read/transform data, run analyses →
- Results (tables, plots) are returned to Server →
- Server pushes results back to UI outputs →
- User views/downloads results.
- Optional: static link to userManual.html.

##### Architectural Patterns and Design Principles
- Reactive Programming (Shiny): clear separation between UI definition and server logic.
- Modularization: isolate complex algorithms in a separate functions file for maintainability and testability.
- Single‐process model: UI and server run in one R process per user session.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Browser (UI/Client)"
        B["Browser / Client"]:::frontend
    end

    %% Server Layer
    subgraph "Shiny Server"
        subgraph "app.r"
            UI["app.r: UI Definition"]:::server
            SV["app.r: Server Logic"]:::server
        end
        AF["Analysis Functions Module<br>(manafest_shiny_functions.r)"]:::server
    end

    %% Data Layer
    DI["Uploaded Files (CSV/TSV)"]:::data

    %% Documentation Layer
    subgraph "Documentation"
        UM["userManual.html"]:::docs
        RM["README.md"]:::docs
        GI[".gitignore"]:::docs
    end

    %% External Dependencies
    EX["External Packages<br/>(shiny, dplyr, ggplot2, etc.)"]:::external

    %% Connections
    B -->|"HTTP Request / upload data"| SV
    SV -->|"invoke functions"| AF
    AF -->|"read/transform data"| DI
    AF -->|"return analysis results"| SV
    SV -->|"render plots/tables"| B
    B -->|"view manual"| UM
    SV -->|"use packages"| EX

    %% Click Events
    click UI "https://github.com/ldanilova/fest/blob/master/app.r"
    click SV "https://github.com/ldanilova/fest/blob/master/app.r"
    click AF "https://github.com/ldanilova/fest/blob/master/manafest_shiny_functions.r"
    click UM "https://github.com/ldanilova/fest/blob/master/userManual.html"
    click RM "https://github.com/ldanilova/fest/blob/master/README.md"
    click GI "https://github.com/ldanilova/fest/blob/master/.gitignore"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#003366,color:#003366;
    classDef server fill:#DFF2D8,stroke:#336600,color:#336600;
    classDef data fill:#FFE8A1,stroke:#CC8400,color:#CC8400;
    classDef docs fill:#F0F0F0,stroke:#888888,color:#555555;
    classDef external fill:#E0E0E0,stroke:#666666,color:#333333;
```
