How rajadilipkolli/hilla-folioman works
1. Overall shape
FolioMan is a single Spring Boot monolith with a React/Hilla frontend embedded in the same deployable application. The browser UI is built from src/main/frontend, while the server-side domain, REST APIs, security, persistence, and background jobs live under src/main/java/com/app/folioman.
2. Primary user-facing flows
The frontend is route-based and centered on a few views: login, user profile, mutual fund scheme search, portfolio overview, CAS import, and rebalance. MainLayout provides the shell/navigation, and auth.ts handles client-side auth integration. The frontend talks to backend endpoints over HTTP; there is no separate frontend server in production.
3. Security boundary
Authentication is handled in the auth package with JWT-based security. The flow includes login, access token issuance, refresh tokens, token blacklist support, login-attempt tracking, and a JWT filter inserted into Spring Security. User profile and user-info endpoints sit behind this security layer. A default admin account is seeded for local/testing use.
4. Mutual-fund reference data subsystem
The mfschemes package is the reference-data engine for AMC, scheme, and NAV information. It integrates with external mutual-fund data sources such as AMFI and BSE Star through scheduled sync services and REST clients. This subsystem stores scheme metadata and NAV history, exposes scheme/NAV APIs, and keeps a local searchable copy of fund master data.
5. Portfolio ingestion and analytics subsystem
The portfolio package is the transactional core. It ingests CAS files from mutual fund registrars, extracts holdings and transactions, persists investor/folio/scheme/transaction records, and computes portfolio values, monthly/yearly summaries, and rebalancing recommendations. It also contains valuation logic such as XIRR calculations and aggregation projections for the UI.
6. Non-JVM processing boundary
CAS PDF parsing crosses a clear process boundary via the pythonbridge package. Java commands are translated into Python executions, with explicit handling for missing Python, execution failures, and timeouts. This is a key architectural dependency because CAS import will not work without the external Python CLI tooling (casparser).
7. Persistence model
The application uses PostgreSQL with Liquibase changelogs to create and evolve schemas for auth, mutual-fund reference data, and portfolio data. The codebase relies heavily on JPA entities, Spring Data repositories, and projection interfaces to shape query results for REST responses. The repo layout suggests a domain-oriented schema split rather than a single flat table model.
8. Caching strategy
Redis is a first-class infrastructure dependency. There is a custom cache manager, cache circuit breaker, TTL adjustment policies, and adaptive cache-sizing logic. Caches are used to protect expensive reference-data and portfolio computations, especially where NAV and scheme data are reused frequently.
9. Background processing and eventing
Several services run asynchronously or on schedules: scheme/NAV synchronization, portfolio value updates, and cache policy evaluation. The shared.events package and listeners such as NewlyInsertedSchemesListener show that the app uses internal events to propagate changes between subsystems without tight coupling.
10. Cross-cutting infrastructure
Common application concerns are centralized under config: async execution, scheduling, CORS, global exception handling, REST client setup, OpenTelemetry appender installation, and database connection tuning. This makes the runtime behavior more operationally robust and shows that the app is designed for long-running server deployment, not just local development.
11. Operational topology
Local development is container-friendly: the repo includes Docker Compose for PostgreSQL and pgAdmin, plus Spring profiles for local and production. The backend is packaged as a single JAR that includes the frontend assets, so deployment is effectively one service with external dependencies on PostgreSQL, Redis, and Python tooling.
12. How the main data flows connect
The critical flow is: user logs in → JWT-secured API calls → CAS import or portfolio actions → Python parsing and domain persistence → reference-data lookup for schemes/NAVs → cached portfolio calculations → REST responses back to the React UI. External mutual-fund feeds continuously refresh the reference-data layer, and portfolio analytics consume that data to keep valuations and recommendations current.
Main entry points: routes.tsx UI routes · portfolio/domain Portfolio core · mfschemes/domain Scheme sync · config App config
Components 21
Frontend
Embedded React/Hilla UI in the monolith.
- UI shell · Top-level app shell and route composition for the browser UI.
src/main/frontend/views/MainLayout.tsx - UI routes · Route setup and view wiring for the embedded frontend.
src/main/frontend/routes.tsx - Client auth · Browser-side auth integration and token/session handling.
src/main/frontend/auth.ts - Login · User sign-in screen.
src/main/frontend/views/login/LoginView.tsx - Portfolio · Portfolio overview and summaries in the UI.
src/main/frontend/views/userPortfolio/UserPortfolioView.tsx - CAS import · UI for importing mutual-fund CAS files.
src/main/frontend/views/importmutualfunds/ImportMutualFundsView.tsx - Rebalance · UI for rebalancing recommendations.
src/main/frontend/views/rebalance/ReBalanceView.tsx - Profile · User profile and account information view.
src/main/frontend/views/userprofile/UserProfileView.tsx - Schemes · Search and browse mutual-fund schemes and NAVs.
src/main/frontend/views/mfschemes/MfSchemesView.tsx
Backend
Spring Boot domain and API layers.
- FolioMan app · Single deployable that bundles the backend and embedded frontend.
src/main/java/com/app/folioman/Application.java - Auth API · Login, user-info, and profile endpoints behind JWT security.
src/main/java/com/app/folioman/auth/rest/AuthController.java - JWT security · JWT issuance, refresh tokens, blacklist, login-attempt tracking, and filter-based enforcement.
src/main/java/com/app/folioman/auth - MF APIs · Scheme and NAV REST endpoints.
src/main/java/com/app/folioman/mfschemes - Scheme sync · AMC, scheme, and NAV ingestion plus synchronization logic.
src/main/java/com/app/folioman/mfschemes/domain - Portfolio API · Import, transaction, and rebalance REST endpoints.
src/main/java/com/app/folioman/portfolio/PortfolioAPI.java - Portfolio core · CAS ingestion, folio persistence, valuation, summaries, and rebalance calculations.
src/main/java/com/app/folioman/portfolio/domain
Infrastructure
Cross-cutting runtime and integration support.
- Python bridge · Executes external Python tooling for CAS PDF parsing and handles failures/timeouts.
src/main/java/com/app/folioman/pythonbridge - Redis cache · Custom cache manager, circuit breaker, TTL adjustment, and cache-size policies.
src/main/java/com/app/folioman/config/redis - PostgreSQL + Liquibase · Versioned relational schema for auth, reference data, and portfolio records.
src/main/resources/db/changelog/db.changelog-master.yaml - Shared events · Application events used to decouple refresh and update flows across subsystems.
src/main/java/com/app/folioman/shared/events - App config · Async, scheduling, CORS, exception handling, telemetry, and database/runtime tuning.
src/main/java/com/app/folioman/config
Connections 26
- FolioMan app → UI shell: serves UI · Backend packages and serves the embedded frontend assets.
- UI shell → UI routes: navigates · The shell hosts route-based views.
- UI routes → Client auth: auth flow · Routes coordinate client-side authentication state.
- UI routes → Login: shows · Login is one of the primary routes.
- UI routes → Portfolio: shows · Portfolio overview route.
- UI routes → CAS import: shows · CAS import route.
- UI routes → Rebalance: shows · Rebalance route.
- UI routes → Profile: shows · Profile route.
- UI routes → Schemes: shows · Scheme search and NAV browsing route.
- Client auth → Auth API: calls · Frontend auth integrates with backend authentication endpoints.
- Auth API → JWT security: protected by · Auth endpoints sit inside the JWT security boundary.
- JWT security → PostgreSQL + Liquibase: persists · Refresh tokens, users, roles, and blacklist-related state are stored in the database.
- MF APIs → Scheme sync: delegates · Reference-data endpoints rely on sync and lookup services.
- Scheme sync → PostgreSQL + Liquibase: stores · Scheme, AMC, type, and NAV data are persisted relationally.
- Scheme sync → Redis cache: caches · Reference-data lookups and NAV reuse are accelerated through Redis.
- Scheme sync → Shared events: publishes · New scheme insertions and refresh events are propagated internally.
- Portfolio API → Portfolio core: delegates · Portfolio endpoints invoke ingestion, valuation, and rebalance logic.
- Portfolio core → Python bridge: parses CAS · CAS import crosses into Python tooling for PDF extraction.
- Portfolio core → Scheme sync: looks up NAV · Portfolio valuation and recommendations depend on scheme and NAV reference data.
- Portfolio core → PostgreSQL + Liquibase: stores · Investor, folio, scheme, transaction, and value records are persisted.
- Portfolio core → Redis cache: caches · Expensive valuations and summaries are cached.
- Portfolio core → Shared events: consumes · Portfolio updates react to internal application events.
- App config → JWT security: configures · Security behavior is wired through application configuration.
- App config → Redis cache: configures · Cache policies and Redis runtime are centralized here.
- App config → PostgreSQL + Liquibase: configures · Data source and persistence behavior are tuned here.
- App config → Python bridge: configures · Python execution settings and timeouts are supplied through config.