How bhavyaalekhya/nudget works
Main Components
a. Electron Shell (main.js)
• Acts as the desktop “container.”
• Launches two child processes in development: the Next.js dev server (frontend) and the Express server (backend).
b. Frontend – Next.js App
• Written in React with the App Router (app/ directory).
• Renders pages, React components (charts, panels, forms).
• Fetches data via HTTP/REST from the backend API.
• Uses Chart.js for visualizations and React Context for theming.
c. Backend – Express + Prisma ORM
• Exposes REST routes under /category, /theme, /prediction, /transactions.
• Business logic in route handlers and utility modules (e.g., predictSpending.ts).
• Uses Prisma as an ORM to read/write the SQLite database.
d. Database – SQLite
• A local file-based database (schema defined in prisma/schema.prisma).
• Migrated via Prisma Migrate (migrations folder).
e. Python Utilities (python-files/)
• A sidecar service or scripts for advanced categorization or ML (app.py, categorize.py).
• Could be invoked by Node (child_process) or run as a separate microservice.
Relationships and Data Flows
• Electron → Frontend: Electron’s BrowserWindow loads the Next.js URL (localhost:3000 in dev or static files in prod).
• Frontend ↔ Backend: All data operations (CRUD on expenses/incomes, forecast requests) flow via HTTP calls (e.g., fetchPrediction.ts).
• Backend → Database: Prisma client executes SQL queries on the SQLite file.
• Backend ↔ Python Utilities (optional): For transaction categorization or ML predictions, the Express server may spawn or send HTTP/RPC requests to the Python scripts.
Architectural Patterns
• Layered Architecture:
– Presentation Layer (Next.js)
– API Layer (Express routes/controllers)
– Data Access Layer (Prisma ORM)
– Database (SQLite)
• Separation of Concerns: Distinct repos/directories for frontend, backend, and desktop shell.
• Modular Components: Next.js App Router folders correspond to pages/views; Express routes map to resource controllers.
• Microservice-like Utility: The Python folder can be drawn as an external service if invoked at runtime.