# lovepurohit/clipify architecture

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

- Interactive diagram: https://gitdiagram.com/lovepurohit/clipify
- Repository: https://github.com/lovepurohit/clipify

## Overview

##### Project Type and Purpose
- Clipify is a lightweight, monolithic full-stack web application written in Go, using SQLite for storage.
- It provides a secure clipboard-sharing service across devices via HTTPS (and HTTP), serving a static web UI and a JSON-based API.

##### File Structure
- Top-level files:
- main.go – entry point, HTTP/HTTPS server setup, routing, handlers
- go.mod / go.sum – Go module dependencies
- Dockerfile & .goreleaser.yml – containerization and release automation
- localhost.crt/key/csr – self-signed SSL certs for HTTPS
- static/ – static assets (index.html, CSS, JS) for the frontend UI
- Hidden config:
- .github/workflows – CI/CD pipelines (release publishing)
- .gitignore, LICENSE, README.md

##### README for Additional Insights
- HTTP & HTTPS endpoints (ports configurable via CLIPIFY_HTTP_PORT and CLIPIFY_HTTPS_PORT)
- Frontend delivers copy/paste UI, language detection, and clip management features.
- Backend uses modernc.org/sqlite for persistent storage and logs metadata (timestamp, OS, detected language).
- Docker setup uses host networking to expose the same ports inside the container.

a. Main Components
- Client Devices (Desktop, Mobile browsers)
- Web Browser UI (static assets: index.html, CSS, JS)
- HTTP/HTTPS Layer (port 8080 / 8443)
- Clipify Go Server (request router, business logic, language detection, metadata capture)
- Database (SQLite file)
- SSL Certificates (localhost.crt, localhost.key)
- (Optional) Docker Host / Container

b. Relationships & Interactions
- Client → Browser UI: GET / → static index.html
- Browser UI → Go Server API: POST /api/clip, GET /api/clips, DELETE /api/clips
- Go Server → SQLite: SQL read/write operations for clip storage
- Go Server logs metadata to SQLite
- Go Server serves static files directly from the embedded `static/` folder
- Docker container binds host network to Go Server’s HTTP/HTTPS ports

c. Architectural Patterns & Design Principles
- Monolithic three-tier pattern: Presentation (static UI), Application (Go HTTP handlers), Data (SQLite).
- Embedded static assets—no external CDN.
- Environment-driven configuration for ports.
- Secure by design: HTTPS enforced with self-signed certs.

d. Key Technologies & Frameworks
- Go 1.23 (net/http package, custom handlers)
- modernc.org/sqlite (Go binding for SQLite)
- Docker (containerization, host networking)
- GitHub Actions & GoReleaser (CI/CD)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Clients & Browsers"
        Browser["Web Browser (Desktop/Mobile)"]:::client
    end

    subgraph "Server Layer"
        direction TB
        GoServer["Clipify Go HTTP Server"]:::server
        SSL["SSL Certificates"]:::infra
        Docker["Docker Container"]:::infra
    end

    subgraph "Data Layer"
        SQLite["SQLite Database"]:::data
    end

    subgraph "Project Files"
        GoMod["go.mod"]:::files
        GoSum["go.sum"]:::files
        CI[".github/workflows/release-publish.yml"]:::files
        GoReleaser[".goreleaser.yml"]:::files
        Readme["README.md"]:::files
        License["LICENSE"]:::files
        Gitignore[".gitignore"]:::files
    end

    Browser -->|"HTTP/HTTPS requests"| GoServer
    GoServer -->|"SQL read/write"| SQLite
    Docker -->|“binds ports & host network”| GoServer
    Docker -->|“contains DB & Certs”| SQLite
    Docker -->|“contains Certs”| SSL

    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef server fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFA500,stroke:#333,stroke-width:1px
    classDef infra fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef files fill:#F0F0F0,stroke:#333,stroke-width:1px

    click GoServer "https://github.com/lovepurohit/clipify/blob/develop/main.go"
    click SSL "https://github.com/lovepurohit/clipify/blob/develop/localhost.crt"
    click SSL "https://github.com/lovepurohit/clipify/blob/develop/localhost.key"
    click SSL "https://github.com/lovepurohit/clipify/blob/develop/localhost.csr"
    click Docker "https://github.com/lovepurohit/clipify/tree/develop/Dockerfile"
    click GoMod "https://github.com/lovepurohit/clipify/blob/develop/go.mod"
    click GoSum "https://github.com/lovepurohit/clipify/blob/develop/go.sum"
    click CI "https://github.com/lovepurohit/clipify/blob/develop/.github/workflows/release-publish.yml"
    click GoReleaser "https://github.com/lovepurohit/clipify/blob/develop/.goreleaser.yml"
    click Readme "https://github.com/lovepurohit/clipify/blob/develop/README.md"
    click License "https://github.com/lovepurohit/clipify/tree/develop/LICENSE"
    click Gitignore "https://github.com/lovepurohit/clipify/blob/develop/.gitignore"
```
