This is a locally-deployed, privacy-focused Budgeting Application designed to replace complex Excel spreadhseets with a modern, responsive Web Interface. It features a React frontend for a premium user experience and a lightweight Node.js backend for reliable file-based storage.
- Monthly Organization: Data is isolated by month (e.g.,
2025-12,2026-01). You can navigate forward and backward in time. - Income Tracking: Add unlimited income sources with "Projected" vs "Actual" values.
- Expense Categorization: Organize expenses into categories (Housing, Food, etc.). Each category has its own sub-table of items.
- Real-time Variance: The app automatically calculates the difference between Projected and Actual costs. Variances are color-coded (Green for good, Red for overspending).
- File-Based Database: All data is stored as transparent JSON files in the
data/directory. No complex database installation is required. - Templating System: You can design a "Perfect Month" (with all your standard rents/bills set up) and save it as a Default Template. Any new month you visit will automatically clone this structure.
- Import/Export:
- Export: Download the current month's data as a JSON file backup.
- Import: Upload a JSON file to overwrite/restore data for the current month.
- Reset: One-click reset to wipe the current month and re-apply the Default Template.
- Dashboard Charts:
- Expense Breakdown: Pie chart showing percentage of spending per category.
- Income vs Expense: Bar chart for quick monthly health check.
- Historical Statistics:
- Cash Flow Trend: Line chart tracking Income vs Expenses over the last 6-12 months.
- Savings Rate: Analysis of your savings percentage over time.
- Budget Accuracy: Comparison of how well you stick to your Projected Budget.
graph TD
User[User Browser] <-->|HTTP/JSON| Frontend[React App (Vite)]
Frontend <-->|REST API| Backend[Node.js Server]
Backend <-->|Read/Write| Storage[File System (./data/*.json)]
-
Frontend (React + Vite):
- Built with React 18.
- Uses
rechartsfor visualization. - Uses
react-router-domfor navigation. - Styled with modular CSS and a global Design System (
index.css) for a premium look.
-
Backend (Node.js + Express):
- A lightweight REST API running on port
3001. - Handles file I/O operations (Reading and Writing JSON files).
- Zero-config: Uses the local filesystem directly.
- A lightweight REST API running on port
-
Data Persistence:
- Data is stored in the
data/folder in the project root. - Format:
YYYY-MM.json(e.g.,2025-12.json). - Template:
default_template.json.
- Data is stored in the
This custom hook is the "Brain" of the frontend.
- Fetching: On mount, it fetches the list of available months from
/api/months. - Loading: When
curMonthchanges, it queries the API for that specific month's data. If the API returnsnull, it initializes a fresh state using client-side defaults. - Auto-Save: It implements a "Debounced Save". It waits for the user to stop typing (500ms) before sending a
POSTrequest to the backend, ensuring distinct updates without spamming the server. - Actions: Exposes atomic actions (
addIncome,updateCategory,saveAsTemplate) to the UI components.
GET /api/months/:id: Checks for a file named{id}.json. If not found, checks fordefault_template.json. If neither, returns empty.POST /api/months/:id: Receives JSON body and writes it directly to disk.GET /api/months: Scans the directory usingfs.readdirSync, filters for valid regex^\d{4}-\d{2}\.json$, and returns the sorted list. This powers the trend charts.
Since this app uses a local filesystem backend, it is designed to be Self-Hosted or run Locally.
- Node.js: You must have Node.js installed (Version 18 or higher recommended).
- Mac:
brew install node - Windows: Download installer from nodejs.org
- Mac:
To use the app on your personal computer:
- Open Terminal in the project folder (
budgetApp). - Install Dependencies (only needed once):
npm install
- Start the App:
npm run dev
- This command uses
concurrentlyto start BOTH the React frontend (Vite) and the Node backend (server.cjs). - You will see output indicating the server is running on
http://localhost:3001and Vite onhttp://localhost:5173.
- This command uses
- Access App: Open your browser to http://localhost:5173.
If you want to run it as a stable service (e.g., on a Raspberry Pi or a Home Server):
-
Build the Frontend: This compiles the React code into static HTML/CSS/JS files.
npm run build
This creates a
dist/folder. -
Serve the Build: The
server.cjsfile is already configured to serve the frontend! -
Run the Server:
node server.cjs
Now the app is running in production mode at
http://localhost:3001.Benefits: Faster than
npm run dev, no formatting/linting overhead. Ideal for running on a personal server without Docker.
The easiest way to run the app in production or on a server (NAS, Raspberry Pi).
- Build & Run:
docker-compose up -d --build
- Access:
Go to
http://localhost:3001 - Data Persistence:
Your data is safe! The
docker-compose.ymlfile maps the container's storage to your local./datafolder. You can see your JSON files updating in real-time on your host machine.
budgetApp/
βββ data/ # <--- YOUR DATA LIVES HERE (JSON files)
βββ public/ # Public assets
βββ src/
β βββ components/ # React Components
β β βββ BudgetView.jsx # Main Dashboard
β β βββ StatsView.jsx # Analytics Page
β β βββ FinanceTable.jsx # Reusable Table
β βββ hooks/
β β βββ useBudgetData.js # State Management & API Calls
β βββ App.jsx # Main Layout & Routing
β βββ main.jsx # Entry point
βββ server.cjs # Node.js Backend Server
βββ package.json # Dependencies & Scripts
βββ vite.config.js # Vite Configuration