Skip to content

hetk987/Expense_Tracker

Repository files navigation

Expense Tracker Frontend

A modern, responsive web application for tracking expenses with automatic bank integration using Plaid. Built with Next.js, TypeScript, and Tailwind CSS.

Features

  • Dashboard: Overview of financial health with key metrics
  • Account Linking: Secure bank account connection via Plaid
  • Transaction Management: View, filter, and analyze transactions
  • Real-time Syncing: Automatic transaction updates
  • Responsive Design: Works seamlessly on desktop and mobile
  • Modern UI: Clean, intuitive interface with Tailwind CSS

Tech Stack

  • Framework: Next.js 14 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS
  • Icons: Lucide React
  • HTTP Client: Axios
  • Plaid Integration: react-plaid-link
  • State Management: React hooks with Zustand (for future expansion)

Getting Started

Prerequisites

  • Node.js 18+
  • npm or yarn
  • Backend server running (see backend README)

Installation

  1. Install dependencies:

    npm install
  2. Start the development server:

    npm run dev
  3. Open your browser: Navigate to http://localhost:3001

Project Structure

src/
├── app/                    # Next.js App Router pages
│   ├── globals.css        # Global styles
│   ├── layout.tsx         # Root layout
│   ├── page.tsx           # Dashboard page
│   ├── link-account/      # Account linking page
│   ├── transactions/      # Transactions page
│   ├── sign-in/           # Sign-in page
│   └── sign-up/           # Sign-up page
├── components/            # Reusable UI components
│   ├── ui/               # Base UI components
│   │   ├── button.tsx
│   │   ├── card.tsx
│   │   └── badge.tsx
│   ├── Header.tsx        # Main navigation header
│   └── AuthWrapper.tsx   # Authentication wrapper component
├── lib/                  # Utility functions and services
│   ├── api.ts           # API service layer
│   └── utils.ts         # Helper functions
└── types/               # TypeScript type definitions
    └── index.ts

Authentication

This application uses Clerk for user authentication and management. The integration follows the latest Next.js App Router patterns:

Features

  • Secure Authentication: User sign-in and sign-up with Clerk
  • Protected Routes: All main pages require authentication
  • User Management: Built-in user profile and account management
  • Modal Authentication: Seamless sign-in/sign-up experience

Authentication Flow

  1. Users can sign up or sign in using the buttons in the header
  2. All protected pages are wrapped with AuthWrapper component
  3. Unauthenticated users see a welcome message and sign-in options
  4. Authenticated users have access to the full expense tracking features

Key Components

Dashboard (/)

  • Financial overview with key metrics
  • Recent transactions preview
  • Linked accounts summary
  • Quick actions for syncing and linking accounts
  • Protected: Requires authentication

Link Account (/link-account)

  • Secure Plaid integration for bank account linking
  • Step-by-step account connection process
  • Security information and supported banks
  • Success confirmation with linked account details
  • Protected: Requires authentication

Transactions (/transactions)

  • Comprehensive transaction list with filtering
  • Date range and account filters
  • Pagination support
  • Transaction categorization and status indicators
  • Export and analysis features
  • Protected: Requires authentication

API Integration

The frontend communicates with the backend through a RESTful API:

  • POST /api/plaid/create-link-token - Initialize Plaid Link
  • POST /api/plaid/exchange-token - Complete account linking
  • GET /api/plaid/accounts - Fetch linked accounts
  • GET /api/plaid/transactions - Get transactions with filters
  • POST /api/plaid/sync - Manual transaction sync

Styling

The application uses Tailwind CSS for styling with a custom design system:

  • Primary Colors: Blue-based palette for brand elements
  • Semantic Colors: Green for income, red for expenses
  • Responsive Design: Mobile-first approach with breakpoints
  • Component Library: Reusable UI components with consistent styling

Development

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run start - Start production server
  • npm run lint - Run ESLint

Code Style

  • TypeScript for type safety
  • ESLint for code quality
  • Prettier for code formatting
  • Component-based architecture
  • Custom hooks for reusable logic

Deployment

Vercel (Recommended)

  1. Connect your GitHub repository to Vercel
  2. Set environment variables in Vercel dashboard
  3. Deploy automatically on push to main branch

Other Platforms

The app can be deployed to any platform that supports Next.js:

  • Netlify
  • AWS Amplify
  • DigitalOcean App Platform
  • Self-hosted servers

Environment Variables

Variable Description Default
NEXT_PUBLIC_API_URL Backend API URL http://localhost:3000

Email Configuration

The application uses Resend for sending budget alerts and weekly summaries. Configure the following environment variables:

Variable Description Required Default
RESEND_API_KEY Resend API key Yes -
FROM_EMAIL Email address to send from (must be verified in Resend) No onboarding@resend.dev
FROM_NAME Display name for email sender No Expense Tracker
NEXT_PUBLIC_APP_URL Base URL of your application (for email links) No http://localhost:3000

Resend Setup

  1. Sign up: Create an account at resend.com
  2. Get API key:
    • Go to API Keys in your Resend dashboard
    • Create a new API key
    • Copy the key (starts with re_)
  3. Verify domain (for production):
    • Add your domain in Resend dashboard
    • Follow DNS verification steps
    • Use your verified domain in FROM_EMAIL
  4. Development: You can use onboarding@resend.dev for testing without domain verification

Example .env.local:

RESEND_API_KEY=re_xxxxxxxxxxxxx
FROM_EMAIL=noreply@yourdomain.com
FROM_NAME=Expense Tracker
NEXT_PUBLIC_APP_URL=https://yourdomain.com

Note: For production, you must verify your sending domain in Resend. The default onboarding@resend.dev email only works for testing.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License.

Support

For support and questions:

  • Check the backend README for API documentation
  • Review Plaid documentation for integration details
  • Open an issue for bugs or feature requests

Releases

No releases published

Packages

 
 
 

Contributors

Languages