Skip to content

isorbon/Sarfa_App

Repository files navigation

πŸ’° Sarfa - Personal Expense Tracker

A modern, full-stack expense tracking web application built with React + TypeScript and Node.js + SQLite.

Expensify Dashboard Version License

🌟 Features

  • βœ… Secure Authentication - JWT-based login/registration system
  • πŸ“Š Interactive Dashboard - Real-time statistics and data visualization
  • οΏ½ Multi-Currency Support - 22 currencies matching all supported languages
  • πŸ“ˆ Beautiful Charts - Monthly trends and category breakdowns
  • 🎨 Icon Customization - 100+ icons to choose from for each expense
  • πŸ” Smart Filtering - Search and filter by date, category, and more
  • πŸ“± Fully Responsive - Works seamlessly on desktop, tablet, and mobile
  • πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦ Family Support - Multiple user accounts for family members
  • ☁️ Remote Hosting Ready - Easy deployment to any cloud platform

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ installed
  • npm or yarn

Installation

  1. Clone the repository
git clone <your-repo-url>
cd expenses
  1. Install backend dependencies
cd server
npm install
  1. Install frontend dependencies
cd ..
npm install

Running the Application

  1. Start the backend server (Terminal 1)
cd server
npm start

Server runs on http://localhost:3001

  1. Start the frontend (Terminal 2)
npm run dev

Application runs on http://localhost:5173

  1. Open your browser Navigate to http://localhost:5173

Demo Credentials

  • Email: demo@expenses.com
  • Password: demo123

πŸ—οΈ Tech Stack

Frontend

  • βš›οΈ React 18 - UI library
  • πŸ“˜ TypeScript - Type safety
  • ⚑ Vite - Build tool
  • 🎨 Vanilla CSS - Styling
  • πŸ“Š Recharts - Data visualization
  • 🎯 Lucide React - Icon library
  • πŸ›£οΈ React Router - Navigation

Backend

  • πŸš€ Express - Web framework
  • πŸ—„οΈ SQLite3 - Database
  • πŸ” JWT - Authentication
  • πŸ”’ bcryptjs - Password hashing
  • 🌐 CORS - Cross-origin support

πŸ“‚ Project Structure

expenses/
β”œβ”€β”€ server/              # Backend API
β”‚   β”œβ”€β”€ server.js        # Express server
β”‚   β”œβ”€β”€ database.js      # Database setup
β”‚   └── expenses.db      # SQLite database
β”œβ”€β”€ src/                 # Frontend source
β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”œβ”€β”€ pages/           # Page components
β”‚   β”œβ”€β”€ context/         # React context
β”‚   β”œβ”€β”€ services/        # API services
β”‚   └── types/           # TypeScript types
β”œβ”€β”€ public/              # Static assets
└── index.html           # HTML template

🎯 Key Features Explained

1. Dashboard

  • 4 Statistics Cards: Account Balance, Monthly Expenses, Total Investment, Goal Tracker
  • Monthly Expenses Chart: 6-month bar chart showing spending trends
  • Category Breakdown: Donut chart with interactive legend
  • Recent Expenses: Table showing last 5 transactions
  • Bill & Subscription Tracker: Recurring payment monitoring

2. Expense Management

  • Add expenses with amount, category, sub-category, description, icon, date, and payment mode
  • Edit existing expenses
  • Delete expenses
  • Search and filter functionality
  • 6 predefined categories with custom colors

3. Categories

  1. πŸ₯¬ Food & Grocery
  2. πŸ“ˆ Investment
  3. πŸ›οΈ Shopping
  4. ✈️ Travelling
  5. πŸ“¦ Miscellaneous
  6. πŸ’³ Bill & Subscription

πŸ” Security

  • Passwords hashed with bcryptjs (10 rounds)
  • JWT tokens for stateless authentication
  • Protected API routes
  • Input validation on both frontend and backend
  • CORS configuration for production
  • Demo Account Protection: Data deletion and password changes are disabled for the demo account (demo@expenses.com) to preserve data integrity for public testing.

Backend Deployment (Serverless)

We recommend deploying the backend to Vercel with a Supabase database (Free Tier).

  1. Database (Supabase):

    • Create a free project at supabase.com.
    • Get your connection string (Transaction Pooler, port 6543).
    • Example: postgresql://postgres:[PASSWORD]@...:6543/postgres?pgbouncer=true
  2. Backend (Vercel):

    • Create a new Vercel project.
    • Set Root Directory to server.
    • Add Environment Variable: DATABASE_URL = (Your Supabase connection string).
    • Add Environment Variable: JWT_SECRET = (Any random secret string).
    • Deploy! (Get your new Backend URL, e.g., https://my-backend.vercel.app).

Frontend Deployment

  1. Frontend (Vercel):
    • Create a separate Vercel project (or use the main one with Root Directory .).
    • Add Environment Variable: VITE_API_BASE_URL = https://<YOUR-BACKEND-URL>/api
    • Deploy!
    • Build command: npm run build

πŸ“Š API Documentation

Authentication

Register

POST /api/auth/register
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "password123",
  "name": "John Doe"
}

Login

POST /api/auth/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "password123"
}

Expenses

Get All Expenses

GET /api/expenses?startDate=2025-01-01&endDate=2025-12-31&category=Shopping
Authorization: Bearer <token>

Create Expense

POST /api/expenses
Authorization: Bearer <token>
Content-Type: application/json

{
  "amount": 50.50,
  "category": "Food & Grocery",
  "sub_category": "Restaurant",
  "description": "Dinner",
  "icon": "UtensilsCrossed",
  "date": "2025-06-15",
  "mode": "Card"
}

Update Expense

PUT /api/expenses/:id
Authorization: Bearer <token>
Content-Type: application/json

{
  "amount": 60.00,
  ...
}

Delete Expense

DELETE /api/expenses/:id
Authorization: Bearer <token>

Dashboard

Get Statistics

GET /api/dashboard/stats?period=month
Authorization: Bearer <token>

Periods: recent, month, year

πŸ› οΈ Development

Available Scripts

Frontend:

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run preview - Preview production build

Backend:

  • npm start - Start server
  • npm run dev - Start with auto-reload (if configured)

Environment Variables

Create .env file in server/ directory:

PORT=3001
JWT_SECRET=your-super-secret-key-change-in-production
NODE_ENV=development

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Created with ❀️ for managing personal and family expenses.

πŸ™ Acknowledgments


Happy Expense Tracking! πŸ’°πŸ“Š

About

Personal Finance & Expense Manager

Resources

Stars

Watchers

Forks

Packages

No packages published