An open-source, self-hostable platform for creating, managing, and investing in custom stock baskets. Supports multiple brokers including Zerodha Kite and Angel One with unified symbol format.
- Name: OpenCase
- Goal: Enable users to create and manage personalized stock portfolios with multi-broker support
- Tech Stack: Hono + TypeScript + Cloudflare Pages/Workers + D1 Database + KV Storage
-
User Authentication System
- Email/Password signup and login
- First user automatically becomes admin
- Session management with KV storage
- Profile management
-
Multi-Broker Support
- Zerodha Kite Connect API (OAuth)
- Angel One Smart API (TOTP)
- Modular architecture for adding new brokers
- Unified symbol format across brokers
- Common holdings format for both brokers
-
Broker Account Management
- Add multiple broker accounts per user
- Connect/disconnect accounts
- TOTP-based authentication for Angel One
- OAuth flow for Zerodha
- Encrypted credential storage
- Active broker selection
-
Basket Management
- Create custom stock baskets (up to 100 stocks)
- Set custom weightages (must sum to 100%)
- Equal weight allocation with auto-calculation
- Theme-based categorization
- Risk level classification (low/moderate/high)
- Benchmark selection for comparison
-
Pre-built Templates
- IT Leaders, Banking Giants, Pharma Champions
- FMCG Essentials, Auto Revolution
- Nifty 50 Core, Dividend Kings, Small Cap Stars
-
Investment Features
- One-click basket purchase
- Direct order placement via broker API
- Investment tracking with P&L
- Portfolio rebalancing
- Holdings sync from broker
-
SIP (Systematic Investment Plan)
- Daily/Weekly/Monthly frequency
- Configurable investment dates
- Pause/Resume/Cancel SIPs
-
Alerts System
- Price alerts, Rebalance alerts
- P&L alerts, SIP reminders
-
Unified Instrument Database
- Download instruments from Zerodha and AngelOne
- Merged master instruments with unified symbols
- Broker-specific tokens preserved for API calls
- Real-time LTP fetching from connected broker
-
Index Support for Benchmarking
- NSE indices (NSE_INDEX exchange)
- BSE indices (BSE_INDEX exchange)
- Normalized index symbols (NIFTY, BANKNIFTY, FINNIFTY, etc.)
- 190+ NSE indices, 110+ BSE indices
- Common format across Zerodha and AngelOne
- Broker Holdings Integration
- Fetch holdings from connected broker (Zerodha/AngelOne)
- Common holdings format: symbol, exchange, quantity, product, pnl
- Unified symbol lookup from master instruments
- OpenCase holdings vs Broker holdings comparison
GET /api/setup/status- Check configuration statusGET /api/setup/brokers- List supported brokersPOST /api/setup/configure- Save broker API credentialsPUT /api/setup/default-broker- Set default broker
GET /api/user/status- Check user auth statusPOST /api/user/signup- Create new account (first user = admin)POST /api/user/login- Login with email/passwordPOST /api/user/logout- Clear sessionGET /api/user/profile- Get user profilePUT /api/user/profile- Update profile
GET /api/broker-accounts- List user's broker accountsPOST /api/broker-accounts- Add new broker accountDELETE /api/broker-accounts/:id- Remove broker accountPOST /api/broker-accounts/:id/connect- Connect to broker (OAuth/TOTP)POST /api/broker-accounts/:id/disconnect- Disconnect from brokerGET /api/broker-accounts/active- Get active connected account
GET /api/baskets- List user's basketsGET /api/baskets/templates- Get pre-built templatesPOST /api/baskets- Create new basket (up to 100 stocks)PUT /api/baskets/:id- Update basketDELETE /api/baskets/:id- Delete basketPOST /api/baskets/calculate-weights- Calculate equal weights
GET /api/investments- List investmentsPOST /api/investments/buy/:basketId- Generate buy ordersGET /api/investments/:id- Get investment detailsPOST /api/investments/:id/rebalance- Execute rebalance
GET /api/portfolio/summary- Portfolio summary with P&LGET /api/portfolio/holdings- Get OpenCase holdingsGET /api/portfolio/broker-holdings- Get holdings from connected broker
GET /api/instruments/search?q=:query- Search stocks with LTPGET /api/instruments/indices- List all indices for benchmarkingGET /api/instruments/indices?exchange=NSE_INDEX- NSE indices onlyGET /api/instruments/indices?q=NIFTY- Search indicesGET /api/instruments/popular- Popular stocks with LTPGET /api/instruments/ltp?symbols=NSE:TCS,NSE:INFY- Get LTP for symbolsPOST /api/instruments/download- Download Zerodha instrumentsPOST /api/instruments/download-angelone- Download AngelOne instrumentsGET /api/instruments/status- Check download status with counts
GET /api/sip- List user's SIPsPOST /api/sip- Create new SIPPUT /api/sip/:id- Update SIPPOST /api/sip/:id/pause- Pause SIPPOST /api/sip/:id/resume- Resume SIPDELETE /api/sip/:id- Cancel SIP
GET /api/auth/login- Redirect to broker loginGET /api/auth/callback- OAuth callback handlerGET /api/auth/status- Check authentication statusPOST /api/auth/logout- Clear session
- Design Documentation - Architecture, UI/UX, Components, Database, API specs
- Common Indices Reference - Index symbol mapping for Zerodha & AngelOne
# Install dependencies
npm install
# Apply database migrations
npm run db:migrate:local
# Seed with template data
npm run db:seed
# Build the project
npm run build
# Start development server
npm run dev- Prerequisites: Node.js 18+, Git
- Clone:
git clone https://github.com/marketcalls/opencase.git - Install:
npm install - Setup DB:
npm run db:migrate:local && npm run db:seed - Build:
npm run build - Run:
npm run dev - Open: http://localhost:3000
New User Setup:
- Open http://localhost:3000
- Click "Sign Up" (first user becomes admin)
- Enter name, email, and password
- After signup, you'll be redirected to onboarding
- Add your first broker account (Zerodha or Angel One)
- Enter API credentials
- Click "Connect" to authenticate with your broker
- Download master instruments from
/contractspage - Start creating baskets!
Adding Broker Accounts:
- Go to
/accountspage - Click "Add Account"
- Select broker type (Zerodha or Angel One)
- Enter API credentials
- For Zerodha: Click Connect -> OAuth redirect
- For Angel One: Enter TOTP code when prompted
Get API credentials from:
- Zerodha: https://developers.kite.trade
- Angel One: https://smartapi.angelbroking.com
| Script | Description |
|---|---|
npm run dev |
Vite dev server with hot reload |
npm run dev:sandbox |
Wrangler Pages dev (local D1) |
npm run build |
Build for production |
npm run db:migrate:local |
Apply migrations |
npm run db:seed |
Seed templates |
npm run db:reset |
Reset local database |
npm run deploy |
Deploy to Cloudflare Pages |
# Build and run with Docker Compose
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose down# Build the image
docker build -t opencase .
# Run container
docker run -d -p 3000:3000 --name opencase opencase
# Run with persistent data
docker run -d -p 3000:3000 \
-v opencase-data:/app/.wrangler/state/v3/d1 \
-e ENCRYPTION_KEY=your-secure-key-32chars!! \
--name opencase opencase# Run with hot-reload (mounts source code)
docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
# Rebuild after changes
docker-compose up --build| File | Description |
|---|---|
Dockerfile |
Multi-stage production build |
Dockerfile.dev |
Development build with all dependencies |
docker-compose.yml |
Production compose configuration |
docker-compose.dev.yml |
Development override with volume mounts |
.dockerignore |
Files excluded from build context |
# Create D1 database
npx wrangler d1 create opencase-db
# Apply migrations
npm run db:migrate:prod
# Deploy
npm run deploy:prod
# Set secrets
npx wrangler pages secret put ENCRYPTION_KEY --project-name opencase- Backend: Hono (TypeScript)
- Database: Cloudflare D1 (SQLite)
- Cache: Cloudflare KV
- Frontend: Vanilla JS + TailwindCSS (CDN)
- Charts: Chart.js
- Build: Vite
- Deployment: Cloudflare Pages
opencase/
├── src/
│ ├── index.tsx # Main app with HTML routes
│ ├── routes/ # API route handlers
│ │ ├── auth.ts # Legacy auth routes
│ │ ├── baskets.ts # Basket CRUD
│ │ ├── broker.ts # Broker account management
│ │ ├── instruments.ts # Stock search, indices, downloads
│ │ ├── investments.ts # Investment operations
│ │ ├── portfolio.ts # Holdings & portfolio
│ │ ├── setup.ts # Platform setup
│ │ ├── sip.ts # SIP management
│ │ └── user.ts # User authentication
│ ├── lib/ # Utility libraries
│ │ ├── kite.ts # Zerodha API client
│ │ ├── angelone.ts # AngelOne API client
│ │ └── utils.ts # Common utilities
│ └── types/ # TypeScript definitions
├── public/
│ └── static/
│ └── app.js # Frontend JavaScript
├── migrations/ # D1 database migrations
├── design/ # Design documentation
│ ├── ARCHITECTURE.md
│ ├── UI-UX-SPEC.md
│ ├── COMPONENTS.md
│ ├── DATABASE.md
│ └── API.md
├── docs/ # Additional documentation
│ └── COMMON-INDICES.md # Index symbol reference
└── wrangler.jsonc # Cloudflare configuration
- Historical performance charts
- Benchmark comparison visualization
- Email/SMS notifications
- Auto-execute SIP orders
- Dark mode UI
- Mobile responsive improvements
- Export portfolio reports (PDF/Excel)
- Dividend tracking
- Corporate actions handling
AGPL3 License - See LICENSE file for details.
See CONTRIBUTING.md for contribution guidelines.
This platform is not affiliated with Zerodha, Angel One, or Smallcase. Use at your own risk. Always verify orders before executing. This is not investment advice.
Last Updated: December 8, 2025 Status: Active Development Version: 1.0.0
{ "name": "opencase", "compatibility_date": "2025-12-06", "pages_build_output_dir": "./dist", "d1_databases": [{ "binding": "DB", "database_name": "opencase-db", "database_id": "your-database-id" }], "kv_namespaces": [{ "binding": "KV", "id": "your-kv-id" }] }