Skip to content

subinita01/Expense-IF

Repository files navigation

πŸ’° Expense-IF

A modern, real-time expense tracking application built with React, TypeScript, and Firebase. Track your daily expenses, visualize spending patterns, and manage your finances with an intuitive and beautiful interface.

🌐 Live Demo: https://expense-if.netlify.app/


✨ Features

  • πŸ” Authentication: Secure user registration and login with Firebase Authentication
  • πŸ“ Expense Tracking: Add, edit, and delete expenses with ease
  • πŸ“Š Real-time Analytics: View expense summaries and category-wise breakdowns
  • πŸ“ˆ Visual Charts: Interactive charts powered by Recharts to visualize spending patterns
  • 🏷️ Category Management: Organize expenses into 7 predefined categories:
    • Food & Dining
    • Transport
    • Entertainment
    • Shopping
    • Utilities
    • Health
    • Other
  • πŸ“… Monthly Overview: Track monthly spending with summary cards showing total expenses and current month's spending
  • ⚑ Real-time Sync: All data is synced in real-time using Firebase Firestore
  • 🎨 Modern UI: Clean, responsive design using shadcn/ui and Tailwind CSS
  • πŸŒ™ Dark Mode Support: Built-in theme support for dark and light modes
  • πŸ“± Fully Responsive: Works seamlessly on desktop, tablet, and mobile devices

πŸ› οΈ Tech Stack

Frontend

  • React 18.3: UI framework
  • TypeScript 5.8: Type safety
  • Vite 5.4: Lightning-fast build tool
  • Tailwind CSS 3.4: Utility-first CSS framework
  • shadcn/ui: High-quality React components
  • React Router v6: Client-side routing
  • React Hook Form: Efficient form handling
  • Zod: Schema validation

Backend & Database

  • Firebase: Backend-as-a-service platform
    • Authentication: User sign-up and login
    • Firestore: Real-time NoSQL database
    • Analytics: User activity tracking

Libraries & Tools

  • Recharts 2.15: Data visualization
  • React Query 5.83: Server state management
  • Lucide React: Beautiful icon library
  • Sonner: Toast notifications
  • date-fns 3.6: Date manipulation and formatting
  • Zod 3.25: TypeScript-first schema validation
  • next-themes: Theme management (dark/light mode)

Development Tools

  • ESLint: Code quality linting
  • TypeScript: Static type checking
  • PostCSS: CSS transformations
  • Autoprefixer: Browser compatibility

πŸ“ Project Structure

Expense-IF/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ ui/                    # shadcn/ui components
β”‚   β”‚   β”œβ”€β”€ ExpenseForm.tsx        # Form for adding/editing expenses
β”‚   β”‚   β”œβ”€β”€ ExpenseList.tsx        # Display list of expenses
β”‚   β”‚   β”œβ”€β”€ ExpenseChart.tsx       # Visualization component
β”‚   β”‚   β”œβ”€β”€ SummaryCards.tsx       # Summary statistics
β”‚   β”‚   β”œβ”€β”€ Header.tsx             # Navigation header
β”‚   β”‚   └── layout/
β”‚   β”‚       └── ProtectedRoute.tsx # Route protection for authenticated users
β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ useExpenses.ts         # Custom hook for expense management
β”‚   β”‚   β”œβ”€β”€ useAuth.ts             # Authentication hook
β”‚   β”‚   └── use-mobile.tsx         # Mobile detection hook
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ Index.tsx              # Landing page
β”‚   β”‚   β”œβ”€β”€ Dashboard.tsx          # Main expense dashboard
β”‚   β”‚   β”œβ”€β”€ login.tsx              # Login page
β”‚   β”‚   β”œβ”€β”€ signup.tsx             # Registration page
β”‚   β”‚   └── NotFound.tsx           # 404 page
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── userService.ts         # User-related API calls
β”‚   β”œβ”€β”€ types/
β”‚   β”‚   └── expense.ts             # TypeScript interfaces and types
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   └── utils.ts               # Utility functions
β”‚   β”œβ”€β”€ firebase.ts                # Firebase configuration
β”‚   β”œβ”€β”€ App.tsx                    # Root component with routing
β”‚   β”œβ”€β”€ main.tsx                   # Entry point
β”‚   β”œβ”€β”€ App.css                    # Global styles
β”‚   └── index.css                  # Tailwind CSS imports
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ favicon.ico
β”‚   β”œβ”€β”€ robots.txt
β”‚   └── _redirects                 # Netlify routing configuration
β”œβ”€β”€ package.json                   # Project dependencies
β”œβ”€β”€ vite.config.ts                 # Vite configuration
β”œβ”€β”€ tsconfig.json                  # TypeScript configuration
β”œβ”€β”€ tailwind.config.ts             # Tailwind CSS configuration
β”œβ”€β”€ postcss.config.js              # PostCSS configuration
β”œβ”€β”€ eslint.config.js               # ESLint configuration
β”œβ”€β”€ components.json                # shadcn/ui configuration
β”œβ”€β”€ netlify.toml                   # Netlify deployment configuration
└── index.html                     # HTML entry point

πŸš€ Getting Started

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • A Firebase project (for database and authentication)

Installation

  1. Clone the repository

    git clone https://github.com/subinita01/Expense-IF.git
    cd Expense-IF
  2. Install dependencies

    npm install
    # or
    yarn install
  3. Set up Firebase Configuration (Optional for local development)

    • The project already has Firebase credentials configured
    • If you want to use your own Firebase project:
      • Update the firebaseConfig in src/firebase.ts with your credentials
  4. Start the development server

    npm run dev
    # or
    yarn dev
  5. Open in browser

    • Navigate to http://localhost:8080

Build for Production

npm run build
# or
yarn build

Preview Production Build

npm run preview
# or
yarn preview

πŸ“– Usage

1. Landing Page

  • Visit the home page to see project information
  • Click on "Login" or "Sign Up" to get started

2. Create an Account

  • Fill in your email and password
  • Click "Sign Up" to create a new account
  • Your account data is securely stored in Firebase

3. Add an Expense

  • Click on the "Add Expense" button in the dashboard
  • Fill in the details:
    • Title: Short description of the expense
    • Amount: Expense amount
    • Category: Select from predefined categories
    • Date: Pick the date of the expense
    • Description (optional): Additional notes
  • Click "Save" to add the expense

4. View Expenses

  • All expenses are displayed in a table format
  • Summary cards show:
    • Total expenses (all time)
    • This month's total
    • Total number of expense records

5. Edit or Delete

  • Click the edit icon to modify an existing expense
  • Click the delete icon to remove an expense
  • Changes sync in real-time across all sessions

6. Analyze Spending

  • View category-wise spending distribution in the chart
  • Identify spending patterns and manage your budget accordingly

πŸ” Authentication

The app uses Firebase Authentication with email and password:

  • Sign Up: Create a new account with email and password
  • Login: Sign in with your credentials
  • Protected Routes: Dashboard is only accessible to authenticated users
  • Auto-redirect: Unauthenticated users are redirected to the login page

πŸ“Š Data Model

Expense Type

interface Expense {
  id: string;                    // Unique identifier (Firestore doc ID)
  title: string;                 // Expense title
  amount: number;                // Expense amount
  category: Category;            // One of 7 categories
  date: string;                  // ISO date format (YYYY-MM-DD)
  description?: string;          // Optional notes
}

type Category = 
  | "food"
  | "transport"
  | "entertainment"
  | "shopping"
  | "utilities"
  | "health"
  | "other";

Firestore Collection Structure

users/
  └── {userId}/
      └── expenses/
          └── {expenseId}
              β”œβ”€β”€ title: string
              β”œβ”€β”€ amount: number
              β”œβ”€β”€ category: string
              β”œβ”€β”€ date: string
              └── description: string (optional)

🎨 Customization

Change Expense Categories

Edit the CATEGORIES array in src/types/expense.ts:

export const CATEGORIES = [
  { value: "food", label: "Food & Dining", color: "hsl(var(--category-food))" },
  // Add more categories here
];

Customize Colors

  • Edit CSS variables in src/index.css
  • Tailwind CSS configuration in tailwind.config.ts

Theme

  • The app supports light and dark modes
  • Theme toggle is available in the header component

πŸ”„ Real-time Features

  • Firestore Real-time Listeners: Expenses update instantly across all devices
  • Live Status Indicator: Shows when the app is connected and last update time
  • Automatic Sync: Changes are automatically synchronized with the database

πŸ“± Responsive Design

  • Mobile: Touch-friendly interface optimized for phones
  • Tablet: Adjusted layout for medium screens
  • Desktop: Full-featured layout for larger screens
  • Built with mobile-first approach using Tailwind CSS

🚒 Deployment

Deploy to Netlify (Recommended)

The project is configured for Netlify deployment:

  1. Connect your GitHub repository to Netlify
  2. Configure build settings:
    • Build Command: npm run build
    • Publish Directory: dist
  3. Deploy

The project includes:

  • netlify.toml: Deployment configuration
  • public/_redirects: SPA routing configuration

Other Deployment Options

  • Vercel: Works seamlessly with Vite
  • GitHub Pages: Configure with appropriate base URL
  • Self-hosted: Build and serve the dist folder

πŸ“ API Endpoints / Firebase Operations

The app performs the following Firebase operations:

Authentication

signUp(email, password)     // Create new account
signIn(email, password)     // Login
signOut()                   // Logout
getCurrentUser()            // Get authenticated user

Firestore CRUD

addExpense(expenseData)     // Create new expense
getExpenses()               // Read all user expenses (real-time)
updateExpense(id, data)     // Update expense
deleteExpense(id)           // Delete expense

πŸ› Troubleshooting

Issue: Cannot load expenses

  • Ensure you're logged in
  • Check Firebase configuration in src/firebase.ts
  • Verify Firestore rules allow read/write access

Issue: Changes not syncing

  • Check your internet connection
  • Verify Firestore is accessible
  • Reload the page

Issue: Authentication fails

  • Ensure email is valid
  • Password should be at least 6 characters
  • Clear browser cache if issue persists

🀝 Contributing

Contributions are welcome! To contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is open source and available under the MIT License.


πŸ‘€ Author

Subinita - GitHub Profile


πŸ™ Acknowledgments

  • shadcn/ui for amazing React components
  • Firebase for real-time backend services
  • Recharts for beautiful data visualizations
  • Tailwind CSS for utility-first CSS framework
  • React Router for client-side routing

πŸ’‘ Future Enhancements

Potential features for future versions:

  • Expense filtering and search
  • Budget setting and tracking
  • Recurring expenses
  • Multi-currency support
  • Export to CSV/PDF
  • Mobile app (React Native)
  • Integration with payment methods
  • Expense splitting (shared expenses)
  • Expense reminders and notifications
  • Advanced analytics and reports

πŸ“ž Support & Contact

For issues, questions, or suggestions:


πŸ“š Learn More


Happy Expense Tracking! πŸ’³βœ¨

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages