A secure, high-performance, and client-side personal finance manager built with React, Vite, TypeScript, Tailwind CSS, and Firebase. This application provides robust expense auditing, category pacing, interactive budget limits, and complete local/offline persistence.
- Architectural Overview
- Core Product Features
- Production Directory Structure
- Environment Configuration
- Local Development Setup
- Security Rules & Data Privacy
- Production Build & Deployment
- CSV Export Utility Architecture
The application utilizes a highly decoupled, modern SPA (Single Page Application) frontend paired with Firebase Serverless Backends.
┌────────────────────────────────────────────────────────┐
│ Client-Side │
│ [ React / Vite ] ──► [ Local Cache / Multi-Tab Sync ] │
└───────────────────────────┬────────────────────────────┘
│ (Secure Channels)
▼
┌────────────────────────────────────────────────────────┐
│ Firebase Services │
│ [ Firestore ] [ Authentication ] [ RTDB ] │
└────────────────────────────────────────────────────────┘
- Runtime & Compilation: Compiled using Vite 5 and TypeScript, producing optimized static chunks.
- Client-Side State: Driven by native React hooks (
useState,useEffect,useMemo) for instant rendering, with transactional boundaries managed via Firebase Firestore listeners. - Data Persistence Strategy: Uses Firestore with dynamic local cache enabled (
persistentLocalCacheandpersistentMultipleTabManager), ensuring the application works fully offline and seamlessly synchronizes when network connection is restored. - Realtime Database Event Logger: Configured with a dedicated Realtime Database helper for presence tracking and action stream synchronization.
- Fully implemented authentication flows including Secure Registration, Sign In, and Forgot Password Recovery.
- Auth state persistence configured globally via the
AuthContextReact Provider.
- Dynamic statistics summarizing Net Balances, Total Income, and Total Expenses at a glance.
- Interactive monthly budget progress bars with real-time feedback (warning banners trigger when exceeding predefined safety targets).
- Advanced visualizations outlining top spending categories and distribution ratios.
- Multi-dimensional filtering framework (search by keyword, filter by type, sort by date or amount descending/ascending).
- Dynamic modal dialogues with automatic input validation and clean touch targets (designed with 44px+ guidelines).
- Robust local utility that extracts and parses active transaction collections on-the-fly.
- Translates nested key-value pairs, sanitizes text inputs against CSV injection attacks, and prompts instant, secure downloads.
├── .env.example # Template documenting required environment variables
├── firestore.rules # Security criteria securing Firestore reading/writing
├── package.json # Package declarations and script definitions
├── tsconfig.json # Compiler options enforcing strict type checking
├── vite.config.ts # Bundler settings
└── src/
├── App.tsx # Main Application entry point & routing switchboard
├── main.tsx # Orchestrates root element rendering
├── index.css # Global styling importing Tailwind CSS rules
├── types.ts # Rigid, shared TypeScript contracts and interfaces
├── components/ # Reusable UI widgets
│ ├── Layout.tsx # Responsive navbar, sidebar wrapper and footer
│ ├── AddTransactionModal.tsx # Form modal handling income/expense entries
│ └── ui/ # Custom Atomic UI Design tokens
│ ├── Button.tsx
│ ├── Card.tsx
│ ├── Input.tsx
│ ├── Modal.tsx
│ ├── Select.tsx
│ └── Table.tsx
├── contexts/ # Global application states
│ └── AuthContext.tsx # Firebase authentication context
├── lib/ # Integrations and utilities
│ ├── firebase.ts # Direct initialization of Firebase Auth, Firestore, and RTDB
│ └── rtdbService.ts # Event tracking and presence syncing protocols
└── pages/ # Full screen layout structures
├── ForgotPassword.tsx
├── Login.tsx
└── Register.tsx
⚠️ Security Warning: Never commit actual production API keys or credentials to public Git repositories. Ensure.gitignoreexplicitly filters out.envfiles.
To initialize, run, and test the workspace locally:
-
Install Base Dependencies:
npm install
-
Run Development Server:
npm run dev
The dev server binds to host
0.0.0.0on port3000as required by cloud network mapping overlays. -
Validate Code Integrity (Linter):
npm run lint
Ensures type safety across all TypeScript modules and verifies imports are correctly declared at the top-level.
To guarantee secure data containment, ensure your Firestore Security Rules (firestore.rules) enforce scoped user validation. No individual can query or write transactions belonging to another UID.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /transactions/{transactionId} {
allow read, write: if request.auth != null && request.auth.uid == resource.data.userId;
allow create: if request.auth != null && request.auth.uid == request.resource.data.userId;
}
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}To bundle the application into an optimized static distribution structure ready for enterprise-ready CDNs (Firebase Hosting, Cloud Run, Vercel, or Netlify):
- Trigger Compilation:
npm run build
- Review Output:
The command executes the Vite compiler which bundles assets, minifies files, and generates index routing files within the
./distfolder. - Containerization:
The static folder
./distcan be served by NGINX or static web services inside the production hosting layer.
The CSV export function is written directly inside /src/App.tsx and works without any external rendering dependencies, reducing production load weights.
- Automatically wraps fields containing commas, carriage returns, or quotations inside double quotes to protect spreadsheet parsing.
- Translates database-stored category keys to human-friendly display titles using a static mapper.
- Dynamically generates and cleans up
BlobURLs to prevent browser memory leaks on client machines.