# grylls20/summitron architecture

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

- Interactive diagram: https://gitdiagram.com/grylls20/summitron
- Repository: https://github.com/grylls20/summitron

## Overview

##### Project type and purpose
- Summitron is a decoupled full-stack web application.
- Purpose: Accept a URL for an online article, call an AI-powered summarization service, and return a concise summary to the user.

##### File structure
- Top-level directories:
- `frontend/` – static site (HTML, CSS, JS)
- `src/main/java/com/example/summitron/` – Spring Boot backend source
- `Dockerfile`, `pom.xml` and Maven wrapper files – build & containerization
- `netlify.toml` – Netlify configuration for frontend hosting
- Key backend components:
- `SummitronController.java` – REST endpoint
- `SummarizationService.java` – business logic calling Together AI API
- `WebConfig.java` – CORS or static‐resource configuration
- Deployment files:
- `Dockerfile` for backend container
- `netlify.toml` for frontend hosting
- `application.properties` for runtime configuration (port, API key via env var)

##### Extract architectural insights from the README
- Frontend: a static single-page site deployed to Netlify
- Backend: Spring Boot REST API containerized in Docker and deployed to Google Cloud Run
- External dependency: Together AI (Llama 3) via HTTP API
- Communication: Frontend uses Fetch API to invoke the backend’s `/summarize` endpoint asynchronously

##### Main components and interactions
a. Components
1. User Browser (UI)
2. Netlify-hosted Frontend (HTML/CSS/JS)
3. Spring Boot API (Google Cloud Run container)
4. Together AI External Service (Llama 3 model)
5. Configuration/Secrets store (Netlify env vars, Cloud Run env vars)
b. Interactions
- User enters a URL → Frontend JS calls `fetch('https://<cloud-run>/summarize')`
- Backend receives REST request → `SummitronController` forwards to `SummarizationService`
- `SummarizationService` calls Together AI API with the user’s URL & API key
- Together AI returns summary → Backend wraps it in JSON → Frontend displays it
c. Architectural patterns and principles
- Decoupled frontend & backend (independent development & scaling)
- Single responsibility: Controller vs Service classes
- Containerization for portability (Docker + Cloud Run)
- Static hosting CDN (Netlify) for global distribution
d. Key technologies & frameworks
- Frontend: HTML5, CSS3, vanilla JavaScript (Fetch API)
- Backend: Java 11, Spring Boot, Maven
- Container: Docker
- Deployment: Netlify (frontend), Google Cloud Run (backend)
- AI Integration: Together AI REST API

##### Detail and clarity
- Call out where Docker & Maven fit in (e.g., “Built with Maven → packaged into Docker image”)
- Build/deploy pipeline: GitHub → Netlify for frontend, GitHub → Cloud Build → Cloud Run for backend

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["User Browser"]:::client

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        FE["Netlify CDN / Frontend"]:::frontend
        Index["index.html"]:::frontend
        CSS["css/style.css"]:::frontend
        Script["js/script.js"]:::frontend
        EnvJS["env.js"]:::frontend
        Styles["styles.css"]:::frontend
        NetlifyConf["netlify.toml"]:::config
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        BE["Spring Boot API (Cloud Run)"]:::backend
        App["SummitronApplication.java"]:::backend
        Ctrl["SummitronController.java"]:::backend
        Service["SummarizationService.java"]:::backend
        ConfigWeb["WebConfig.java"]:::backend
        AppProps["application.properties"]:::config
        Docker["Dockerfile"]:::config
    end

    %% External Service Layer
    TogetherAI["Together AI Service"]:::external

    %% Build Configuration
    subgraph "Build Configuration"
        direction TB
        Pom["pom.xml"]:::build
        Mvnw["mvnw"]:::build
        MvnwCmd["mvnw.cmd"]:::build
        MvnDir[".mvn/"]:::build
    end

    %% Interactions
    Browser -->|"Load Static Site (HTTPS)"| FE
    FE -->|"Fetch /summarize (HTTPS/JSON)"| BE
    BE -->|"HTTP/JSON API call"| TogetherAI
    TogetherAI -->|"JSON Summary"| BE
    BE -->|"Return JSON Summary"| FE
    FE -->|"Render Summary"| Browser

    %% Composition
    FE --> Index
    FE --> CSS
    FE --> Script
    FE --> EnvJS
    FE --> Styles
    FE --> NetlifyConf

    BE --> App
    BE --> Ctrl
    BE --> Service
    BE --> ConfigWeb
    BE --> AppProps
    BE --> Docker

    BE --> Pom
    BE --> Mvnw
    BE --> MvnwCmd
    BE --> MvnDir

    %% Click Events
    click FE "https://github.com/grylls20/summitron/tree/main/frontend/"
    click Index "https://github.com/grylls20/summitron/blob/main/frontend/index.html"
    click CSS "https://github.com/grylls20/summitron/blob/main/frontend/css/style.css"
    click Script "https://github.com/grylls20/summitron/blob/main/frontend/js/script.js"
    click EnvJS "https://github.com/grylls20/summitron/blob/main/frontend/env.js"
    click Styles "https://github.com/grylls20/summitron/blob/main/frontend/styles.css"
    click NetlifyConf "https://github.com/grylls20/summitron/blob/main/netlify.toml"
    click App "https://github.com/grylls20/summitron/blob/main/src/main/java/com/example/summitron/SummitronApplication.java"
    click Ctrl "https://github.com/grylls20/summitron/blob/main/src/main/java/com/example/summitron/SummitronController.java"
    click Service "https://github.com/grylls20/summitron/blob/main/src/main/java/com/example/summitron/SummarizationService.java"
    click ConfigWeb "https://github.com/grylls20/summitron/blob/main/src/main/java/com/example/summitron/WebConfig.java"
    click AppProps "https://github.com/grylls20/summitron/blob/main/src/main/resources/application.properties"
    click Docker "https://github.com/grylls20/summitron/tree/main/Dockerfile"
    click Pom "https://github.com/grylls20/summitron/blob/main/pom.xml"
    click Mvnw "https://github.com/grylls20/summitron/tree/main/mvnw"
    click MvnwCmd "https://github.com/grylls20/summitron/blob/main/mvnw.cmd"
    click MvnDir "https://github.com/grylls20/summitron/tree/main/.mvn/"

    %% Styles
    classDef client fill:#eef,stroke:#33a,stroke-width:2px
    classDef frontend fill:#def,stroke:#36c,stroke-width:2px
    classDef backend fill:#dfd,stroke:#2a2,stroke-width:2px
    classDef external fill:#fed,stroke:#e65,stroke-width:2px
    classDef config fill:#fdf,stroke:#c37,stroke-width:2px
    classDef build fill:#ffd,stroke:#d90,stroke-width:2px
```
