Skip to content

190-785/Daily_Ledger

Repository files navigation

💰 Daily Ledger - Smart Collection Tracker

A modern, real-time collection management system built with React, Firebase, and Tailwind CSS. Track daily collections, manage members, share lists, and analyze financial data with an intuitive dashboard.

React Firebase Vite Tailwind CSS License


🌟 Features

💳 Collection Management

  • Daily Ledger: Track daily transactions for each member
  • Member Management: Add, edit, and organize collection members
  • Monthly Targets: Set and monitor monthly collection goals
  • Real-time Updates: Instant synchronization across all devices

List Sharing & Owner Statistics

  • Share Lists: Collaborate with other users by sharing collection lists
  • Username Search: Find users by their unique username
  • Access Control: Manage who can view your shared lists
  • Owner Statistics: View comprehensive payment statistics (total collected, who paid/didn't pay) - visible only to list owners
  • Real-time Sync: Shared lists update instantly for all users

📊 Advanced Analytics

  • Daily Summary: View today's collections at a glance
  • Monthly Overview: Track progress toward monthly targets
  • Payment Status: See who paid today and who has outstanding balances
  • Outstanding Management: Clear outstanding balances for specific months
  • Historical Data: Access past transactions and trends
  • Excel Export: Download monthly reports and individual member statements

👤 User Profiles

  • Unique Usernames: Claim your unique @username
  • Profile Management: Update your name, email, and password
  • Secure Authentication: Firebase Authentication with email/password
  • Data Privacy: Your data is protected by Firestore security rules

📱 Progressive Web App (PWA)

  • Installable: Add to home screen on mobile devices
  • Offline Support: Access your data even without internet
  • Push Notifications: Stay updated with important events (coming soon)
  • Native Experience: Feels like a native mobile app

🎨 Modern Design

  • Responsive UI: Works perfectly on desktop, tablet, and mobile
  • Dark Mode Ready: Custom design system with beautiful gradients
  • Smooth Animations: Polished transitions and interactions
  • Accessible: Built with accessibility best practices

🚀 Quick Start

Prerequisites

  • Node.js 18+ (LTS recommended)
  • npm or yarn or pnpm
  • Firebase Account (free tier works great!)

Installation

  1. Clone the repository

    git clone https://github.com/190-785/Daily_Ledger.git
    cd Daily_Ledger
  2. Install dependencies

    npm install
  3. Set up Firebase (see Firebase Setup below)

  4. Start development server

    npm run dev
  5. Open your browser

    http://localhost:5173
    

🔥 Firebase Setup

1. Create Firebase Project

  1. Go to Firebase Console
  2. Click "Add project"
  3. Name it (e.g., "daily-ledger")
  4. Enable Google Analytics (optional)
  5. Create project

2. Enable Authentication

  1. In Firebase Console, go to Authentication
  2. Click "Get started"
  3. Enable "Email/Password" provider
  4. Save

3. Create Firestore Database

  1. Go to Firestore Database
  2. Click "Create database"
  3. Choose "Start in production mode"
  4. Select a location (closest to your users)
  5. Click "Enable"

4. Deploy Security Rules

  1. Go to Firestore DatabaseRules tab
  2. Copy the entire content from firestore.rules file
  3. Paste into the editor
  4. Click "Publish"

5. Configure Your App

  1. In Firebase Console, go to Project Settings (gear icon)

  2. Scroll to "Your apps"

  3. Click "</>" (Web app)

  4. Register your app (name: "Daily Ledger Web")

  5. Copy the Firebase config object

  6. Add Firebase config via environment variables

    Copy .env.example to .env at the project root and fill in your Firebase values. Vite exposes vars prefixed with VITE_ to the client.

    Example (.env):

    VITE_FIREBASE_API_KEY=AIzaSy...
    VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
    VITE_FIREBASE_PROJECT_ID=your-project-id
    VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
    VITE_FIREBASE_MESSAGING_SENDER_ID=...
    VITE_FIREBASE_APP_ID=1:...:web:...
    VITE_FIREBASE_MEASUREMENT_ID=G-XXXXXXXXX

    The app automatically loads these values from import.meta.env at runtime; you don't need to edit src/firebase.js directly.

6. Add Authorized Domains

For production deployment (Vercel, etc.):

  1. Go to AuthenticationSettingsAuthorized domains
  2. Add your production domain (e.g., your-app.vercel.app)

🛠️ Development

Available Scripts

# Start development server (with hot reload)
npm run dev

# Build for production
npm run build

# Preview production build
npm run preview

# Run ESLint
npm run lint

Project Structure

Daily_Ledger/
├── public/
│   ├── manifest.json          # PWA manifest
│   ├── service-worker.js      # Service worker for offline support
│   └── favicon.svg            # App icon
├── src/
│   ├── components/            # Reusable UI components
│   │   ├── Button.jsx
│   │   ├── Card.jsx
│   │   ├── Input.jsx
│   │   ├── Table.jsx
│   │   ├── Header.jsx
│   │   ├── Footer.jsx
│   │   ├── Sidebar.jsx
│   │   ├── BottomNav.jsx
│   │   ├── ErrorBoundary.jsx
│   │   └── ... (modals, animations, etc.)
│   ├── pages/                 # Page components
│   │   ├── LoginPage.jsx
│   │   ├── SignupPage.jsx
│   │   ├── DashboardPage.jsx
│   │   ├── LedgerPage.jsx
│   │   ├── MembersPage.jsx
│   │   ├── ListsPage.jsx
│   │   ├── ProfilePage.jsx
│   │   └── MonthlyViewPage.jsx
│   ├── hooks/                 # Custom React hooks
│   │   └── useValidation.js
│   ├── utils/                 # Utility functions
│   │   ├── designSystem.js
│   │   ├── validation.js
│   │   ├── statsCalculator.js
│   │   └── pwa.js
│   ├── firebase.js            # Firebase configuration & helpers
│   ├── App.jsx                # Main app component
│   ├── main.jsx               # Entry point
│   └── index.css              # Global styles
├── firestore.rules            # Firebase security rules
├── vercel.json                # Vercel deployment config
├── vite.config.js             # Vite configuration
├── package.json               # Dependencies & scripts
└── README.md                  # This file

🎨 Tech Stack

Frontend

Backend & Services

  • Firebase 12.3.0 - Backend-as-a-Service
    • Authentication - Secure user auth with email/password
    • Firestore - Real-time NoSQL database
    • Security Rules - Server-side data protection

PWA & Performance

  • Service Worker - Offline support & caching
  • Web Manifest - Installable app metadata
  • Code Splitting - Optimized bundle loading

Development Tools

  • ESLint - Code linting and quality
  • PostCSS - CSS processing
  • Autoprefixer - CSS vendor prefixing

🔒 Security

Firestore Security Rules

All data access is protected by comprehensive Firestore Security Rules that have been thoroughly tested and fixed for production use:

Key Security Features:

  • Authentication Required: Most operations require user authentication
  • Owner-Only Access: Users can only access their own data
  • Input Validation: String lengths, formats, and types are validated
  • Timestamp Validation: Prevents backdating and future-dating using server timestamps
  • Rate Limiting: Max amounts (1M per transaction) and list sizes (1000 members)
  • Immutable Data: Usernames cannot be changed after creation
  • Sharing Controls: List sharing requires explicit permission and uses map-based structure

Recent Security Fixes:

  • Map-based Sharing: Changed from array [] to object {} structure for efficient user lookup
  • Server Timestamps: All timestamps use serverTimestamp() instead of client-side new Date()
  • Permission Errors: Fixed "Missing or insufficient permissions" errors during list sharing
  • Input Validation: Comprehensive validation for usernames, emails, dates, and amounts

Security Rules Structure:

// Username availability check (public)
match /usernames/{username} {
  allow read: if true;
}

// Lists with sharing support
match /lists/{listId} {
  allow read: if isOwner(userId) || 
              (isSignedIn() && request.auth.uid in resource.data.sharedWith.keys());
  allow write: if isOwner(userId) && validListData();
}

// Transactions with validation
match /lists/{listId}/transactions/{transactionId} {
  allow read, write: if canAccessList(listId) && validTransactionData();
}

Best Practices

  • 🔐 Firebase API keys are public by design (safe in client-side code)
  • 🔐 All sensitive operations validated on Firebase servers
  • 🔐 Security rules cannot be bypassed by modified client code
  • 🔐 User data isolated by Firebase Auth UID
  • 🔐 Server-side timestamp validation prevents manipulation
  • 🔐 Map-based sharing structure enables efficient permission checks

🚢 Deployment

Architecture Overview

Your app follows a JAMstack architecture:

  • Vercel = Static hosting (HTML, CSS, JS files)
  • Firebase = Backend services (Auth + Database)
  • Security Rules = Enforced on Firebase servers (not in browser)
Browser → Vercel (Static Host) → Firebase SDK → Firebase Servers (Security Rules)

Key Security Point: Security rules protect data on Firebase servers, not in the browser. Users cannot bypass them!

Deploy to Vercel (Recommended)

Option A: Vercel Dashboard (Easiest)

  1. Push to GitHub

    git add .
    git commit -m "Ready for deployment"
    git push origin main
  2. Import to Vercel

    • Go to vercel.com
    • Click "Add New Project"
    • Import your GitHub repository
    • Configure:
      • Framework Preset: Vite
      • Build Command: npm run build
      • Output Directory: dist
    • Click "Deploy"

Option B: Vercel CLI

# Install CLI (if not already installed)
npm i -g vercel

# Deploy
vercel --prod

Deploy Firestore Security Rules

Step 1: Choose Rules File

  • Recommended: Use firestore.rules (production-ready with enhanced validation)
  • Alternative: firestore.production.rules (even more restrictive validation)

Step 2: Deploy via Firebase Console

  1. Go to Firebase Console
  2. Select your project (daily-collection-ledger)
  3. Navigate: Firestore DatabaseRules tab
  4. Copy entire content from firestore.rules
  5. Paste into Firebase Console editor
  6. Click "Publish"
  7. Wait 60 seconds for rules to propagate

Configure Firebase for Production

Add Vercel Domain to Authorized Domains

  1. Get your Vercel URL (e.g., daily-ledger.vercel.app)
  2. Firebase Console → AuthenticationSettings
  3. Scroll to "Authorized domains"
  4. Click "Add domain"
  5. Enter your Vercel domain
  6. Click "Add"

Test Production Deployment

  • Visit your Vercel URL
  • Test signup, login, and all features
  • Check browser console (F12) for errors
  • Verify list sharing and dashboard work

Deploy to Other Platforms

The app works on any static hosting platform:

  • Netlify: Deploy from GitHub with Vite preset
  • GitHub Pages: Use gh-pages npm package
  • Firebase Hosting: firebase init hosting + firebase deploy

Production vs Development Differences

Development (npm run dev):

  • Hot reload enabled
  • Source maps available
  • Console logging active
  • Runs on http://localhost:5173

Production (Vercel):

  • Code minified and optimized
  • Source maps removed
  • Custom HTTPS domain
  • CDN distribution worldwide
  • Automatic SSL certificates

Firebase Rules (Same Everywhere):

  • ✅ Work identically in dev and production
  • ✅ Protect data regardless of client location
  • ✅ Cannot be bypassed by modified client code

Continuous Deployment

Connect your GitHub repo to Vercel for automatic deployments:

  • Every push to main = automatic production deploy
  • Pull requests get preview deployments
  • Rollbacks available in Vercel dashboard

📖 Documentation

Essential Docs

  • LICENSE - GNU General Public License v3.0

Consolidated Information

All deployment guides, security rules documentation, and feature explanations have been consolidated into this README for easier reference.


🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development Guidelines

  1. Follow existing code style
  2. Use meaningful component and variable names
  3. Add comments for complex logic
  4. Test thoroughly before submitting
  5. Update documentation as needed

Code Standards

  • Components: Use functional components with hooks
  • Styling: Use Tailwind CSS utility classes
  • State Management: React hooks (useState, useEffect, etc.)
  • Firebase: Use async/await for all Firebase operations
  • Error Handling: Always wrap Firebase calls in try/catch

🐛 Troubleshooting

Common Issues

"Missing or insufficient permissions"

  • Deploy updated firestore.rules to Firebase Console
  • Wait 60 seconds for rules to propagate
  • Clear browser cache and hard refresh

"Auth domain not authorized"

  • Add your domain to Firebase authorized domains
  • Firebase Console → Authentication → Settings → Authorized domains

Build errors

  • Delete node_modules and reinstall: rm -rf node_modules && npm install
  • Clear Vite cache: rm -rf node_modules/.vite
  • Update dependencies: npm update

Service Worker not updating

  • Hard refresh: Ctrl+Shift+R (Windows) or Cmd+Shift+R (Mac)
  • Clear application cache in DevTools (F12 → Application → Clear storage)

📊 Performance

  • Lighthouse Score: 90+ on all metrics
  • 🚀 Build Time: ~13 seconds
  • 📦 Bundle Size: ~805 KB (208 KB gzipped)
  • 🌐 First Contentful Paint: < 1s (on Vercel CDN)
  • 📱 Mobile Optimized: Responsive design for all screen sizes

📱 Progressive Web App (PWA)

The app can be installed on devices:

Desktop (Chrome/Edge)

  • Look for "Install" icon in address bar
  • Click to install as desktop app

Mobile (Android/iOS)

  • Tap browser menu (⋮)
  • Select "Add to Home Screen"
  • App icon appears on home screen

Offline Support

  • View cached data without internet
  • Add transactions offline (syncs when online)
  • Service worker caches app assets

🔄 Updates & Roadmap

Current Version: 1.0.0

  • ✅ Core ledger functionality
  • ✅ User authentication
  • ✅ Dashboard analytics
  • ✅ List sharing
  • ✅ PWA support
  • ✅ Mobile responsive
  • ✅ Production-ready

Upcoming Features

  • 🔜 Export data (CSV, PDF)
  • 🔜 Dark mode toggle
  • 🔜 Push notifications
  • 🔜 Advanced filtering & search
  • 🔜 Charts & visualizations
  • 🔜 Multi-currency support

📄 License

This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.

GPL-3.0 Summary

  • Freedom to use - Use the software for any purpose
  • Freedom to study - Access and modify the source code
  • Freedom to share - Distribute copies to help others
  • Freedom to improve - Distribute modified versions
  • ⚠️ Copyleft - Derivative works must also be GPL-3.0
  • ⚠️ Source disclosure - Modified versions must include source code

👨‍💻 Author

190-785


🙏 Acknowledgments

  • React Team - For the amazing React library
  • Vite Team - For the blazing-fast build tool
  • Tailwind CSS - For the utility-first CSS framework
  • Firebase - For the powerful backend services
  • Vercel - For the excellent hosting platform

💬 Support

If you have any questions or need help:

  1. Check the documentation files
  2. Review Firebase docs
  3. Open an issue on GitHub
  4. Check browser console for error messages

⭐ Star this repo if you find it helpful! ⭐

Made with ❤️ using React, Firebase, and Tailwind CSS

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors