# 0xlightning/myexpense-log architecture

> Architecture diagram of the GitHub repository 0xlightning/myexpense-log, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0xlightning/myexpense-log
- Repository: https://github.com/0xlightning/myexpense-log

## Overview

1. This is a single-page React application, bootstrapped with Create React App, and deployed as a static site. The main runtime is the browser, with Firebase providing backend services.

2. The app’s domain is personal/financial tracking. The top-level pages suggest separate views for Dashboard, Income, Expenditure, Exchange, Investments, OnCredit, Card, and Login, implying the UI is organized around transaction and asset categories rather than generic CRUD screens.

3. Authentication is a first-class boundary. `src/context/AuthContext.js` centralizes auth state, `src/components/auth/PrivateRoute.js` gates protected pages, and `src/pages/Login.js` handles sign-in entry. This creates a clear split between public access and authenticated application flows.

4. Application layout is separated from page content. `src/components/layout/Layout.js` and `Sidebar.js` provide the persistent shell/navigation, while the `src/pages/*` files hold the main feature screens. This is important for diagramming because most authenticated routes likely render inside the same shell.

5. There is a small shared UI component layer in `src/components/ui/` with reusable primitives such as Button, Card, Input, Modal, Table, and Tabs. These are the building blocks used across the finance pages to keep interactions and styling consistent.

6. Data access is abstracted into a service layer under `src/services/`. `firebase.js` initializes the Firebase SDK, `firestore.js` is the direct Firestore access layer, and `transactions.js` appears to encapsulate finance-specific read/write logic. This is the main boundary between UI and persistence.

7. Firestore is the primary datastore. The presence of `firestore.rules` indicates the app enforces server-side access control at the database level, which complements the React-side private route checks. The architecture is therefore “client-authenticated + Firestore-protected,” not purely client-trusted.

8. Firebase Hosting is the deployment target. `firebase.json`, `.firebaserc`, and `public/_redirects` indicate SPA hosting with route fallback support, so direct navigation to client routes resolves back to `index.html`. That matters for the routing diagram because page routing is handled client-side, not by a separate web server.

9. The `public/` folder contains the static app shell assets: `index.html`, `manifest.json`, `robots.txt`, and redirect rules. These assets support a standard CRA/Firebase SPA deployment, likely with progressive-web-app-friendly metadata but no separate backend UI server.

10. The source tree suggests a fairly modular feature split rather than a deeply layered enterprise architecture. The main flow is: browser loads static React app → auth context resolves user state → private routes decide access → layout/sidebar frame the app → pages call service functions → Firestore stores and returns data.

11. Testing and quality tooling are minimal but standard for CRA. `App.test.js`, `setupTests.js`, and `reportWebVitals.js` show the default React testing/performance hooks are present, but there is no sign of a separate test runner, API mocking layer, or backend service test suite in this repo snapshot.

12. If you are drawing the architecture, the key boxes are: Firebase Auth/Firestore as managed backend services, React app shell and routing in the client, layout/navigation as the persistent UI layer, feature pages for financial domains, and a services layer that mediates all persistence operations.

Main entry points: [`src/components/layout/Layout.js`](https://github.com/0xlightning/myexpense-log/blob/main/src/components/layout/Layout.js) (Layout), [`src/services/transactions.js`](https://github.com/0xlightning/myexpense-log/blob/main/src/services/transactions.js) (Transactions), [`src/components/ui`](https://github.com/0xlightning/myexpense-log/tree/main/src/components/ui) (UI primitives), [`src/App.js`](https://github.com/0xlightning/myexpense-log/blob/main/src/App.js) (App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client app"]
  node_index["Entry<br/>React bootstrap<br/>[index.js]"]
  node_app["App<br/>Route shell<br/>[App.js]"]
  node_authctx(("Auth state<br/>Context<br/>[AuthContext.js]"))
  node_privateroute["Private route<br/>Route guard<br/>[PrivateRoute.js]"]
  node_login["Login<br/>Public page<br/>[Login.js]"]
  node_dashboard["Dashboard<br/>Feature page<br/>[Dashboard.js]"]
  node_income["Income<br/>Feature page<br/>[Income.js]"]
  node_expenditure["Expenditure<br/>Feature page<br/>[Expenditure.js]"]
  node_exchange["Exchange<br/>Feature page<br/>[Exchange.js]"]
  node_investments["Investments<br/>Feature page<br/>[Investments.js]"]
  node_oncredit["On credit<br/>Feature page<br/>[OnCredit.js]"]
  node_card["Card<br/>Feature page<br/>[Card.js]"]
end

subgraph group_ui["UI layer"]
  node_layout["Layout<br/>Shell<br/>[Layout.js]"]
  node_sidebar["Sidebar<br/>Navigation<br/>[Sidebar.js]"]
  node_ui_primitives["UI primitives<br/>Shared components"]
end

subgraph group_data["Data layer"]
  node_transactions["Transactions<br/>Domain service<br/>[transactions.js]"]
  node_firestore_svc["Firestore svc<br/>Data access<br/>[firestore.js]"]
  node_firebase_init["Firebase init<br/>SDK setup<br/>[firebase.js]"]
end

subgraph group_platform["Platform"]
  node_static_host["Static site<br/>CRA hosting<br/>[index.html]"]
  node_firebase_backend[("Firebase backend<br/>Managed services")]
  node_rules["Firestore rules<br/>Access control<br/>[firestore.rules]"]
end

node_static_host -->|"loads"| node_index
node_index -->|"mounts"| node_app
node_app -->|"uses"| node_authctx
node_app -->|"guards"| node_privateroute
node_app -->|"routes to"| node_login
node_privateroute -->|"renders"| node_layout
node_layout -->|"contains"| node_sidebar
node_layout -->|"frames"| node_dashboard
node_layout -->|"frames"| node_income
node_layout -->|"frames"| node_expenditure
node_layout -->|"frames"| node_exchange
node_layout -->|"frames"| node_investments
node_layout -->|"frames"| node_oncredit
node_layout -->|"frames"| node_card
node_dashboard -->|"uses"| node_ui_primitives
node_income -->|"uses"| node_ui_primitives
node_expenditure -->|"uses"| node_ui_primitives
node_exchange -->|"uses"| node_ui_primitives
node_investments -->|"uses"| node_ui_primitives
node_oncredit -->|"uses"| node_ui_primitives
node_card -->|"uses"| node_ui_primitives
node_authctx -->|"authenticates"| node_firebase_backend
node_firebase_init -->|"connects"| node_firebase_backend
node_firestore_svc -->|"uses"| node_firebase_init
node_transactions -->|"wraps"| node_firestore_svc
node_dashboard -->|"reads data"| node_transactions
node_income -->|"reads data"| node_transactions
node_expenditure -->|"reads data"| node_transactions
node_exchange -->|"reads data"| node_transactions
node_investments -->|"reads data"| node_transactions
node_oncredit -->|"reads data"| node_transactions
node_card -->|"reads data"| node_transactions
node_firebase_backend -->|"governed by"| node_rules

click node_index "https://github.com/0xlightning/myexpense-log/blob/main/src/index.js"
click node_app "https://github.com/0xlightning/myexpense-log/blob/main/src/App.js"
click node_authctx "https://github.com/0xlightning/myexpense-log/blob/main/src/context/AuthContext.js"
click node_privateroute "https://github.com/0xlightning/myexpense-log/blob/main/src/components/auth/PrivateRoute.js"
click node_login "https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Login.js"
click node_dashboard "https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Dashboard.js"
click node_income "https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Income.js"
click node_expenditure "https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Expenditure.js"
click node_exchange "https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Exchange.js"
click node_investments "https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Investments.js"
click node_oncredit "https://github.com/0xlightning/myexpense-log/blob/main/src/pages/OnCredit.js"
click node_card "https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Card.js"
click node_layout "https://github.com/0xlightning/myexpense-log/blob/main/src/components/layout/Layout.js"
click node_sidebar "https://github.com/0xlightning/myexpense-log/blob/main/src/components/layout/Sidebar.js"
click node_ui_primitives "https://github.com/0xlightning/myexpense-log/tree/main/src/components/ui"
click node_transactions "https://github.com/0xlightning/myexpense-log/blob/main/src/services/transactions.js"
click node_firestore_svc "https://github.com/0xlightning/myexpense-log/blob/main/src/services/firestore.js"
click node_firebase_init "https://github.com/0xlightning/myexpense-log/blob/main/src/services/firebase.js"
click node_static_host "https://github.com/0xlightning/myexpense-log/blob/main/public/index.html"
click node_rules "https://github.com/0xlightning/myexpense-log/blob/main/firestore.rules"

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_index,node_app,node_authctx,node_privateroute,node_login,node_dashboard,node_income,node_expenditure,node_exchange,node_investments,node_oncredit,node_card toneBlue
class node_layout,node_sidebar,node_ui_primitives toneAmber
class node_transactions,node_firestore_svc,node_firebase_init toneMint
class node_static_host,node_firebase_backend,node_rules toneRose
```

## Components

### Client app

React SPA runtime, routing, and page composition in the browser.

- [Entry](https://github.com/0xlightning/myexpense-log/blob/main/src/index.js): React bootstrap · Browser entry point that mounts the app and global styles. · `src/index.js`
- [App](https://github.com/0xlightning/myexpense-log/blob/main/src/App.js): Route shell · Top-level application composition and client-side route wiring. · `src/App.js`
- [Auth state](https://github.com/0xlightning/myexpense-log/blob/main/src/context/AuthContext.js): Context · Centralized authentication state and session lifecycle. · `src/context/AuthContext.js`
- [Private route](https://github.com/0xlightning/myexpense-log/blob/main/src/components/auth/PrivateRoute.js): Route guard · Protects authenticated screens from public access. · `src/components/auth/PrivateRoute.js`
- [Login](https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Login.js): Public page · Sign-in entry page for unauthenticated users. · `src/pages/Login.js`
- [Dashboard](https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Dashboard.js): Feature page · Overview screen for account and transaction status. · `src/pages/Dashboard.js`
- [Income](https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Income.js): Feature page · Income tracking and entry view. · `src/pages/Income.js`
- [Expenditure](https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Expenditure.js): Feature page · Spending tracking and entry view. · `src/pages/Expenditure.js`
- [Exchange](https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Exchange.js): Feature page · Currency or transfer-related finance view. · `src/pages/Exchange.js`
- [Investments](https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Investments.js): Feature page · Investment holdings and activity view. · `src/pages/Investments.js`
- [On credit](https://github.com/0xlightning/myexpense-log/blob/main/src/pages/OnCredit.js): Feature page · Receivables and owed-balance tracking view. · `src/pages/OnCredit.js`
- [Card](https://github.com/0xlightning/myexpense-log/blob/main/src/pages/Card.js): Feature page · Card-related transactions and balances view. · `src/pages/Card.js`

### UI layer

Shared layout and reusable interface primitives.

- [Layout](https://github.com/0xlightning/myexpense-log/blob/main/src/components/layout/Layout.js): Shell · Persistent authenticated app shell and content frame. · `src/components/layout/Layout.js`
- [Sidebar](https://github.com/0xlightning/myexpense-log/blob/main/src/components/layout/Sidebar.js): Navigation · Primary navigation for finance sections. · `src/components/layout/Sidebar.js`
- [UI primitives](https://github.com/0xlightning/myexpense-log/tree/main/src/components/ui): Shared components · Reusable controls such as buttons, cards, inputs, modals, tables, and tabs. · `src/components/ui`

### Data layer

Service abstractions that mediate Firebase access and domain persistence.

- [Transactions](https://github.com/0xlightning/myexpense-log/blob/main/src/services/transactions.js): Domain service · Finance-specific persistence and query logic. · `src/services/transactions.js`
- [Firestore svc](https://github.com/0xlightning/myexpense-log/blob/main/src/services/firestore.js): Data access · Direct Firestore access and document operations. · `src/services/firestore.js`
- [Firebase init](https://github.com/0xlightning/myexpense-log/blob/main/src/services/firebase.js): SDK setup · Initializes the Firebase SDK and shared client instance. · `src/services/firebase.js`

### Platform

Static hosting assets and managed Firebase backend services.

- [Static site](https://github.com/0xlightning/myexpense-log/blob/main/public/index.html): CRA hosting · Prebuilt SPA assets and route fallback for browser navigation. · `public/index.html`
- **Firebase backend**: Managed services · Hosted auth and datastore services used by the client.
- [Firestore rules](https://github.com/0xlightning/myexpense-log/blob/main/firestore.rules): Access control · Server-side database security rules enforcing protected access. · `firestore.rules`

## Connections

- Static site → Entry: loads · The hosted SPA bootstraps from the static HTML shell.
- Entry → App: mounts · React entry mounts the top-level application.
- App → Auth state: uses · App composition depends on centralized auth state.
- App → Private route: guards · Authenticated routes are wrapped by route protection.
- App → Login: routes to · Public access lands on the login page.
- Private route → Layout: renders · Protected screens are shown inside the persistent shell.
- Layout → Sidebar: contains · The shell includes primary navigation.
- Layout → Dashboard: frames · Dashboard and feature pages render in the shared layout.
- Layout → Income: frames · Feature pages render in the shared layout.
- Layout → Expenditure: frames · Feature pages render in the shared layout.
- Layout → Exchange: frames · Feature pages render in the shared layout.
- Layout → Investments: frames · Feature pages render in the shared layout.
- Layout → On credit: frames · Feature pages render in the shared layout.
- Layout → Card: frames · Feature pages render in the shared layout.
- Dashboard → UI primitives: uses · Pages are built from shared UI controls.
- Income → UI primitives: uses · Pages are built from shared UI controls.
- Expenditure → UI primitives: uses · Pages are built from shared UI controls.
- Exchange → UI primitives: uses · Pages are built from shared UI controls.
- Investments → UI primitives: uses · Pages are built from shared UI controls.
- On credit → UI primitives: uses · Pages are built from shared UI controls.
- Card → UI primitives: uses · Pages are built from shared UI controls.
- Auth state → Firebase backend: authenticates · Session state is backed by Firebase authentication services.
- Firebase init → Firebase backend: connects · Shared Firebase client binds the app to managed services.
- Firestore svc → Firebase init: uses · Firestore access is built on the initialized Firebase client.
- Transactions → Firestore svc: wraps · Domain persistence is mediated through Firestore access functions.
- Dashboard → Transactions: reads data · Feature views fetch finance data through the service layer.
- Income → Transactions: reads data · Feature views fetch finance data through the service layer.
- Expenditure → Transactions: reads data · Feature views fetch finance data through the service layer.
- Exchange → Transactions: reads data · Feature views fetch finance data through the service layer.
- Investments → Transactions: reads data · Feature views fetch finance data through the service layer.
- On credit → Transactions: reads data · Feature views fetch finance data through the service layer.
- Card → Transactions: reads data · Feature views fetch finance data through the service layer.
- Firebase backend → Firestore rules: governed by · Firestore access is constrained by server-side rules.
