Beaver Expense Tracker is a responsive web application for managing construction expenses across sites, categories, and timelines. It is built for day-to-day project accounting tasks such as entry, filtering, reporting, receipt management, and export.
- Tracks construction expenses with GST-aware totals.
- Supports site-level budgeting and spend visibility.
- Separates material and labour categories.
- Provides reporting filters and visual summaries.
- Imports from CSV and exports to CSV or JSON bundles.
- Stores receipts with each expense record.
- Uses Firebase in production, with a local-storage fallback for offline/dev usage.
-
Authentication
- Google sign-in via Firebase Authentication.
- Redirect-based auth flow for reliable browser compatibility.
-
Expense Management
- Create, edit, and delete transactions.
- Fields include date, site, category, subcategory, unit, unit price, GST, payment details, notes, and receipts.
- Optimistic row updates for better perceived responsiveness.
-
Category and Site Management
- Create and maintain categories/subcategories.
- Create and manage sites with budget tracking.
-
Reports and Analytics
- Filter by timeline, site, category, and subcategory.
- Charts for category split, timeline, and site-wise spend.
- Paginated report table with load-more behavior.
-
Import and Export
- CSV import for spreadsheet-style expense rows.
- CSV/JSON export bundle including receipt links/files metadata.
- Frontend: React 19, TypeScript, Vite
- Styling/UI: Tailwind CSS, Lucide Icons
- Forms and Validation: React Hook Form, Zod
- Charts: Recharts
- Backend Services: Firebase Auth, Firestore, Cloud Storage, Hosting
- Testing: Vitest, Testing Library
- src/App.tsx: Main UI, routing-by-view state, forms, reports table, import/export actions
- src/hooks/useAuth.ts: Auth session state and auth diagnostics handling
- src/hooks/useExpenseData.ts: Snapshot loading, pagination, optimistic CRUD orchestration
- src/lib/repository.ts: Runtime data-source switch (Firestore or local fallback)
- src/lib/firestoreRepository.ts: Firestore + Storage data access layer
- src/lib/localRepository.ts: localStorage-backed data access fallback
- src/lib/calculations.ts: Totals, GST, and reporting aggregations
- src/lib/csvImport.ts and src/lib/exports.ts: import/export logic
- firebase/: Firestore indexes/rules and Storage rules
- Node.js 20+
- npm 10+
- Firebase project (for cloud mode)
- Firebase CLI (invoked via npx in scripts)
- Install dependencies.
npm install- Create environment file.
cp .env.example .env- Fill
.envwith Firebase values:
- VITE_FIREBASE_API_KEY
- VITE_FIREBASE_AUTH_DOMAIN
- VITE_FIREBASE_PROJECT_ID
- VITE_FIREBASE_STORAGE_BUCKET
- VITE_FIREBASE_MESSAGING_SENDER_ID
- VITE_FIREBASE_APP_ID
- Start development server.
npm run devnpm run dev: start local dev servernpm run build: type-check and produce production buildnpm run preview: preview production bundle locallynpm run lint: run ESLintnpm run test: run Vitest test suitenpm run test:watch: run tests in watch modenpm run firebase:login: authenticate Firebase CLInpm run firebase:emulators: start Firebase emulatorsnpm run firebase:deploy:rules: deploy Firestore/Storage rules and indexesnpm run firebase:deploy:hosting: build and deploy hosting onlynpm run firebase:deploy: build and deploy all configured Firebase targets
- Create a Firebase project.
- Enable Authentication (Google provider).
- Enable Firestore Database.
- Enable Cloud Storage.
- Update
.firebasercwith your project id. - Log in to Firebase CLI.
npm run firebase:login- Deploy all targets.
npm run firebase:deploy- Rules and indexes only:
npm run firebase:deploy:rules- Hosting only:
npm run firebase:deploy:hosting-
Firebase mode
- Enabled when all Firebase environment variables are present.
- Uses Firestore and Storage with owner-scoped documents.
-
Local fallback mode
- Automatically used when Firebase env values are missing.
- Persists data in browser localStorage for development continuity.
- Input validation and sanitization are enforced before persistence.
- Auth errors are generalized for safer UX.
- Receipt and CSV imports include file-size/type checks.
- Firestore and Storage rules are scoped for authenticated ownership patterns.
Run the full quality pass:
npm run lint
npm run test
npm run buildCurrent tests cover calculations, CSV import/export behavior, and data transformation paths.
Application version is sourced from package.json and displayed in the app footer and build metadata.