Skip to content
anandrajaram21Public

About

Private portfolio and goal tracker for Indian investors: mutual funds and stocks with live NAVs, XIRR, SIP planning and goal allocations

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Corpus

Private portfolio and goal tracking for Indian investors.

Track mutual funds and stocks, XIRR, SIPs and how close each goal is, in rupees.
Live NAVs from MFAPI and Yahoo Finance. Your data stays in your own database.

CI Next.js 16 Bun License: MIT

Corpus dashboard: portfolio value, XIRR, monthly investments, holdings and goal progress

✨ Features

  • 📈 Live portfolio: mutual funds via MFAPI scheme codes, stocks and ETFs via Yahoo Finance (NSE .NS and BSE .BO are tried automatically). Current value, gain and XIRR per holding and overall.
  • 🎯 Goals: targets in today's money, grown with your inflation assumption, with the monthly SIP each goal needs and whether you are on track.
  • 🔀 Allocations: split every investment across goals; goal progress is the allocated share of each holding's current value.
  • 🧾 Ledger: buys and sells with amount, NAV and units (units are calculated from amount / NAV).
  • ₹ Indian formatting: ₹12,34,567 grouping and compact ₹4.2L / ₹1.2Cr values, with the exact amount on hover.
  • 💾 Backups: export everything as JSON and import it back (replaces your data).
  • 🌗 Light and dark mode, works on phones.
Investments Goals
Investments table with gain, XIRR and expanded details Goals with inflation-adjusted targets, progress and SIP needed

🚀 Quick start

Requires Bun 1.4+ and a Google OAuth client.

git clone https://github.com/anandrajaram21/Corpus.git
cd corpus
bun install
cp .env.example .env

Fill in .env:

Variable Value
BETTER_AUTH_URL http://localhost:3000 locally, your site URL in production
BETTER_AUTH_SECRET a random string, e.g. openssl rand -base64 32 (required in production)
BETTER_AUTH_GOOGLE_CLIENT_ID / _SECRET from Google Cloud Console → APIs & Services → Credentials → OAuth client ID (Web application)
DATABASE_URL file:./db.sqlite for local SQLite, or libsql://… for Turso
DATABASE_AUTH_TOKEN Turso token; leave empty for local SQLite

Add this Authorized redirect URI to the Google OAuth client (one per environment):

http://localhost:3000/api/auth/callback/google

Create the tables and start the app:

bun run db:push   # applies src/server/db/schema.ts to DATABASE_URL
bun run dev       # http://localhost:3000

Then follow the in-app Guide: set assumptions → add goals → add investments → record transactions → allocate.

☁️ Deploy to Vercel

  1. Import the repo in Vercel. Bun is detected from bun.lock; no build settings are needed.
  2. Add the environment variables above. Use a hosted libSQL database such as Turso (DATABASE_URL=libsql://… plus DATABASE_AUTH_TOKEN), since the serverless filesystem is not persistent.
  3. Set BETTER_AUTH_URL to the production URL and add https://<your-domain>/api/auth/callback/google as a redirect URI in Google Cloud.
  4. Apply the schema to the production database from your machine: DATABASE_URL=… DATABASE_AUTH_TOKEN=… bun run db:push.

Quotes are cached in the Next.js data cache (MFAPI NAVs for 30 minutes, Yahoo prices for 5 minutes), so page loads don't wait on the quote APIs.

🗂️ Project structure

Path What it holds
src/app/(app)/ Signed-in pages (dashboard, investments, transactions, goals, allocations, assumptions, guide), shared layout, loading and error states
src/app/page.tsx Public landing and sign-in page
src/app/_components/ App shell, navigation, stat cards, tables and the create/edit forms (forms/)
src/app/api/ Better Auth handler, tRPC endpoint, JSON backup export/import (/api/data)
src/components/ui/ shadcn/ui primitives
src/lib/ Pure, unit-tested logic: XIRR and goal math (portfolio.ts), INR formatting (format.ts), quote sources (quote-sources.ts), backup format (backup.ts)
src/server/ Database (Drizzle schema), tRPC routers, auth, quote fetching, per-request data loaders
src/env.js Validated environment variables

🛠️ Development

Command What it does
bun run dev Development server
bun run check ESLint, TypeScript and Vitest (run before every commit)
bun run test Unit tests only
bun run build / bun run start Production build / server
bun run format:write Prettier
bun run db:push Apply the schema to DATABASE_URL
bun run db:studio Drizzle Studio

Stack: Next.js 16 (App Router, React 19), tRPC 11, Better Auth (Google), Drizzle ORM on SQLite/libSQL, Tailwind CSS 4 with shadcn/ui, Vitest. See AGENTS.md for architecture notes and project rules.

📄 License

MIT

About

Private portfolio and goal tracker for Indian investors: mutual funds and stocks with live NAVs, XIRR, SIP planning and goal allocations

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages