

A full-stack portfolio analytics application with a React TypeScript frontend and Python FastAPI backend.
- Portfolio Overview Cards - Total value, gains/losses, holdings count, risk level
- Asset Allocation Charts - Interactive pie charts for sector and market cap distribution
- Holdings Table - Sortable, searchable table with all portfolio positions
- Performance Chart - Timeline comparison vs Nifty 50 and Gold benchmarks
- Top Performers - Best and worst performing stocks with insights
- 4 REST API Endpoints matching the assignment requirements exactly
- Excel Data Integration - Reads portfolio data from provided Excel file
- Real-time Calculations - Gain/loss, percentages, allocations computed on-the-fly
- Type Safety - Pydantic models for request/response validation
- Auto-generated API Docs - Interactive Swagger UI at
/docs
Endpoint | Description | Returns |
---|---|---|
GET /api/portfolio/holdings |
Complete holdings with calculations | List of enriched stock positions |
GET /api/portfolio/allocation |
Sector & market cap distribution | Percentage breakdowns with counts |
GET /api/portfolio/performance |
Historical timeline vs benchmarks | Performance data with returns |
GET /api/portfolio/summary |
Key portfolio metrics | Overview with top/worst performers |
- React 18 with TypeScript for type safety
- Vite for fast development and building
- Shadcn/ui + Tailwind CSS for modern, responsive design
- Recharts for interactive data visualizations
- TanStack Query for efficient API state management
- React Router for navigation
- Python 3.12 with FastAPI for high-performance APIs
- JSON-based data pipeline for optimal performance (Excel β JSON β API)
- Automatic data import from Excel with timestamped backups
- In-memory caching for sub-millisecond API responses
- Pydantic for data validation and serialization
- Uvicorn as ASGI server with auto-reload
- Node.js 18+ (for frontend)
- Python 3.12+ (for backend)
# Navigate to backend directory
cd backend
# Install Python dependencies (virtual environment already configured)
pip install -r requirements.txt
# Import Excel data to JSON (first time or after Excel updates)
python import_data.py
# Start the API server
python run.py
Backend will run on: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Alternative docs: http://localhost:8000/redoc
# Navigate to frontend directory
cd frontend
# Install frontend dependencies
npm install
# Start the development server
npm run dev
Frontend will run on: http://localhost:8080
# Run the integration test script
chmod +x test-integration.sh
./test-integration.sh
# Complete data update workflow
cd backend
./update_data.sh
This will:
- Import latest Excel data to JSON
- Reload API server cache
- Validate all endpoints
wealth-pulse-dash/
βββ frontend/ # React TypeScript Frontend
β βββ src/
β β βββ components/dashboard/ # Dashboard components
β β βββ api/portfolio.ts # API client
β β βββ pages/Index.tsx # Main dashboard page
β β βββ ...
β βββ package.json
β βββ vite.config.ts
βββ backend/ # Python FastAPI Backend
β βββ app/
β β βββ main.py # FastAPI application
β β βββ models.py # Pydantic models
β β βββ data_service.py # JSON processing logic
β β βββ __init__.py
β βββ data/
β β βββ portfolio_data.json # Generated JSON cache
β β βββ Sample Portfolio Dataset for Assignment.xlsx
β β βββ backups/ # Timestamped backups
β βββ requirements.txt
β βββ run.py # Server startup
β βββ README.md
βββ start-dev.sh # Development startup script
The application reads portfolio data from Sample Portfolio Dataset for Assignment.xlsx
with the following sheets:
- Holdings - Stock positions with quantities, prices, sectors
- Historical_Performance - Timeline data for performance charts
- Summary - Portfolio overview metrics
- Sector_Allocation - Sector distribution data
- Market_Cap - Market cap allocation data
- Top_Performers - Best/worst performing stocks
cd frontend
npm run dev # Start with hot reload
npm run build # Production build
npm run preview # Preview production build
python run.py # Start with auto-reload
# API will automatically restart when code changes
- Backend: Add new endpoints in
backend/app/main.py
, models inbackend/app/models.py
- Frontend: Add API calls in
frontend/src/api/portfolio.ts
, components infrontend/src/components/
- All 4 required API endpoints implemented exactly as specified
- Data calculations (gain/loss, percentages) working correctly
- Error handling with proper HTTP status codes
- CORS enabled for frontend integration
- Clean, documented code structure
- Portfolio overview cards with color-coded gains/losses
- Interactive asset allocation visualizations
- Sortable, searchable holdings table
- Performance comparison charts with hover effects
- Top performers section with insights
- Responsive design for mobile/desktop
- Loading states and error handling
The application is architected for easy deployment:
- Backend: Can be deployed to any platform supporting Python (Heroku, Railway, DigitalOcean, etc.)
- Frontend: Can be deployed to static hosting (Vercel, Netlify, GitHub Pages, etc.)
- Environment Variables: Backend URL configurable via frontend environment
- Integration test script validates all API endpoints
- Frontend automatically handles API failures gracefully
- Type safety ensures data consistency between frontend/backend
Portfolio Analytics Dashboard - Built with modern web technologies for optimal performance and user experience.
- Edit files directly within the Codespace and commit and push your changes once you're done.
This project is built with:
- Vite
- TypeScript
- React
- shadcn-ui
- Tailwind CSS