๐Ÿ’ฐ Expense Tracker

March 14, 2026 ยท View on GitHub

A modern, full-stack expense tracking application built with Next.js 15, tRPC, and PostgreSQL. Track your expenses, manage shared costs with friends, and gain insights into your spending patterns with beautiful analytics.

Next.js TypeScript tRPC PostgreSQL License: MIT

โœจ Features

  • ๐Ÿ’ณ Multi-Account Management - Track expenses across multiple bank accounts
  • ๐Ÿ‘ฅ Shared Expenses - Split costs with friends and track who owes what
  • ๐Ÿ“Š Analytics Dashboard - Visualize spending patterns with interactive charts
  • ๐Ÿ”„ Self Transfers - Record transfers between your own accounts
  • ๐Ÿ“ Transaction Sessions - Organize expenses into sessions for better tracking
  • ๐ŸŽจ Modern UI - Beautiful, responsive interface with dark/light theme support
  • ๐Ÿ” Secure Authentication - Email/password authentication with session management
  • โšก Real-time Updates - Optimistic updates with TanStack Query
  • ๐Ÿ“ฑ Mobile Responsive - Works seamlessly on desktop, tablet, and mobile devices
  • ๐Ÿ” Advanced Filtering - Filter and search transactions with URL-persisted state

๐Ÿš€ Tech Stack

Frontend

Backend

State Management & Forms

Developer Experience

๐Ÿ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js 20.x or higher
  • pnpm 8.x or higher (recommended) or npm/yarn
  • PostgreSQL 14.x or higher
  • Git

๐Ÿ› ๏ธ Installation

1. Clone the repository

git clone https://github.com/jainhardik120/expense-tracker.git
cd expense-tracker

2. Install dependencies

pnpm install
# or
npm install
# or
yarn install

3. Set up environment variables

Create a .env file in the root directory:

# Database
DATABASE_URL="postgresql://user:password@localhost:5432/expense_tracker"

# App URL (optional)
NEXT_PUBLIC_BASE_URL="http://localhost:3000"

# Skip environment validation during build (optional)
SKIP_ENV_VALIDATION=false

4. Set up the database

Generate and run database migrations:

# Generate migration files
pnpm db:generate

# Apply migrations to database
pnpm db:migrate

5. Start the development server

pnpm dev

Open http://localhost:3000 in your browser to see the application.

๐Ÿ—„๏ธ Database Schema

The application uses a multi-tenant architecture where all data is scoped by userId. Key entities include:

  • users - User accounts and profiles
  • sessions - Authentication sessions
  • bankAccount - User's financial accounts
  • statements - All transactions (expenses, transfers, etc.)
  • friendsProfiles - People involved in shared expenses
  • splits - How expenses are divided among friends
  • selfTransferStatements - Transfers between user's own accounts

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ app/                    # Next.js App Router
โ”‚   โ”œโ”€โ”€ (auth)/            # Authentication routes (login/register)
โ”‚   โ”œโ”€โ”€ (main)/            # Protected app routes
โ”‚   โ”‚   โ”œโ”€โ”€ sessions/      # Expense tracking sessions
โ”‚   โ”‚   โ”œโ”€โ”€ statements/    # Transaction management
โ”‚   โ”‚   โ””โ”€โ”€ aggregated/    # Analytics and summaries
โ”‚   โ””โ”€โ”€ api/               # API routes
โ”œโ”€โ”€ components/            # Reusable React components
โ”‚   โ”œโ”€โ”€ ui/               # shadcn/ui components
โ”‚   โ””โ”€โ”€ data-table/       # Table components with filtering
โ”œโ”€โ”€ server/               # Backend logic
โ”‚   โ”œโ”€โ”€ routers/          # tRPC routers
โ”‚   โ””โ”€โ”€ helpers/          # Helper functions
โ”œโ”€โ”€ db/                   # Database configuration
โ”‚   โ””โ”€โ”€ schema.ts         # Drizzle schema definitions
โ”œโ”€โ”€ lib/                  # Utility functions and configurations
โ””โ”€โ”€ hooks/                # Custom React hooks

๐ŸŽฏ Available Scripts

# Development
pnpm dev              # Start development server with Turbopack
pnpm build            # Build for production
pnpm start            # Start production server

# Database
pnpm db:generate      # Generate migration files
pnpm db:migrate       # Run database migrations

# Code Quality
pnpm lint             # Run ESLint
pnpm lint:fix         # Fix ESLint errors
pnpm typecheck        # Run TypeScript type checking
pnpm format           # Format code with Prettier

# Analysis
pnpm duplicate:check  # Check for code duplication
pnpm update:check     # Check for dependency updates

๐Ÿณ Docker Deployment

Build and run with Docker:

# Build the Docker image
docker build -t expense-tracker .

# Run the container
docker run -p 3000:3000 \
  -e DATABASE_URL="your_database_url" \
  expense-tracker

๐ŸŒ Deployment

Deploy with Vercel

  1. Push your code to GitHub
  2. Import your repository to Vercel
  3. Add environment variables
  4. Deploy!

Other Platforms

The application can be deployed to any platform that supports Node.js and Docker:

  • Railway
  • Render
  • Fly.io
  • AWS/GCP/Azure

Ensure you:

  1. Set up a PostgreSQL database
  2. Configure environment variables
  3. Run database migrations
  4. Deploy the application

๐Ÿค– Android Release Automation

The Android GitHub Actions workflow at .github/workflows/main.yml now publishes the release .aab to the Google Play internal track as part of the master release pipeline. A separate release trigger remains as a fallback for manually published GitHub releases.

Before that release job can succeed:

  1. Enable the Google Play Android Developer API for the Google Cloud project tied to your Play Console account.
  2. Create a service account key in JSON format.
  3. Add that service account under Google Play Console Users and permissions and grant it access to com.jainhardik120.expensetracker.
  4. Add the JSON file contents to the repository GitHub secret PLAYSTORE_SERVICE_ACCOUNT_JSON.
  5. Make sure the app already exists in Play Console and has had its first upload created manually.

๐Ÿค Contributing

Contributions are welcome! Please follow these steps:

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

Development Guidelines

  • Follow the existing code style
  • Run pnpm lint and pnpm typecheck before committing
  • Write meaningful commit messages
  • Update documentation as needed

๐Ÿ“ License

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

๐Ÿ™ Acknowledgments

๐Ÿ“ง Contact

For questions or feedback, please open an issue on GitHub.


Built with โค๏ธ using Next.js 15