Skip to content

manishkco/FinFlow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MERN Stack React 18 Vite Tailwind CSS License

πŸ’° FinFlow

A production-ready, full-stack personal finance tracker built with the MERN stack.
Track income & expenses Β· Visualize spending habits Β· Gain financial insights

Features β€’ Tech Stack β€’ Quick Start β€’ API Reference β€’ Deployment


✨ Features

πŸ” Secure Authentication
JWT tokens + bcrypt password hashing (12 rounds)
πŸ’Έ Transaction Management
Full CRUD β€” add, edit, delete income & expenses
πŸ“Š Interactive Dashboard
Live stats for income, expenses, balance & savings rate
πŸ“ˆ Analytics & Charts
Area, bar & pie charts with monthly breakdowns via Recharts
🏷 Category Tracking
Categorize expenses and view breakdown by category
πŸ”Ž Search, Filters & Pagination
Debounced search, type/category/date filters, paginated results
πŸŒ™ Dark Mode
Persisted theme toggle stored in localStorage
⚑ Blazing Fast
React 18 + Vite for near-instant hot reload
πŸ“± Fully Responsive
Mobile-first layout adapts to any screen size
🧩 Clean Architecture
Separated contexts, custom hooks & modular components

πŸ›  Tech Stack

Layer Technology
Frontend React Vite
Styling TailwindCSS
Charts Recharts
State Context API + Custom Hooks
Backend Node.js Express
Database MongoDB Mongoose
Authentication JWT + bcrypt
HTTP Client Axios

πŸ“ Project Structure

finance-tracker/
β”‚
β”œβ”€β”€ πŸ”§ backend/                          # Express REST API server
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── db.js                        # MongoDB connection setup
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ authController.js            # Signup, login, getMe, updateProfile
β”‚   β”‚   β”œβ”€β”€ transactionController.js     # CRUD operations for transactions
β”‚   β”‚   └── analyticsController.js       # Summary, monthly charts, categories
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── authMiddleware.js            # JWT verification & route protection
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ User.js                      # User schema (name, email, password)
β”‚   β”‚   └── Transaction.js              # Transaction schema (type, amount, etc.)
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ authRoutes.js               # Auth endpoints
β”‚   β”‚   β”œβ”€β”€ transactionRoutes.js        # Transaction endpoints
β”‚   β”‚   └── analyticsRoutes.js          # Analytics endpoints
β”‚   β”œβ”€β”€ .env.example                    # Environment variable template
β”‚   β”œβ”€β”€ package.json
β”‚   └── server.js                       # App entry point
β”‚
└── βš›οΈ frontend/                         # React SPA (Vite)
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ components/
    β”‚   β”‚   β”œβ”€β”€ Auth/                    # ProtectedRoute wrapper
    β”‚   β”‚   β”œβ”€β”€ Dashboard/              # StatsGrid, Charts, RecentTransactions
    β”‚   β”‚   β”œβ”€β”€ Layout/                 # AppLayout (sidebar + header)
    β”‚   β”‚   └── Modals/                 # TransactionModal, ConfirmModal
    β”‚   β”œβ”€β”€ context/
    β”‚   β”‚   β”œβ”€β”€ AuthContext.jsx          # Auth state & methods
    β”‚   β”‚   β”œβ”€β”€ TransactionContext.jsx   # Transaction state & CRUD
    β”‚   β”‚   └── ThemeContext.jsx         # Dark/light mode toggle
    β”‚   β”œβ”€β”€ hooks/
    β”‚   β”‚   β”œβ”€β”€ useAnalytics.js          # Analytics data fetcher
    β”‚   β”‚   └── useDebounce.js           # Debounced search input
    β”‚   β”œβ”€β”€ pages/                       # Login, Signup, Dashboard, Analytics, etc.
    β”‚   β”œβ”€β”€ services/
    β”‚   β”‚   └── api.js                   # Axios instance + interceptors
    β”‚   └── utils/
    β”‚       └── helpers.js               # Formatters, constants, color maps
    β”œβ”€β”€ index.html
    β”œβ”€β”€ vite.config.js
    └── tailwind.config.js

πŸš€ Quick Start

Prerequisites

Requirement Version
Node.js β‰₯ 18.x
npm β‰₯ 9.x
MongoDB β‰₯ 6.x (local or Atlas)

1️⃣ Clone the Repository

git clone https://github.com/manishkco/FinFlow.git
cd finance-tracker

2️⃣ Install Dependencies

# Backend
cd backend && npm install

# Frontend
cd ../frontend && npm install

3️⃣ Configure Environment Variables

Create a .env file inside backend/:

PORT=5000
MONGO_URI=mongodb://localhost:27017/finance_tracker
# For Atlas: mongodb+srv://<user>:<pass>@cluster.mongodb.net/finance_tracker

JWT_SECRET=pick_a_long_random_string_here_minimum_32_chars
JWT_EXPIRE=7d
NODE_ENV=development

⚠️ Never commit your .env file. It's already in .gitignore.

4️⃣ Run the Application

# Terminal 1 β€” Start backend
cd backend
npm run dev
# βœ… MongoDB Connected Β· πŸš€ Server running on port 5000

# Terminal 2 β€” Start frontend
cd frontend
npm run dev
# ⚑ App running on http://localhost:5173

5️⃣ Open & Use

  1. Navigate to http://localhost:5173
  2. Click "Create one" to sign up
  3. Start adding transactions and exploring the dashboard! πŸŽ‰

