# karthik2428/finwiz architecture

> Architecture diagram of the GitHub repository karthik2428/finwiz, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/karthik2428/finwiz
- Repository: https://github.com/karthik2428/finwiz

## Overview

1. **System shape**
   - Finwiz is a two-tier finance app: a React single-page frontend in `client/` and an Express/MongoDB backend in `server/`.
   - The main data path is: browser UI → frontend API service → Express routes/controllers → Mongoose models → MongoDB.

2. **Frontend shell**
   - The client is built with **React + Vite** and styled with **Tailwind** utilities.
   - `App.jsx` and `main.jsx` likely define the app shell and route mounting, while `AuthContext` holds login/session state across the UI.

3. **Frontend feature areas**
   - User-facing pages are split by concern: dashboard, transactions, budget, goals, profile, subscriptions, premium, and onboarding/auth flows such as login, signup, OTP verification, forgot/reset password.
   - There is also a separate **admin section** under `client/src/pages/admin`, indicating the UI has both consumer and administrative workflows.

4. **Frontend layout and reusable components**
   - Shared layout components (`DashboardLayout`, `Navbar`, `Sidebar`, `NotificationCenter`, `PrivateRoute`) define the authenticated app shell and route protection.
   - Common primitives like `Button`, `Input`, `Modal`, `Table`, `Card`, `ProgressBar`, and `DateInput` keep the UI consistent across finance pages.

5. **Client-side service layer**
   - `client/src/services/api.js` is the primary backend integration point.
   - Specialized frontend services for `analytics`, `forecast`, and `recommendation` suggest the UI consumes computed finance insights rather than only raw CRUD data.

6. **Backend API organization**
   - The server is organized by domain with routes/controllers for auth, transactions, budgets, goals, analytics, forecast, recommendations, news, notifications, payments, subscriptions, reports, and user management.
   - Admin capabilities are isolated in their own route/controller set: config, funds, logs, news, payments, system, and users.

7. **Persistence model**
   - MongoDB is the core datastore via Mongoose models.
   - The schema set shows the app tracks users, transactions, budgets, goals, subscriptions, payments, notifications, OTPs, reports, logs, and admin/configuration objects such as `Config`, `NewsSetting`, and `FundMetadata`.

8. **Derived finance intelligence**
   - The backend contains substantial business logic for computation, not just storage.
   - Utility modules such as `analyticsMath`, `forecastMath`, `goalMath`, `riskCalculator`, `categorizer`, `subscriptionDetector`, and `mfMath` indicate that budgeting, forecasting, categorization, and recommendation features are calculated server-side.

9. **External service integrations**
   - The app integrates with email and payment providers: `brevoService` for messaging/email and `razorpayService` for payments.
   - `pdfService` supports document/report generation, and `mfService` plus news-related services suggest enrichment from external market/news sources.

10. **Background processing**
   - Several cron-oriented services (`newsCron`, `notificationCron`, `paymentCron`, `reportCron`, `logCron`, and `cronService`) show that the backend runs scheduled jobs.
   - These jobs likely handle periodic news ingestion, notification delivery, payment/subscription upkeep, reporting, and maintenance/logging.

11. **Authentication and user lifecycle**
   - Authentication is handled by dedicated controllers and middleware, with OTP support via the `Otp` model and `otpGenerator`.
   - Password reset, verification, and protected-resource access are enforced through `auth` middleware and the frontend `PrivateRoute`.

12. **Operational boundaries**
   - Middleware separation is clear: `asyncHandler` for controller error wrapping, plus request/error logging middleware for observability.
   - The existence of both `client/vercel.json` and `server/vercel.json` suggests the frontend and backend can be deployed independently.

13. **Architecture summary for diagramming**
   - Model the repository as four major zones: public/auth flows, authenticated finance dashboard, admin console, and backend job/integration layer.
   - The central backend domain services are what connect raw user activity to analytics, forecasts, notifications, payments, and reports.

