# nutlope/blinkshot architecture

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

- Interactive diagram: https://gitdiagram.com/nutlope/blinkshot
- Repository: https://github.com/nutlope/blinkshot

## Overview

##### Project type and purpose
- BlinkShot is a full-stack, server-rendered Next.js application that lets users generate AI images in real time.
- The front end (Next.js App Router + Tailwind + React) collects prompts, the back end (Next.js API routes) calls the Together.ai inference service (using Flux Schnell), and observability is handled by Helicone and Plausible.

##### File structure
- Top-level files: ESLint, Prettier, Next config, Tailwind config, PostCSS, environment examples.
- app/ — Next.js “app router” pages, layout.tsx, global styles, and app/api/generateImages/route.ts for the serverless API endpoint.
- lib/utils.ts — shared helper functions.
- middleware.ts — any request-level middleware.
- public/ — static assets (images, fonts, styles).

##### Extract insights from the README
- Core services: Flux Schnell (model), Together AI (inference), Helicone (observability), Plausible (analytics).
- Tech stack: Next.js (front/back), Tailwind CSS, React.
- No internal database today—state is ephemeral, results are returned directly.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend"
        direction TB
        Browser["Web Browser (Client UI)"]:::frontend
        NextJSApp["Next.js Frontend\n(App Router + Tailwind + React)"]:::frontend
        UIComponents["React/Tailwind UI Components"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB
        Middleware["Request Middleware"]:::backend
        APILayer["Next.js API: generateImages route"]:::backend
        Utils["Shared Utilities (lib/utils.ts)"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        TogetherAI["Together.ai Inference Service\n(Flux Schnell)"]:::external
        Helicone["Helicone Observability"]:::external
        Plausible["Plausible Analytics"]:::external
    end

    %% Static Asset Hosting
    StaticAssets["Static Assets Hosting\n(public/)"]:::backend

    %% Data Flows
    Browser -->|"POST /api/generateImages\n(HTTPS JSON)"| APILayer
    APILayer -->|"calls inference API\n(Flux Schnell SDK)"| TogetherAI
    TogetherAI -->|"returns image data\n(JSON/stream)"| APILayer
    APILayer -->|"responds with image\n(JSON/stream)"| Browser

    %% Observability & Analytics
    APILayer -->|"logs inference calls"| Helicone
    Browser -->|"pageview & events"| Plausible

    %% Middleware & Utils connections
    Browser --> Middleware
    Middleware --> APILayer
    APILayer --> Utils

    %% Static Assets serving
    Browser -->|"loads CSS, images"| StaticAssets

    %% Click Events
    click Browser "https://github.com/nutlope/blinkshot/blob/main/app/page.tsx"
    click NextJSApp "https://github.com/nutlope/blinkshot/blob/main/app/layout.tsx"
    click NextJSApp "https://github.com/nutlope/blinkshot/blob/main/app/providers.tsx"
    click NextJSApp "https://github.com/nutlope/blinkshot/blob/main/app/globals.css"
    click NextJSApp "https://github.com/nutlope/blinkshot/blob/main/tailwind.config.ts"
    click NextJSApp "https://github.com/nutlope/blinkshot/blob/main/postcss.config.mjs"
    click UIComponents "https://github.com/nutlope/blinkshot/blob/main/components/ui/button.tsx"
    click APILayer "https://github.com/nutlope/blinkshot/blob/main/app/api/generateImages/route.ts"
    click Utils "https://github.com/nutlope/blinkshot/blob/main/lib/utils.ts"
    click Middleware "https://github.com/nutlope/blinkshot/blob/main/middleware.ts"
    click StaticAssets "https://github.com/nutlope/blinkshot/tree/main/public/"

    %% Styles
    classDef frontend fill:#b2f5ea,stroke:#2c7a7b,stroke-width:1px
    classDef backend fill:#bee3f8,stroke:#2b6cb0,stroke-width:1px
    classDef external fill:#e2e8f0,stroke:#4a5568,stroke-width:1px
```
