# nomandhoni-cs/blink-eye architecture

> Architecture diagram of the GitHub repository nomandhoni-cs/blink-eye, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nomandhoni-cs/blink-eye
- Repository: https://github.com/nomandhoni-cs/blink-eye

## Overview

##### Project type and purpose
- This repository contains two distinct but related applications:
- A desktop app built with Tauri (Rust + React/Vite) named “Blink Eye,” designed to remind users to take eye-care breaks.
- An accompanying Next.js/React website for marketing, documentation, blog posts, and license validation APIs.
- The desktop app’s primary use cases: configurable timers, full-screen reminders, audio control, usage tracking, licensing.
- The website’s purpose: static-and-serverless content delivery with internationalization, blog, docs, and lightweight API routes for licensing.

##### File structure
- Top-level directories:
- src-tauri: Rust code, Tauri config, desktop capabilities, assets, command handlers.
- src: React/TypeScript UI for the desktop; organized by components, hooks, services, contexts, lib, styles.
- website: Next.js app with pages, app directory (for new App Router), public assets, API routes, i18n, config, components.
- Key patterns:
- Desktop UI uses a component-based, hook-driven structure with context providers for global state.
- app-api folder abstracts calls to Tauri’s JS–Rust bridge (notifications, tray, shortcuts).
- Rust backend defines “commands” in src-tauri/src/main.rs that the UI invokes.
- Website uses Next.js file-system routing (SSR/SSG), serverless API endpoints (route.ts), and i18n configuration.
- Configuration files show Vite for the desktop UI, Cargo.toml for Rust, package.json for JS, tailwind.config, tsconfig, GitHub workflows for CI/CD.

##### README for additional insights
- The README confirms core desktop features, Tauri + Rust + Bun + Cargo development flow.
- Website setup instructions show a separate Bun-based workflow.
- Licensing model uses GPLv3 + commercial option; website contains API endpoints to validate licenses.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Desktop App"
        subgraph "UI Layer"
            ReactUI["React UI"]:::frontend
        end
        subgraph "Tauri API Layer"
            SetupNot["setupNotifications.ts"]:::backend
            SetupShort["setupShortcuts.ts"]:::backend
            SetupTray["setupTray.ts"]:::backend
        end
        subgraph "Rust Backend"
            MainRs["main.rs"]:::backend
            LibRs["lib.rs"]:::backend
        end
        subgraph "OS / Native Services"
            Notifications["OS Notifications"]:::external
            Tray["System Tray"]:::external
            Shortcuts["Global Shortcuts"]:::external
            Audio["Audio Control"]:::external
        end
        DataStore["Local Storage (JSON/SQLite)"]:::storage
    end

    subgraph "Website"
        subgraph "Frontend"
            NextApp["Next.js App Router"]:::frontend
            SharedComp["Shared Components"]:::frontend
        end
        subgraph "Serverless API"
            HelloApi["hello/route.ts"]:::backend
            ActivateApi["activatelicense/route.ts"]:::backend
            ValidateApi["validatelicense/route.ts"]:::backend
            BasicUserApi["basicUserData/route.ts"]:::backend
        end
        ContentStore["Markdown Posts & i18n JSON"]:::storage
    end

    ExternalLicense["License Server API"]:::external

    ReactUI -->|"calls"| SetupNot
    ReactUI -->|"calls"| SetupShort
    ReactUI -->|"calls"| SetupTray
    SetupNot -->|"invoke"| MainRs
    SetupShort -->|"invoke"| MainRs
    SetupTray -->|"invoke"| MainRs
    MainRs -->|"delegates"| LibRs
    LibRs -->|"read/write"| DataStore
    LibRs -->|"call"| Notifications
    LibRs -->|"call"| Tray
    LibRs -->|"call"| Shortcuts
    LibRs -->|"call"| Audio
    ReactUI -->|"validates license via"| ActivateApi
    ReactUI -->|"checks license via"| ValidateApi

    NextApp -->|"fetches content"| ContentStore
    NextApp -->|"calls"| HelloApi
    NextApp -->|"calls"| ActivateApi
    NextApp -->|"calls"| ValidateApi
    NextApp -->|"calls"| BasicUserApi

    ValidateApi -->|"reads"| ContentStore
    ActivateApi -->|"reads/writes"| ContentStore
    BasicUserApi -->|"reads"| ContentStore
    HelloApi -->|"reads"| ContentStore

    click ReactUI "https://github.com/nomandhoni-cs/blink-eye/blob/master/src/main.tsx"
    click SetupNot "https://github.com/nomandhoni-cs/blink-eye/blob/master/src/app-api/setupNotifications.ts"
    click SetupShort "https://github.com/nomandhoni-cs/blink-eye/blob/master/src/app-api/setupShortcuts.ts"
    click SetupTray "https://github.com/nomandhoni-cs/blink-eye/blob/master/src/app-api/setupTray.ts"
    click MainRs "https://github.com/nomandhoni-cs/blink-eye/blob/master/src-tauri/src/main.rs"
    click LibRs "https://github.com/nomandhoni-cs/blink-eye/blob/master/src-tauri/src/lib.rs"
    click DataStore "https://github.com/nomandhoni-cs/blink-eye/blob/master/src/lib/migrateScreenTimeToSQLite.ts"
    click NextApp "https://github.com/nomandhoni-cs/blink-eye/blob/master/website/app/layout.tsx"
    click SharedComp "https://github.com/nomandhoni-cs/blink-eye/tree/master/website/components/"
    click HelloApi "https://github.com/nomandhoni-cs/blink-eye/blob/master/website/app/api/hello/route.ts"
    click ActivateApi "https://github.com/nomandhoni-cs/blink-eye/blob/master/website/app/api/activatelicense/route.ts"
    click ValidateApi "https://github.com/nomandhoni-cs/blink-eye/blob/master/website/app/api/validatelicense/route.ts"
    click BasicUserApi "https://github.com/nomandhoni-cs/blink-eye/blob/master/website/app/api/basicUserData/route.ts"
    click ContentStore "https://github.com/nomandhoni-cs/blink-eye/tree/master/website/_posts/"

    classDef frontend fill:#E0F7FA,stroke:#0288D1,stroke-width:2px
    classDef backend fill:#E8F5E9,stroke:#2E7D32,stroke-width:2px
    classDef storage fill:#F5F5F5,stroke:#9E9E9E,stroke-width:2px
    classDef external fill:#FFF3E0,stroke:#EF6C00,stroke-width:2px
```
