# princeunadkat-dev/text-storage architecture

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

- Interactive diagram: https://gitdiagram.com/princeunadkat-dev/text-storage
- Repository: https://github.com/princeunadkat-dev/text-storage

## Overview

##### Project Type and Purpose
- Full-stack single-page web application with a static frontend and a minimal Node.js backend proxy.
- Purpose: Let users store/retrieve text in Firebase, generate QR codes, copy text, and send it via email (without exposing secrets).

##### File Structure
- Top-level files:
– index.html, script.js → Static frontend
– server.js → Express backend proxy for email
– .env → Secrets for Sendinblue/Brevo API (gitignored)
– CNAME → Custom domain configuration
- No separate “src” folders; everything lives at root, simplifying component boundaries.

##### Key Architecture Insights from README
- Frontend directly communicates with Firebase for storage.
- Frontend POSTs to `/send-email` on the Node.js server to relay email requests securely.
- Backend uses `express`, `node-fetch`, `cors`, and `dotenv` to call Sendinblue/Brevo’s API.
- QR-generation and copy-to-clipboard handled entirely in the browser.

##### Main Components and Their Roles
a. User Browser (Client)
– index.html, script.js
– UI: dark theme, card layout, chat-style animation
– Libraries: Firebase SDK, QR-code JS library
b. Static Hosting Layer
– Serves index.html & script.js (can be Netlify, Vercel, S3 + CloudFront)
c. Firebase
– Data storage & retrieval (Realtime Database or Firestore)
– Provides JS SDK endpoints
d. Node.js Backend (server.js)
– Endpoint: POST /send-email
– Reads API key & sender info from .env
– Uses express + cors + node-fetch → Sendinblue/Brevo REST API
e. External Email Service (Sendinblue/Brevo)
– Actual mail delivery

##### Architectural Patterns & Principles
- Separation of concerns: UI vs. business logic vs. secret management.
- Client-heavy app: most logic (QR, clipboard, Firebase calls) lives in browser.
- Backend as a secure proxy for email to protect API keys.
- Static vs. dynamic: Static hosting for UI, dynamic Node.js for protected operations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User Browser"]:::user
    subgraph "Static Host"
        FE1["Frontend UI<br/>(index.html)"]:::frontend
        FE2["Frontend Logic<br/>(script.js)"]:::frontend
    end
    subgraph "Node Server"
        BE["Email Proxy API<br/>(server.js)"]:::backend
        ENV["Env Variables<br/>(.env)"]:::infra
    end
    Firebase[(Firebase)]:::db
    Send["Sendinblue/Brevo"]:::thirdparty
    Docs["Project Docs<br/>(README.md)"]:::docs
    GitIg["Git Ignore Rules<br/>(.gitignore)"]:::docs
    Cfg["Hosting Config<br/>(CNAME)"]:::infra
    Dom["Domain Reference<br/>(domain.txt)"]:::infra

    U -->|Loads page| FE1
    FE1 -->|Initializes logic| FE2
    FE2 -->|SDK GET/SET| Firebase
    FE2 -->|POST /send-email| BE
    BE -->|Sends email via API| Send
    Send -->|ACK response| BE
    BE -->|200 OK| FE2

    click FE1 "https://github.com/princeunadkat-dev/text-storage/blob/main/index.html"
    click FE2 "https://github.com/princeunadkat-dev/text-storage/blob/main/script.js"
    click BE "https://github.com/princeunadkat-dev/text-storage/blob/main/server.js"
    click ENV "https://github.com/princeunadkat-dev/text-storage/blob/main/.env"
    click Cfg "https://github.com/princeunadkat-dev/text-storage/tree/main/CNAME"
    click Dom "https://github.com/princeunadkat-dev/text-storage/blob/main/domain.txt"
    click Docs "https://github.com/princeunadkat-dev/text-storage/blob/main/README.md"
    click GitIg "https://github.com/princeunadkat-dev/text-storage/blob/main/.gitignore"

    classDef user fill:#FFFFFF,stroke:#333,stroke-dasharray:5 5
    classDef frontend fill:#ADD8E6,stroke:#333
    classDef backend fill:#90EE90,stroke:#333
    classDef db fill:#FFA500,stroke:#333
    classDef thirdparty fill:#D8BFD8,stroke:#333
    classDef infra fill:#E0E0E0,stroke:#333
    classDef docs fill:#F5F5F5,stroke:#333
```