πŸ” Authentication Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Client     │────▢│   Express    │────▢│   MongoDB    β”‚
β”‚  (React)     │◀────│   Server     │◀────│   (Atlas)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

1. User signs up β†’ password hashed with bcrypt (12 rounds)
2. Server generates JWT token (expires in 7 days)
3. Token stored in localStorage
4. Axios interceptor attaches "Authorization: Bearer <token>" to every request
5. authMiddleware.js verifies token on protected routes
6. Token expired/invalid β†’ 401 β†’ auto-redirect to /login

πŸ”„ Data Flow

User Action (e.g. "Add Expense")
        ↓
TransactionModal.jsx  β†’  form state
        ↓
TransactionContext.addTransaction()
        ↓
services/api.js  β†’  POST /api/transactions
        ↓
authMiddleware  β†’  verify JWT
        ↓
transactionController.createTransaction()
        ↓
Transaction.create()  β†’  MongoDB
        ↓
Response { success: true, transaction: {...} }
        ↓
Context: prepend to state β†’ React re-renders β†’ UI updates ✨

πŸ”Œ API Reference

πŸ”‘ Auth Endpoints

Method Endpoint Auth Body / Notes
POST /api/auth/signup ❌ { name, email, password }
POST /api/auth/login ❌ { email, password }
GET /api/auth/me βœ… Returns current user profile
PUT /api/auth/profile βœ… { name, currency, monthlyBudget }

πŸ’³ Transaction Endpoints

Method Endpoint Auth Body / Notes
GET /api/transactions βœ… Query: ?type=income&category=Food&search=...&page=1&limit=20&startDate=&endDate=
POST /api/transactions βœ… { type, amount, category, description, date }
PUT /api/transactions/:id βœ… Same as POST body
DELETE /api/transactions/:id βœ… β€”

πŸ“Š Analytics Endpoints

Method Endpoint Auth Notes
GET /api/analytics/summary βœ… ?month=1&year=2025 β€” income, expenses, savings
GET /api/analytics/monthly βœ… Last 12 months of income & expenses (for charts)
GET /api/analytics/categories βœ… Expense breakdown by category for the month

🧩 Architecture Decisions

Why Context API over Redux?
For a finance app of this scale, Context API provides sufficient state management with far less boilerplate. Redux adds unnecessary complexity unless the app has 10+ slices of deeply nested state.
Why Vite instead of Create React App?
Vite is 10–20Γ— faster for development with near-instant hot module replacement. CRA is officially deprecated and no longer maintained.
Why separate Auth & Transaction contexts?
Separation of concerns. Auth state is required globally (header, protected routes, layout), while Transaction state is scoped to protected pages only β€” mounted inside ProtectedLayout for optimal performance.
Why Recharts?
Recharts is the most popular React charting library with a fully composable API β€” each axis, grid, and tooltip is a separate React component, making customization straightforward.

βœ… Feature Checklist

  • JWT authentication (signup, login, logout)
  • Password hashing (bcrypt, 12 rounds)
  • Protected routes (frontend + backend)
  • Add / Edit / Delete transactions
  • Income & Expense transaction types
  • Category system (Food, Transport, Bills, etc.)
  • Debounced search
  • Filters β€” type, category, date range
  • Pagination
  • Dashboard stats (income, expenses, balance, savings rate)
  • Area chart β€” 12-month income vs expenses
  • Pie chart β€” expense breakdown by category
  • Bar charts on Analytics page
  • Monthly analytics with month selector
  • Dark mode (persisted in localStorage)
  • Responsive mobile layout
  • Loading skeleton screens
  • Toast notifications
  • Profile settings (name, currency, monthly budget)
  • Keyboard-accessible modals

🚒 Deployment

πŸ–₯ Backend β€” Railway / Render
  1. Push code to GitHub
  2. Connect the repo on Railway or Render
  3. Set environment variables: MONGO_URI, JWT_SECRET, NODE_ENV=production
  4. Build command: npm install
  5. Start command: node server.js
🌐 Frontend β€” Vercel / Netlify
  1. Connect GitHub repo on Vercel or Netlify
  2. Root directory: frontend
  3. Build command: npm run build
  4. Output directory: dist
  5. Add env variable: VITE_API_URL=https://your-backend.railway.app
πŸ—„ Database β€” MongoDB Atlas
  1. Create a free cluster at cloud.mongodb.com
  2. Create a database user with read/write access
  3. Whitelist 0.0.0.0/0 in Network Access (or your server IP)
  4. Copy the connection string to your MONGO_URI env variable

πŸ›‘ Production Hardening

# Recommended packages for production
npm install helmet express-rate-limit compression morgan
Package Purpose
helmet Security headers (XSS, clickjacking, etc.)
express-rate-limit Rate limiting to prevent brute force
compression Gzip compression for faster responses
morgan HTTP request logging

Tip: MongoDB indexes are already configured on userId + date and userId + type for optimal query performance.


πŸ“Œ Roadmap

  • πŸ”” Budget alerts & smart notifications
  • πŸ“± React Native mobile app
  • πŸ“€ Export reports (CSV / PDF)
  • πŸ€– AI-powered spending insights
  • πŸ”— Bank account integration (Plaid)
  • πŸ‘₯ Multi-user household budgeting

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

Manish Kumar

GitHub


⭐ Support

If you found this project useful, please give it a ⭐ star on GitHub β€” it means a lot!

Built with ❀️ using the MERN Stack

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors