Welcome to SpendSight – a handy tool designed to help users keep track of their spending by simply uploading receipts. It's built using Next.js and TypeScript, with Supabase handling our backend tasks like authentication, storage, and the database, and OpenAI handling the magic of extracting receipt details.
With SpendSight, you can:
- Upload Receipts: Snap a picture or upload a digital receipt.
- AI-Powered Extraction: We'll automatically grab important details from the receipt, like items purchased and the total amount spent, thanks to OpenAI.
- Store Your Data: All extracted information is saved safely in the Supabase database.
- Track Your Spending: You can easily view your past purchases in a visually pleasing dashboard with graphs showing your spending trends.
- Export CSV: Want to take your data with you? You can export all your receipts into a CSV file anytime.
- Next.js: React framework for building the frontend.
- TypeScript: Ensures clean, well-typed code.
- Supabase: Used for user authentication, database management, and file storage.
- OpenAI API: Extracts all the essential details from your uploaded receipts.
Here’s a breakdown of the app flow:
- A user uploads a receipt image.
- OpenAI analyzes the image and extracts details like merchant name, date, items, and total amount.
- The extracted data is stored in Supabase for future access.
- On the user's dashboard, graphs and charts provide insights into spending habits.
- Users can also download their receipt data as a CSV file.
SpendSight relies on two main database tables for receipts and user profiles. Here's a quick look:
CREATE TABLE receipts (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY,
user_id UUID REFERENCES auth.users(id),
merchant VARCHAR(255) NOT NULL,
date DATE NOT NULL,
total_amount DECIMAL(10, 2) NOT NULL,
items JSONB,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
Copy code
CREATE TABLE profiles (
id UUID REFERENCES auth.users(id) PRIMARY KEY,
username VARCHAR(255) UNIQUE,
full_name VARCHAR(255),
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
To ensure user privacy, we have set up row-level security policies that restrict access to only the user’s data:
ALTER TABLE profiles ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Users can only view their own profile" ON profiles
FOR SELECT USING (auth.uid() = id);
CREATE POLICY "Users can update their own profile" ON profiles
FOR UPDATE USING (auth.uid() = id);
To store receipts, you'll need to create a storage bucket in Supabase:
- Open the Supabase dashboard.
- Create a bucket and name it receipts.
Before setting up the project, make sure you have:
- Node.js (v14 or higher)
- A Supabase account
- An OpenAI API key
- Clone this repository:
git clone https://github.com/your-username/spendsight.git
cd spendsight
- Install the necessary packages:
npm install
- Set up your environment variables. Create a
.env.local
file and add your Supabase and OpenAI credentials:
NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
OPENAI_API_KEY=your-openai-api-key
- Start the development server:
npm run dev
Now, visit http://localhost:3000 to start using SpendSight.
Thinking about contributing? Awesome! Here's what you need to do:
- Fork this repository.
- Create a new branch for your feature or fix.
- Make your changes.
- Submit a pull request, and we'll review it.
- Supabase Setup
- Make sure to configure Supabase for user authentication, storage, and database management:
- Create a bucket called
receipts
. - Run the SQL scripts for the
receipts
andprofiles
tables provided earlier and enable realtime.
- Upload Receipts: After signing up or logging in, start by uploading your receipts.
- AI Data Extraction: Watch as OpenAI works its magic by extracting key details.
- Track Spending: View the extracted details in your personalized dashboard.
- Export as CSV: Want a downloadable record? Export your receipt data in CSV format with one click.
Check out the deployed App