# saadullah990123/freelance-invoice-studio architecture

> Architecture diagram of the GitHub repository saadullah990123/freelance-invoice-studio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saadullah990123/freelance-invoice-studio
- Repository: https://github.com/saadullah990123/freelance-invoice-studio

## Overview

Clearledger is a freelancer billing workspace. The main workflow is to sign in, manage clients and projects, log billable hours, turn those hours into invoice items, edit and preview invoices, then export or email them and track payment status and earnings. The graph also includes profile settings, guides, PDF generation, and the Firestore data layer. Edges reflect shown imports and calls or README-described behavior; the email-server connection is unverified because its request wiring was not shown.

Main entry points: [`src/App.tsx`](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/App.tsx) (App Coordinator), [`src/services/firestoreService.ts`](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/services/firestoreService.ts) (Firestore Service), [`src/utils/invoiceCalculations.ts`](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/utils/invoiceCalculations.ts) (Invoice Calculations), [`src/components/InvoiceEditor.tsx`](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/InvoiceEditor.tsx) (Invoice Editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace UI"]
  node_app["App Coordinator<br/>[App.tsx]"]
  node_auth["Authentication Context<br/>[AuthContext.tsx]"]
  node_authgate["Sign-in Gate<br/>[AuthGateView.tsx]"]
  node_topbar["Navigation<br/>[TopBar.tsx]"]
  node_clients["Client Directory<br/>[ClientsView.tsx]"]
  node_profile["Profile Settings"]
  node_guides["Guides<br/>[GuidesView.tsx]"]
end

subgraph group_billing["Billing Workflow"]
  node_time["Time Tracker"]
  node_editor["Invoice Editor<br/>[InvoiceEditor.tsx]"]
  node_preview["Invoice Preview<br/>[InvoicePreview.tsx]"]
  node_tracker["Invoice Tracker<br/>[InvoiceTracker.tsx]"]
end

subgraph group_shared["Shared Logic"]
  node_model["Billing Types<br/>[invoice.ts]"]
  node_defaults["Invoice Defaults<br/>[defaultInvoices.ts]"]
  node_calculations["Invoice Calculations"]
  node_validation["Input Validation<br/>[validation.ts]"]
end

subgraph group_persistence["Cloud Data"]
  node_firebase["Firebase Client<br/>[firebase.ts]"]
  node_firestore["Firestore Service"]
  node_database[("Cloud Firestore")]
  node_firebaseauth["Firebase Auth"]
end

subgraph group_delivery["Invoice Delivery"]
  node_pdf["Invoice PDF Export<br/>[exportPdf.ts]"]
  node_guidepdf["Guide PDF Export<br/>[exportDocsPdf.ts]"]
  node_email["Email Modal<br/>[SendEmailModal.tsx]"]
  node_server["Express Server<br/>[server.ts]"]
end

node_freelancer(("Freelancer"))

node_freelancer -->|"signs in"| node_authgate
node_authgate -->|"requests sign-in"| node_auth
node_auth -->|"uses auth client"| node_firebase
node_firebase -->|"authenticates with"| node_firebaseauth
node_app -->|"shows when signed out"| node_authgate
node_app -->|"renders"| node_clients
node_app -->|"renders"| node_time
node_app -->|"renders"| node_editor
node_app -->|"renders"| node_preview
node_app -->|"renders"| node_tracker
node_app -->|"renders"| node_profile
node_app -->|"renders"| node_topbar
node_app -->|"renders"| node_guides
node_app -->|"opens"| node_email
node_time -->|"requests conversion"| node_app
node_app -->|"creates invoice"| node_defaults
node_app -->|"saves invoice and bills logs"| node_firestore
node_editor -->|"computes totals"| node_calculations
node_editor -->|"validates input"| node_validation
node_editor -->|"uses invoice defaults"| node_defaults
node_clients -->|"validates email"| node_validation
node_clients -->|"summarizes invoices"| node_calculations
node_preview -->|"exports invoice"| node_pdf
node_preview -->|"computes display totals"| node_calculations
node_tracker -->|"downloads invoice"| node_pdf
node_email -->|"attaches PDF data"| node_pdf
node_guides -->|"exports guide"| node_guidepdf
node_pdf -->|"formats totals"| node_calculations
node_firestore -->|"uses client and errors"| node_firebase
node_firestore -->|"reads and writes records"| node_database
node_firestore -->|"sanitizes records"| node_validation
node_firestore -->|"creates profile defaults"| node_defaults
node_firestore -->|"updates earnings"| node_calculations
node_email -.->|"may submit email request"| node_server
node_server -->|"uses admin setup"| node_firebase

click node_app "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/App.tsx"
click node_auth "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/context/AuthContext.tsx"
click node_authgate "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/AuthGateView.tsx"
click node_topbar "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/TopBar.tsx"
click node_clients "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/ClientsView.tsx"
click node_profile "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/ProfileSettingsView.tsx"
click node_guides "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/GuidesView.tsx"
click node_time "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/TimeTrackerView.tsx"
click node_editor "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/InvoiceEditor.tsx"
click node_preview "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/InvoicePreview.tsx"
click node_tracker "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/InvoiceTracker.tsx"
click node_model "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/types/invoice.ts"
click node_defaults "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/data/defaultInvoices.ts"
click node_calculations "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/utils/invoiceCalculations.ts"
click node_validation "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/utils/validation.ts"
click node_pdf "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/utils/exportPdf.ts"
click node_guidepdf "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/utils/exportDocsPdf.ts"
click node_email "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/SendEmailModal.tsx"
click node_server "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/server.ts"
click node_firebase "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/lib/firebase.ts"
click node_firestore "https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/services/firestoreService.ts"

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_app,node_auth,node_authgate,node_topbar,node_clients,node_profile,node_guides toneBlue
class node_time,node_editor,node_preview,node_tracker toneAmber
class node_model,node_defaults,node_calculations,node_validation toneMint
class node_firebase,node_firestore,node_database,node_firebaseauth toneRose
class node_pdf,node_guidepdf,node_email,node_server,node_freelancer toneIndigo
```

## Components

### Workspace UI

- [App Coordinator](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/App.tsx): `src/App.tsx`
- [Authentication Context](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Sign-in Gate](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/AuthGateView.tsx): `src/components/AuthGateView.tsx`
- [Navigation](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/TopBar.tsx): `src/components/TopBar.tsx`
- [Client Directory](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/ClientsView.tsx): `src/components/ClientsView.tsx`
- [Profile Settings](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/ProfileSettingsView.tsx): `src/components/ProfileSettingsView.tsx`
- [Guides](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/GuidesView.tsx): `src/components/GuidesView.tsx`

### Billing Workflow

- [Time Tracker](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/TimeTrackerView.tsx): `src/components/TimeTrackerView.tsx`
- [Invoice Editor](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/InvoiceEditor.tsx): `src/components/InvoiceEditor.tsx`
- [Invoice Preview](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/InvoicePreview.tsx): `src/components/InvoicePreview.tsx`
- [Invoice Tracker](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/InvoiceTracker.tsx): `src/components/InvoiceTracker.tsx`

### Shared Logic

- [Billing Types](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/types/invoice.ts): `src/types/invoice.ts`
- [Invoice Defaults](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/data/defaultInvoices.ts): `src/data/defaultInvoices.ts`
- [Invoice Calculations](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/utils/invoiceCalculations.ts): `src/utils/invoiceCalculations.ts`
- [Input Validation](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/utils/validation.ts): `src/utils/validation.ts`

### Cloud Data

- [Firebase Client](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/lib/firebase.ts): `src/lib/firebase.ts`
- [Firestore Service](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/services/firestoreService.ts): `src/services/firestoreService.ts`
- **Cloud Firestore**
- **Firebase Auth**

### Invoice Delivery

- [Invoice PDF Export](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/utils/exportPdf.ts): `src/utils/exportPdf.ts`
- [Guide PDF Export](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/utils/exportDocsPdf.ts): `src/utils/exportDocsPdf.ts`
- [Email Modal](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/src/components/SendEmailModal.tsx): `src/components/SendEmailModal.tsx`
- [Express Server](https://github.com/saadullah990123/freelance-invoice-studio/blob/main/server.ts): `server.ts`

### Other components

- **Freelancer**

## Connections

- Freelancer → Sign-in Gate: signs in (evidence: `README.md`)
- Sign-in Gate → Authentication Context: requests sign-in (evidence: `src/components/AuthGateView.tsx`)
- Authentication Context → Firebase Client: uses auth client (evidence: `src/context/AuthContext.tsx`)
- Firebase Client → Firebase Auth: authenticates with (evidence: `src/lib/firebase.ts`)
- App Coordinator → Sign-in Gate: shows when signed out (evidence: `src/App.tsx`)
- App Coordinator → Client Directory: renders (evidence: `src/App.tsx`)
- App Coordinator → Time Tracker: renders (evidence: `src/App.tsx`)
- App Coordinator → Invoice Editor: renders (evidence: `src/App.tsx`)
- App Coordinator → Invoice Preview: renders (evidence: `src/App.tsx`)
- App Coordinator → Invoice Tracker: renders (evidence: `src/App.tsx`)
- App Coordinator → Profile Settings: renders (evidence: `src/App.tsx`)
- App Coordinator → Navigation: renders (evidence: `src/App.tsx`)
- App Coordinator → Guides: renders (evidence: `src/App.tsx`)
- App Coordinator → Email Modal: opens (evidence: `src/App.tsx`)
- Time Tracker → App Coordinator: requests conversion (evidence: `README.md`)
- App Coordinator → Invoice Defaults: creates invoice (evidence: `src/App.tsx`)
- App Coordinator → Firestore Service: saves invoice and bills logs (evidence: `src/App.tsx`)
- Invoice Editor → Invoice Calculations: computes totals (evidence: `src/components/InvoiceEditor.tsx`)
- Invoice Editor → Input Validation: validates input (evidence: `src/components/InvoiceEditor.tsx`)
- Invoice Editor → Invoice Defaults: uses invoice defaults (evidence: `src/components/InvoiceEditor.tsx`)
- Client Directory → Input Validation: validates email (evidence: `src/components/ClientsView.tsx`)
- Client Directory → Invoice Calculations: summarizes invoices (evidence: `src/components/ClientsView.tsx`)
- Invoice Preview → Invoice PDF Export: exports invoice (evidence: `src/components/InvoicePreview.tsx`)
- Invoice Preview → Invoice Calculations: computes display totals (evidence: `src/components/InvoicePreview.tsx`)
- Invoice Tracker → Invoice PDF Export: downloads invoice (evidence: `src/components/InvoiceTracker.tsx`)
- Email Modal → Invoice PDF Export: attaches PDF data (evidence: `src/components/SendEmailModal.tsx`)
- Guides → Guide PDF Export: exports guide (evidence: `src/components/GuidesView.tsx`)
- Invoice PDF Export → Invoice Calculations: formats totals (evidence: `src/utils/exportPdf.ts`)
- Firestore Service → Firebase Client: uses client and errors (evidence: `src/services/firestoreService.ts`)
- Firestore Service → Cloud Firestore: reads and writes records (evidence: `src/services/firestoreService.ts`)
- Firestore Service → Input Validation: sanitizes records (evidence: `src/services/firestoreService.ts`)
- Firestore Service → Invoice Defaults: creates profile defaults (evidence: `src/services/firestoreService.ts`)
- Firestore Service → Invoice Calculations: updates earnings (evidence: `src/services/firestoreService.ts`)
- Email Modal → Express Server: may submit email request
- Express Server → Firebase Client: uses admin setup (evidence: `server.ts`)
