# cassiemarie0728/snippet-bubble-manager architecture

> Architecture diagram of the GitHub repository cassiemarie0728/snippet-bubble-manager, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cassiemarie0728/snippet-bubble-manager
- Repository: https://github.com/cassiemarie0728/snippet-bubble-manager

## Overview

1. **Overall shape**
   - This repo is a two-tier app: a **React/Vite single-page frontend** plus a **separate Node backend** under `backend/`.
   - The core product is a **floating snippet manager UI** that stores and retrieves developer snippets, with Firebase handling persistence and auth.

2. **Frontend shell**
   - `src/main.tsx` boots the app, `src/App.tsx` contains the main UI/workflow, and `src/index.css` holds the global styling.
   - The frontend is the primary user-facing layer: the bubble UI, snippet browser/editor, copy actions, and folder/snippet management all live here.

3. **Shared client-side model**
   - `src/types.ts` defines the app’s domain objects, especially **Snippet** and **Folder**.
   - `src/templates.ts` likely provides canned snippet/templates content used by the UI and/or AI-assisted creation flows.

4. **Firebase boundary**
   - `src/firebase.ts` is the client integration point for Firebase.
   - The frontend appears to use **Firestore** for data storage and **Firebase Authentication** for user identity, with the app reading/writing directly from the browser.

5. **Data domain**
   - The main persisted entities are:
     - **Snippets**: title, code, language, tags, description, favorite/pinned flags, timestamps, `ownerId`, optional `folderId`, and `lastCopiedAt`.
     - **Folders**: name, timestamps, and `ownerId`.
   - This implies the app is organized around **per-user collections** with snippet-to-folder relationships and copy-history metadata.

6. **Primary user flows**
   - A user authenticates, loads their snippets/folders from Firestore, and interacts with them through the bubble interface.
   - Common actions include create/update/delete snippets, organize into folders, mark favorites/pins, and copy code to the clipboard.
   - Copying a snippet updates its `lastCopiedAt`, which is part of the app’s usage-aware sorting or recency tracking.

7. **Real-time and access control**
   - The README indicates **real-time updates** from Firebase and **ownership-based security**.
   - `firestore.rules` enforce that users can only access documents where `ownerId === request.auth.uid`, with an admin override for a specific email address.
   - This means the trust boundary is Firestore rules, not the frontend.

8. **Backend service**
   - `backend/server.js` and `backend/package.json` define a separate server process, distinct from the browser app.
   - Based on the README’s AI features, this backend likely exists to host server-side API behavior such as **Google GenAI integration** or other protected operations that should not live entirely in the client.
   - Treat it as a separate runtime from the Vite frontend.

9. **AI/editor integration**
   - The README calls out **Google GenAI** and **Monaco Editor**.
   - Architecturally, this adds an assisted-code path: the editor is the rich text/code entry surface, and AI can generate or enhance snippet content before it is saved to Firestore or copied to the clipboard.

10. **Deployment/runtime clues**
   - `vite.config.ts`, `index.html`, and root `package.json` show a standard Vite web build.
   - `dockerfile`, `docker-compose.yml`, and `render.yaml` indicate the project is intended to run in containerized or hosted environments, not just locally.
   - The Firebase config files (`firebase-applet-config.json`, `firebase-blueprint.json`) suggest Firebase project wiring is part of the deployment setup.

11. **Supporting docs and governance**
   - `API.md`, `ARCHITECTURE.md`, `CONTRIBUTING.md`, and `docs/` support onboarding and system understanding rather than runtime behavior.
   - `metadata.json` and the Firebase blueprint/config files likely support the product’s packaging or platform registration.

12. **How to draw the diagram**
   - Put the **React/Vite app** at the center, connected to **Firebase Auth + Firestore** for identity and data.
   - Show a separate **backend Node service** as a sibling runtime, likely handling AI or protected server-side endpoints.
   - Inside the frontend, show the main feature blocks as **bubble UI**, **snippet/folder management**, **Monaco editor**, and **copy-to-clipboard actions**.
   - Put **Firestore rules** on the boundary between the app and Firestore to reflect the ownership-based security model.

Main entry points: [`src/App.tsx`](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/App.tsx) (App), [`backend/server.js`](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/backend/server.js) (API Server), [`src/firebase.ts`](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/firebase.ts) (Firebase Client), [`docker-compose.yml`](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/docker-compose.yml) (Deploy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_main(("Boot<br/>entrypoint<br/>[main.tsx]"))
  node_app["App<br/>ui shell<br/>[App.tsx]"]
  node_styles["Styles<br/>global css<br/>[index.css]"]
  node_model["Models<br/>domain types<br/>[types.ts]"]
  node_templates["Templates<br/>snippet presets<br/>[templates.ts]"]
  node_client["Firebase Client<br/>sdk bridge<br/>[firebase.ts]"]
  node_bubble{{"Bubble UI<br/>interaction layer"}}
  node_library["Library<br/>snippet management"]
  node_editor["Editor"]
  node_actions(("Clipboard<br/>user actions"))
end

subgraph group_firebase["Firebase"]
  node_auth(("Auth<br/>identity service"))
  node_store[("Firestore<br/>document store")]
  node_rules{{"Rules<br/>security policy<br/>[firestore.rules]"}}
end

subgraph group_backend["Backend"]
  node_server["API Server<br/>node service<br/>[server.js]"]
  node_ai(("GenAI<br/>external ai"))
end

subgraph group_ops["Ops & Docs"]
  node_build["Web Build<br/>vite/web config<br/>[vite.config.ts]"]
  node_deploy["Deploy<br/>container/runtime<br/>[docker-compose.yml]"]
  node_docs["Docs<br/>guides<br/>[README.md]"]
end

node_main -->|"boots"| node_app
node_app -->|"renders"| node_bubble
node_app -->|"organizes"| node_library
node_app -->|"edits"| node_editor
node_app -->|"copies"| node_actions
node_app -->|"uses"| node_model
node_app -->|"seeds"| node_templates
node_app -->|"reads/writes"| node_client
node_app -->|"styles"| node_styles
node_client -->|"authenticates"| node_auth
node_client -->|"persists"| node_store
node_store -->|"governed by"| node_rules
node_server -->|"calls"| node_ai
node_server -.->|"optional data access"| node_store
node_build -->|"bundles"| node_main
node_deploy -->|"runs"| node_server
node_deploy -->|"hosts"| node_build
node_docs -.->|"describes"| node_app
node_docs -.->|"describes"| node_server

click node_main "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/main.tsx"
click node_app "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/App.tsx"
click node_styles "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/index.css"
click node_model "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/types.ts"
click node_templates "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/templates.ts"
click node_client "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/firebase.ts"
click node_rules "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/firestore.rules"
click node_server "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/backend/server.js"
click node_build "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/vite.config.ts"
click node_deploy "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/docker-compose.yml"
click node_docs "https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_app,node_styles,node_model,node_templates,node_client,node_bubble,node_library,node_editor,node_actions toneBlue
class node_auth,node_store,node_rules toneAmber
class node_server,node_ai toneMint
class node_build,node_deploy,node_docs toneRose
```

## Components

### Frontend

React/Vite single-page client

- [Boot](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/main.tsx): entrypoint · Vite application entry · `src/main.tsx`
- [App](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/App.tsx): ui shell · Main frontend workflow and bubble interface · `src/App.tsx`
- [Styles](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/index.css): global css · Application-wide styling · `src/index.css`
- [Models](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/types.ts): domain types · Snippet and folder data shapes · `src/types.ts`
- [Templates](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/templates.ts): snippet presets · Starter or canned snippet content · `src/templates.ts`
- [Firebase Client](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/src/firebase.ts): sdk bridge · Browser-side Firebase configuration and access · `src/firebase.ts`
- **Bubble UI**: interaction layer · Floating snippet manager surface
- **Library**: snippet management · Browse, organize, and manage snippets and folders
- **Editor**: code editor · Snippet editing and generation surface
- **Clipboard**: user actions · Copy and recency-tracking actions

### Firebase

Identity, persistence, and access control

- **Auth**: identity service · Firebase Authentication
- **Firestore**: document store · Per-user snippet and folder persistence
- [Rules](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/firestore.rules): security policy · Ownership-based Firestore access control · `firestore.rules`

### Backend

Separate Node runtime for protected server-side work

- [API Server](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/backend/server.js): node service · Separate backend process · `backend/server.js`
- **GenAI**: external ai · Protected AI integration used by the backend

### Ops & Docs

Build, deploy, and supporting documentation

- [Web Build](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/vite.config.ts): vite/web config · Frontend build and HTML entry wiring · `vite.config.ts`
- [Deploy](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/docker-compose.yml): container/runtime · Container and hosted deployment setup · `docker-compose.yml`
- [Docs](https://github.com/cassiemarie0728/snippet-bubble-manager/blob/main/README.md): guides · Architecture, API, and contribution docs · `README.md`

## Connections

- Boot → App: boots · Starts the frontend application
- App → Bubble UI: renders · Primary floating UI
- App → Library: organizes · Snippet and folder workflows
- App → Editor: edits · Code entry and assisted creation
- App → Clipboard: copies · Copy-to-clipboard and recency updates
- App → Models: uses · Shared snippet and folder types
- App → Templates: seeds · Template-driven snippet creation
- App → Firebase Client: reads/writes · Frontend Firebase integration
- App → Styles: styles · Global presentation layer
- Firebase Client → Auth: authenticates · User identity
- Firebase Client → Firestore: persists · Snippet and folder data
- Firestore → Rules: governed by · Ownership-based access policy
- API Server → GenAI: calls · Backend-only protected AI operations
- API Server → Firestore: optional data access · Backend may coordinate with persisted data
- Web Build → Boot: bundles · Vite build entry
- Deploy → API Server: runs · Separate backend runtime
- Deploy → Web Build: hosts · Web app build and container deployment
- Docs → App: describes · Repository guidance and system overview
- Docs → API Server: describes · Backend notes and API guidance
