Skip to content

Saikumar-bali/bill_tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Bill Tracker

A full-stack bill tracking application that allows users to track their expenses with both manual entry and OCR-powered receipt scanning.

Status License

πŸš€ Live Demo

✨ Features

  • User Authentication - Secure login and registration system
  • Manual Bill Entry - Add bills manually with title, amount, category, and date
  • OCR Receipt Scanning - Upload receipt images and automatically extract bill details
  • Dashboard - View total spending, monthly totals, and category breakdown
  • Data Visualization - See spending trends over time with charts
  • Bill Management - View, track, and manage all your bills in one place
  • Image Storage - Receipts stored in Cloudflare R2 with public access

πŸ›  Tech Stack

Frontend

  • React 19 - UI framework
  • Vite - Build tool
  • React Router - Client-side routing
  • Axios - HTTP client
  • Recharts - Data visualization
  • Lucide React - Icons

Backend

  • Express.js - Web framework
  • Cloudflare D1 - SQLite database
  • Cloudflare R2 - Object storage for receipt images
  • JWT - Authentication tokens
  • OCR.space API - Receipt text extraction
  • Multer - File upload handling

πŸ“ Project Structure

bill_tracking/
β”œβ”€β”€ client/                 # React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # React components
β”‚   β”‚   β”œβ”€β”€ pages/         # Page components
β”‚   β”‚   β”œβ”€β”€ context/       # React context (auth)
β”‚   β”‚   β”œβ”€β”€ services/      # API service
β”‚   β”‚   β”œβ”€β”€ App.tsx        # Main app component
β”‚   β”‚   └── main.tsx       # Entry point
β”‚   β”œβ”€β”€ .env               # Frontend environment variables
β”‚   β”œβ”€β”€ .env.example       # Frontend environment template
β”‚   β”œβ”€β”€ vercel.json        # Vercel configuration
β”‚   └── package.json
β”œβ”€β”€ server/                 # Express backend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ routes/        # API routes (auth, bills)
β”‚   β”‚   β”œβ”€β”€ middleware/    # Express middleware
β”‚   β”‚   β”œβ”€β”€ services/      # D1, R2, OCR services
β”‚   β”‚   └── index.js       # Server entry point
β”‚   β”œβ”€β”€ .env               # Server environment variables
β”‚   β”œβ”€β”€ .env.example       # Server environment template
β”‚   β”œβ”€β”€ wrangler.toml      # Cloudflare config
β”‚   β”œβ”€β”€ vercel.json        # Vercel configuration
β”‚   └── package.json
└── README.md

οΏ½-setup Local Development

Prerequisites

  • Node.js 18+
  • npm or pnpm

1. Clone the repository

git clone https://github.com/yourusername/bill_tracking.git
cd bill_tracking

2. Setup Backend

cd server
npm install
cp .env.example .env
# Edit .env with your credentials

Required Backend Environment Variables

PORT=5000
CLOUDFLARE_API_TOKEN=your_cloudflare_api_token
CLOUDFLARE_ACCOUNT_ID=your_cloudflare_account_id
CLOUDFLARE_D1_DATABASE_ID=your_d1_database_id
JWT_SECRET=your_jwt_secret
OCR_SPACE_API_KEY=your_ocr_space_api_key
R2_ACCESS_KEY_ID=your_r2_access_key_id
R2_SECRET_ACCESS_KEY=your_r2_secret_access_key

Start the backend server:

npm run start
# Server runs on http://localhost:5000

3. Setup Frontend

cd client
npm install
cp .env.example .env
# Edit .env with your API URL

Required Frontend Environment Variables

VITE_API_URL=http://localhost:5000/api
# Or for production:
VITE_API_URL=https://server-wheat-eight-61.vercel.app/api

Start the frontend:

npm run dev
# Frontend runs on http://localhost:5173

☁️ Deployment

Frontend (Cloudflare Pages)

  1. Go to Cloudflare Dashboard β†’ Pages
  2. Click Connect to Git and select your repository
  3. Configure settings:
    • Production branch: main
    • Build command: npm run build
    • Build output directory: dist
  4. Add environment variable:
    • VITE_API_URL = https://server-wheat-eight-61.vercel.app/api
  5. Click Save and Deploy

Backend (Vercel)

The backend is already deployed to Vercel. To redeploy:

  1. Push changes to GitHub
  2. Vercel will automatically deploy

Or manually:

cd server
npm install -g vercel
vercel --prod

οΏ½ API Endpoints

Authentication

Method Endpoint Description
POST /api/auth/register Register new user
POST /api/auth/login Login user
GET /api/auth/me Get current user

Bills

Method Endpoint Description
GET /api/bills Get all bills for user
POST /api/bills/manual Add bill manually
POST /api/bills/upload Upload receipt (with OCR)
GET /api/bills/summary Get spending summary
GET /api/bills/image/:key Get receipt image

πŸ”§ Cloudflare D1 Database Schema

CREATE TABLE users (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  email TEXT UNIQUE NOT NULL,
  password TEXT NOT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE bills (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  user_id INTEGER NOT NULL,
  title TEXT NOT NULL,
  amount REAL NOT NULL,
  category TEXT,
  date DATE NOT NULL,
  type TEXT NOT NULL,
  file_path TEXT,
  vendor_name TEXT,
  invoice_no TEXT,
  phone_number TEXT,
  address TEXT,
  items_json TEXT,
  subtotal REAL,
  discount REAL,
  total_qty INTEGER,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  FOREIGN KEY (user_id) REFERENCES users(id)
);

πŸ“ License

MIT License - feel free to use this project for learning or personal use.

πŸ‘€ Author

Saikumar Bali


Built with ❀️ using React, Express, and Cloudflare

About

A full-stack bill tracking application that allows users to upload, manage, and track bills digitally. Built with React, Node.js, and MySQL with OCR support for extracting bill details automatically.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors