# mariavyso/fact-data-modeling-pub-mariavyso architecture

> Architecture diagram of the GitHub repository mariavyso/fact-data-modeling-pub-mariavyso, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mariavyso/fact-data-modeling-pub-mariavyso
- Repository: https://github.com/mariavyso/fact-data-modeling-pub-mariavyso

## Overview

##### Project Type and Purpose
- This repository is not a typical full-stack app but an automated grading harness for a SQL assignment (“Fact Data Modeling”).
- Students supply SQL files in the **`submission/`** folder; the system runs tests against those queries, generates feedback, and posts results via GitHub.

##### File Structure Analysis
- **Top-level**
- `.github/workflows/autograding.yml` – CI pipeline definition
- `Dockerfile` – container spec for the test runner
- `README.md` – assignment instructions
- **`_app/`** – core grading application
- `requirements.txt` – Python dependencies
- `src/entrypoint.sh` – container entrypoint, kicks off tests and comment generation
- `src/trino_tests.py` – logic to connect to Trino, execute SQL tests, collect results
- `src/generate_comment.py` – assembles test results and posts comments to the PR via GitHub API
- `src/util.py` – shared helper functions
- **`submission/`** – student‐editable files (`query_1.sql` … `query_8.sql`)

##### README Insights
- Emphasis on **not** modifying `_app`, `Dockerfile`, or `.github` (they power automation).
- Tests are triggered by opening a PR; results are passed to TAs automatically.
- Under the hood, the harness spins up a container, runs Trino against sample data, and uses Python scripts to drive the workflow.

a. Main Components
- **Student Submission** (SQL files in `submission/`)
- **GitHub Actions CI** (`.github/workflows/autograding.yml`)
- **Docker Container** (built from `Dockerfile`)
- **Entry Point Script** (`entrypoint.sh`)
- **Test Runner** (`trino_tests.py` + Trino engine)
- **Feedback Generator** (`generate_comment.py` + GitHub API)
b. Relationships & Interactions
1. Student pushes code → GitHub Action triggers on PR
2. CI builds Docker image (includes `_app` code + Python deps)
3. Container runs `entrypoint.sh`
4. `trino_tests.py` connects to Trino, loads `submission/*.sql`, executes and validates results
5. Results passed to `generate_comment.py`, which calls GitHub API to post feedback on the PR
c. Architectural Patterns
- **CI/CD Pipeline**: Automated workflow triggered by pull request events
- **Containerization**: Isolated grading environment for reproducibility
- **Modular Scripts**: Separate concerns (testing vs. comment generation)
d. Technology & Framework Highlights
- **GitHub Actions** for orchestration
- **Docker** for consistent runtime
- **Python** (with dependencies in `requirements.txt`) as the glue
- **Trino** (Presto) as the SQL execution engine
- **GitHub API** for publishing results

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "CI/CD Layer"
        PR["Pull Request Event"]:::infra
        Workflow["GitHub Actions CI\n(.github/workflows/autograding.yml)"]:::infra
    end

    subgraph "Automation Artifacts"
        README["Assignment Instructions\n(README.md)"]:::codeArtifacts
        SSub["Student Submission\n(submission/*.sql)"]:::codeArtifacts
    end

    subgraph "Containerization"
        DockerfileNode["Dockerfile"]:::infra
        Requirements["Python Dependencies\n(requirements.txt)"]:::codeArtifacts
        Util["Shared Utilities\n(util.py)"]:::codeArtifacts
        Entrypoint["Entrypoint Script\n(entrypoint.sh)"]:::codeArtifacts
        TrinoTests["Test Runner\n(trino_tests.py)"]:::codeArtifacts
    end

    subgraph "Execution Layer"
        Trino["Trino Cluster"]:::infra
    end

    subgraph "Notification Layer"
        GenerateComment["Feedback Generator\n(generate_comment.py)"]:::codeArtifacts
        GitHubAPI["GitHub API"]:::infra
    end

    PR -->|triggers| Workflow
    Workflow -->|builds image| DockerfileNode
    DockerfileNode -->|installs deps| Requirements
    Requirements -->|invokes| Entrypoint
    Entrypoint -->|loads helpers| Util
    Entrypoint -->|runs tests| TrinoTests
    SSub -->|SQL artifacts| TrinoTests
    TrinoTests -->|executes queries| Trino
    TrinoTests -->|passes results| GenerateComment
    GenerateComment -->|calls| GitHubAPI
    GitHubAPI -->|posts feedback| PR

    click SSub "https://github.com/mariavyso/fact-data-modeling-pub-mariavyso/tree/main/submission/"
    click Workflow "https://github.com/mariavyso/fact-data-modeling-pub-mariavyso/blob/main/.github/workflows/autograding.yml"
    click DockerfileNode "https://github.com/mariavyso/fact-data-modeling-pub-mariavyso/tree/main/Dockerfile"
    click README "https://github.com/mariavyso/fact-data-modeling-pub-mariavyso/blob/main/README.md"
    click Requirements "https://github.com/mariavyso/fact-data-modeling-pub-mariavyso/blob/main/_app/requirements.txt"
    click Util "https://github.com/mariavyso/fact-data-modeling-pub-mariavyso/blob/main/_app/src/util.py"
    click Entrypoint "https://github.com/mariavyso/fact-data-modeling-pub-mariavyso/blob/main/_app/src/entrypoint.sh"
    click TrinoTests "https://github.com/mariavyso/fact-data-modeling-pub-mariavyso/blob/main/_app/src/trino_tests.py"
    click GenerateComment "https://github.com/mariavyso/fact-data-modeling-pub-mariavyso/blob/main/_app/src/generate_comment.py"

    classDef codeArtifacts fill:#ADD8E6,stroke:#000,color:#000
    classDef infra fill:#90EE90,stroke:#000,color:#000

    linkStyle 0,1,2,3,4,5,7,8,9 stroke:#FFA500,stroke-width:2px
    linkStyle 6,10 stroke:#808080,stroke-width:2px
```