Main entry points: [`client/src/App.jsx`](https://github.com/karthik2428/finwiz/blob/main/client/src/App.jsx) (App Shell), [`server/src/index.js`](https://github.com/karthik2428/finwiz/blob/main/server/src/index.js) (Server), [`server/src/models/User.js`](https://github.com/karthik2428/finwiz/blob/main/server/src/models/User.js) (Domain Models), [`client/src/pages/Dashboard.jsx`](https://github.com/karthik2428/finwiz/blob/main/client/src/pages/Dashboard.jsx) (Finance Pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client App"]
  node_client_main(("Main<br/>React entry<br/>[main.jsx]"))
  node_client_app["App Shell<br/>React shell<br/>[App.jsx]"]
  node_client_auth["Auth State<br/>context<br/>[AuthContext.jsx]"]
  node_client_private["Private Route<br/>route guard<br/>[PrivateRoute.jsx]"]
  node_client_layout["Dashboard Layout"]
  node_client_api["API Client<br/>[api.js]"]
  node_client_insights["Insights Services<br/>[analytics.js]"]
  node_client_auth_pages["Auth Pages<br/>[Login.jsx]"]
  node_client_finance_pages["Finance Pages<br/>[Dashboard.jsx]"]
  node_client_admin["Admin UI<br/>admin pages<br/>[AdminDashboard.jsx]"]
end

subgraph group_server["Server API"]
  node_server_entry(("Server<br/>Express entry<br/>[index.js]"))
  node_server_auth["Auth API<br/>domain controllers/routes<br/>[authController.js]"]
  node_server_finance["Finance API<br/>domain controllers/routes"]
  node_server_intel["Insight API<br/>domain controllers/routes"]
  node_server_admin["Admin API<br/>admin controllers/routes"]
  node_server_jobs["Job Services<br/>scheduled services<br/>[cronService.js]"]
  node_server_external["External Integrations<br/>providers<br/>[brevoService.js]"]
end

subgraph group_data["Persistence"]
  node_server_models[("Domain Models<br/>mongoose models<br/>[User.js]")]
  node_server_db[("MongoDB<br/>database<br/>[db.js]")]
end

node_client_main -->|"mounts"| node_client_app
node_client_app -->|"uses"| node_client_auth
node_client_app -->|"protects"| node_client_private
node_client_app -->|"composes"| node_client_layout
node_client_app -->|"routes to"| node_client_auth_pages
node_client_app -->|"routes to"| node_client_finance_pages
node_client_app -->|"routes to"| node_client_admin
node_client_finance_pages -->|"calls"| node_client_api
node_client_finance_pages -->|"uses"| node_client_insights
node_client_admin -->|"calls"| node_client_api
node_server_entry -->|"exposes"| node_server_auth
node_server_entry -->|"exposes"| node_server_finance
node_server_entry -->|"exposes"| node_server_intel
node_server_entry -->|"exposes"| node_server_admin
node_server_entry -->|"starts"| node_server_jobs
node_server_entry -->|"integrates"| node_server_external
node_server_auth -->|"reads/writes"| node_server_models
node_server_finance -->|"reads/writes"| node_server_models
node_server_intel -->|"reads/writes"| node_server_models
node_server_admin -->|"reads/writes"| node_server_models
node_server_jobs -->|"runs"| node_server_external
node_server_models -->|"persists to"| node_server_db

click node_client_main "https://github.com/karthik2428/finwiz/blob/main/client/src/main.jsx"
click node_client_app "https://github.com/karthik2428/finwiz/blob/main/client/src/App.jsx"
click node_client_auth "https://github.com/karthik2428/finwiz/blob/main/client/src/context/AuthContext.jsx"
click node_client_private "https://github.com/karthik2428/finwiz/blob/main/client/src/components/layout/PrivateRoute.jsx"
click node_client_layout "https://github.com/karthik2428/finwiz/blob/main/client/src/components/layout/DashboardLayout.jsx"
click node_client_api "https://github.com/karthik2428/finwiz/blob/main/client/src/services/api.js"
click node_client_insights "https://github.com/karthik2428/finwiz/blob/main/client/src/services/analytics.js"
click node_client_auth_pages "https://github.com/karthik2428/finwiz/blob/main/client/src/pages/Login.jsx"
click node_client_finance_pages "https://github.com/karthik2428/finwiz/blob/main/client/src/pages/Dashboard.jsx"
click node_client_admin "https://github.com/karthik2428/finwiz/blob/main/client/src/pages/admin/AdminDashboard.jsx"
click node_server_entry "https://github.com/karthik2428/finwiz/blob/main/server/src/index.js"
click node_server_auth "https://github.com/karthik2428/finwiz/blob/main/server/src/controllers/authController.js"
click node_server_finance "https://github.com/karthik2428/finwiz/blob/main/server/src/controllers/transactionsController.js"
click node_server_intel "https://github.com/karthik2428/finwiz/blob/main/server/src/controllers/analyticsController.js"
click node_server_admin "https://github.com/karthik2428/finwiz/blob/main/server/src/controllers/adminConfigController.js"
click node_server_jobs "https://github.com/karthik2428/finwiz/blob/main/server/src/services/cronService.js"
click node_server_external "https://github.com/karthik2428/finwiz/blob/main/server/src/services/brevoService.js"
click node_server_models "https://github.com/karthik2428/finwiz/blob/main/server/src/models/User.js"
click node_server_db "https://github.com/karthik2428/finwiz/blob/main/server/src/config/db.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_main,node_client_app,node_client_auth,node_client_private,node_client_layout,node_client_api,node_client_insights,node_client_auth_pages,node_client_finance_pages,node_client_admin toneBlue
class node_server_entry,node_server_auth,node_server_finance,node_server_intel,node_server_admin,node_server_jobs,node_server_external toneAmber
class node_server_models,node_server_db toneMint
```

## Components

### Client App

React/Vite frontend with authenticated finance and admin workflows.

- [Main](https://github.com/karthik2428/finwiz/blob/main/client/src/main.jsx): React entry · Bootstraps the SPA and mounts the app. · `client/src/main.jsx`
- [App Shell](https://github.com/karthik2428/finwiz/blob/main/client/src/App.jsx): React shell · Top-level client composition and route wiring. · `client/src/App.jsx`
- [Auth State](https://github.com/karthik2428/finwiz/blob/main/client/src/context/AuthContext.jsx): context · Holds session and login state across the UI. · `client/src/context/AuthContext.jsx`
- [Private Route](https://github.com/karthik2428/finwiz/blob/main/client/src/components/layout/PrivateRoute.jsx): route guard · Protects authenticated screens in the client router. · `client/src/components/layout/PrivateRoute.jsx`
- [Dashboard Layout](https://github.com/karthik2428/finwiz/blob/main/client/src/components/layout/DashboardLayout.jsx): layout · Authenticated app shell with navigation and sidebar. · `client/src/components/layout/DashboardLayout.jsx`
- [API Client](https://github.com/karthik2428/finwiz/blob/main/client/src/services/api.js): service · Primary frontend integration point for backend calls. · `client/src/services/api.js`
- [Insights Services](https://github.com/karthik2428/finwiz/blob/main/client/src/services/analytics.js): services · Client-side access to analytics, forecast, and recommendations. · `client/src/services/analytics.js`
- [Auth Pages](https://github.com/karthik2428/finwiz/blob/main/client/src/pages/Login.jsx): pages · Login, signup, OTP, and password recovery flows. · `client/src/pages/Login.jsx`
- [Finance Pages](https://github.com/karthik2428/finwiz/blob/main/client/src/pages/Dashboard.jsx): pages · Dashboard, transactions, budget, goals, profile, subscriptions, and premium screens. · `client/src/pages/Dashboard.jsx`
- [Admin UI](https://github.com/karthik2428/finwiz/blob/main/client/src/pages/admin/AdminDashboard.jsx): admin pages · Administrative screens for config, funds, logs, news, payments, system, and users. · `client/src/pages/admin/AdminDashboard.jsx`

### Server API

Express backend with domain routes, business logic, and scheduled jobs.

- [Server](https://github.com/karthik2428/finwiz/blob/main/server/src/index.js): Express entry · Starts the API server and wires middleware, routes, and services. · `server/src/index.js`
- [Auth API](https://github.com/karthik2428/finwiz/blob/main/server/src/controllers/authController.js): domain controllers/routes · Handles login, verification, password reset, and protected access. · `server/src/controllers/authController.js`
- [Finance API](https://github.com/karthik2428/finwiz/blob/main/server/src/controllers/transactionsController.js): domain controllers/routes · Transactions, budgets, goals, user data, and reports endpoints. · `server/src/controllers/transactionsController.js`
- [Insight API](https://github.com/karthik2428/finwiz/blob/main/server/src/controllers/analyticsController.js): domain controllers/routes · Analytics, forecasting, recommendations, and news enrichment endpoints. · `server/src/controllers/analyticsController.js`
- [Admin API](https://github.com/karthik2428/finwiz/blob/main/server/src/controllers/adminConfigController.js): admin controllers/routes · Administrative configuration, logs, payments, news, funds, system, and user controls. · `server/src/controllers/adminConfigController.js`
- [Job Services](https://github.com/karthik2428/finwiz/blob/main/server/src/services/cronService.js): scheduled services · Cron-driven maintenance for news, notifications, payments, reports, and logs. · `server/src/services/cronService.js`
- [External Integrations](https://github.com/karthik2428/finwiz/blob/main/server/src/services/brevoService.js): providers · Email, payments, PDF generation, market data, and news services. · `server/src/services/brevoService.js`

### Persistence

MongoDB-facing Mongoose models that store app state and records.

- [Domain Models](https://github.com/karthik2428/finwiz/blob/main/server/src/models/User.js): mongoose models · Core persisted entities including users, transactions, budgets, goals, and operational records. · `server/src/models/User.js`
- [MongoDB](https://github.com/karthik2428/finwiz/blob/main/server/src/config/db.js): database · Primary datastore accessed through Mongoose. · `server/src/config/db.js`

## Connections

- Main → App Shell: mounts · Entry point renders the application shell.
- App Shell → Auth State: uses · App shell reads session state for routing and UI decisions.
- App Shell → Private Route: protects · Authenticated routes are wrapped by the guard.
- App Shell → Dashboard Layout: composes · Dashboard sections share the common authenticated layout.
- App Shell → Auth Pages: routes to · Public flows cover login, signup, OTP, and recovery.
- App Shell → Finance Pages: routes to · Primary user screens are mounted from the app router.
- App Shell → Admin UI: routes to · Admin screens are exposed as a separate UI area.
- Finance Pages → API Client: calls · Finance pages fetch and mutate backend data through the API service.
- Finance Pages → Insights Services: uses · Dashboard features consume computed analytics and forecasts.
- Admin UI → API Client: calls · Admin operations use the same backend integration layer.
- Server → Auth API: exposes · Authentication endpoints are registered in the API.
- Server → Finance API: exposes · Core finance endpoints handle app data flows.
- Server → Insight API: exposes · Insight endpoints serve analytics and recommendation features.
- Server → Admin API: exposes · Admin routes are mounted separately from consumer APIs.
- Server → Job Services: starts · Background cron jobs run alongside the API server.
- Server → External Integrations: integrates · Server services connect to third-party providers and market/news sources.
- Auth API → Domain Models: reads/writes · Auth logic persists users and OTP-related records.
- Finance API → Domain Models: reads/writes · Finance controllers store transactions, budgets, goals, reports, and notifications.
- Insight API → Domain Models: reads/writes · Insight endpoints rely on stored user and finance data.
- Admin API → Domain Models: reads/writes · Admin controls manage configuration, logs, payments, news settings, and funds metadata.
- Job Services → External Integrations: runs · Scheduled jobs trigger email, payment, reporting, and ingestion services.
- Domain Models → MongoDB: persists to · Mongoose models store data in MongoDB.
