How neeraj966/finstreet works
Purpose and Runtime Shape
FinStreet is a two-process personal-finance system: a React/Vite browser client and a Node.js/Express REST API backed by MongoDB. It manages authenticated users’ expenses, budgets, recurring transactions, Paytm statement imports, account credits, reports, investments, events, and advice.
Entry points are Frontend/src/main.jsx and Frontend/src/App.jsx for the client, and Backend/src/index.js plus Backend/src/app.js for API startup and HTTP composition.
Client Application and Navigation
The frontend is a React single-page application with route-level finance modules. Core user state, including authenticated-user access, is centralized in Frontend/src/context/UserContext.jsx; shared navigation and authentication UI live in Frontend/src/componants/Navbar.jsx and Frontend/src/componants/GoogleAuthButton.jsx.
Primary feature screens are implemented as page components:
• Expenses/import/report workflow: Frontend/src/pages/Expenses.jsx
• Budget planning and status: Frontend/src/pages/Budget.jsx
• Dashboard aggregate views: Frontend/src/pages/Dashboard.jsx
• Account-credit history: Frontend/src/pages/MainAccount.jsx
The frontend targets the backend through VITE_BASE_URL; it does not host business persistence itself.
API Composition and Security Boundary
Express application setup, cross-origin behavior, middleware, and route registration are concentrated in Backend/src/app.js. Backend/src/index.js starts the service after database setup from Backend/src/DB/index.js.
API domains are exposed through dedicated route modules, notably:
• Backend/src/routes/User.route.js
• Backend/src/routes/Expense.route.js
• Backend/src/routes/Budget.route.js
• Backend/src/routes/Investment.route.js
• Backend/src/routes/Event.route.js
• Backend/src/routes/Advisor.route.js
JWT-based identity protection is the principal API boundary in Backend/src/middleware/auth.middleware.js. User session/token invalidation state is represented by Backend/src/models/Blacklist.model.js.
Finance Persistence Model
Mongoose models form the system of record in MongoDB. Expense records, including manually created and imported/recurring entries, are held in Backend/src/models/Expanse.model.js; category-period budgets are in Backend/src/models/Budget.model.js; users and main-account-related state are in Backend/src/models/User.model.js.
Controllers implement the API’s feature orchestration and aggregate rules:
• Backend/src/controller/Expense.Controller.js
• Backend/src/controller/Budget.Controller.js
• Backend/src/controller/User.Controller.js
Expense categories are shared domain vocabulary across backend operations through Backend/src/constants/categories.js, with a corresponding frontend set in Frontend/src/constants/categories.js.
Expense, Budget, and Recurrence Flow
Users create, query, edit, and delete expenses through the Expenses page to the expense API/controller, which persists records in MongoDB. Budget operations use the same category model, allowing budget progress, alerts, and dashboard calculations to compare category spending against monthly allocations.
Recurring monthly expenses are a backend concern implemented in Backend/src/utills/RecurringExpenses.js; generated records re-enter the normal expense persistence and reporting path rather than creating a separate transaction type.
Paytm Import and Reporting Boundary
Statement imports cross a file-processing boundary: uploaded/generated files reside under Backend/public/imports/, are parsed by Backend/src/utills/PaytmPassbook.js, and can also be run through Backend/scripts/importPaytmPassbook.js. The import flow maps paid rows into expense records and received rows into the user’s main-account history while suppressing duplicates.
Client-side downloadable report generation is isolated in Frontend/src/utils/reportExports.js, producing CSV/PDF from the data currently returned by API filters; it does not require a separate report service.
Supporting Finance Modules
Investments, events, and advice are independent API domains with separate controllers and models where applicable: Backend/src/controller/Investment.Controller.js, Backend/src/models/Investment.model.js, Backend/src/controller/Event.Controller.js, and Backend/src/models/Event.model.js. Their corresponding client pages extend the SPA without changing the core expense-budget-account flow.
External material dependencies are MongoDB/Mongoose for persistence, JWT for authentication, Multer and SheetJS for spreadsheet ingestion, and jsPDF-based frontend exports.
Main entry points: app.js Express app · main.jsx SPA entry & routes · Expense.Controller.js Expense API · index.js MongoDB
Components 22
React Client
- SPA entry & routes
Frontend/src/main.jsx - User context · Central authenticated-user state.
Frontend/src/context/UserContext.jsx - Navigation & Google auth
Frontend/src/componants/GoogleAuthButton.jsx - Expenses & reports · Expense management, import, and report workflow.
Frontend/src/pages/Expenses.jsx - Budget planning
Frontend/src/pages/Budget.jsx - Dashboard
Frontend/src/pages/Dashboard.jsx - Main account
Frontend/src/pages/MainAccount.jsx - CSV/PDF exports · Exports API-filtered client data.
Frontend/src/utils/reportExports.js
Express API
- API startup · Connects the database and starts Express.
Backend/src/index.js - Express app · CORS, middleware, and route registration.
Backend/src/app.js - JWT protection
Backend/src/middleware/auth.middleware.js - Token blacklist · Tracks invalidated sessions or tokens.
Backend/src/models/Blacklist.model.js
Finance Domains
- Expense API
Backend/src/controller/Expense.Controller.js - Budget API
Backend/src/controller/Budget.Controller.js - User & account API
Backend/src/controller/User.Controller.js - Investments, events & advice · Independent supporting finance modules.
Backend/src/routes/Investment.route.js - Expense categories · Shared vocabulary for expenses and budgets.
Backend/src/constants/categories.js - Recurring expense generator · Creates normal monthly expense records.
Backend/src/utills/RecurringExpenses.js
Import Pipeline
- Paytm statement parser · Maps paid rows to expenses and received rows to accounts.
Backend/src/utills/PaytmPassbook.js - Statement files
- Paytm import script
Backend/scripts/importPaytmPassbook.js
Other components
- MongoDB · Mongoose-backed finance and identity data.
Backend/src/DB/index.js
Connections 30
- SPA entry & routes → User context: provides user state
- SPA entry & routes → Navigation & Google auth: renders
- SPA entry & routes → Expenses & reports: routes to
- SPA entry & routes → Budget planning: routes to
- SPA entry & routes → Dashboard: routes to
- SPA entry & routes → Main account: routes to
- Expenses & reports → CSV/PDF exports: exports filtered data
- Expenses & reports → Express app: REST via VITE_BASE_URL
- Budget planning → Express app: REST
- Dashboard → Express app: REST aggregates
- Main account → Express app: REST
- API startup → Express app: starts
- API startup → MongoDB: connects
- Express app → JWT protection: protects routes
- JWT protection → Token blacklist: checks invalidation
- Express app → Expense API: expense routes
- Express app → Budget API: budget routes
- Express app → User & account API: user routes
- Express app → Investments, events & advice: supporting routes
- Expense API → MongoDB: expense records
- Budget API → MongoDB: budget records
- User & account API → MongoDB: users and account history
- Investments, events & advice → MongoDB: domain data
- Expense API → Expense categories: uses
- Budget API → Expense categories: compares spending
- Recurring expense generator → Expense API: creates expenses
- Statement files → Paytm statement parser: parsed by
- Paytm import script → Paytm statement parser: runs
- Paytm statement parser → Expense API: paid rows
- Paytm statement parser → User & account API: received rows