Skip to content

Repository files navigation

πŸ“ˆ Real-Time Portfolio Tracker

A high-performance stock portfolio management system built with gRPC, featuring real-time price streaming, alerts, and portfolio analytics.

🎯 Features

  • Real-Time Price Updates: Server-side streaming of stock prices with sub-second latency
  • Portfolio Management: Track multiple stocks with purchase history and performance metrics
  • Price Alerts: Set custom alerts with notifications when target prices are reached
  • Bidirectional Streaming: Live portfolio updates while managing positions
  • Historical Data: View and analyze historical price trends
  • Multi-Language Support: Leveraging Protocol Buffers for polyglot development

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         gRPC/HTTP2        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚             │◄──────────────────────────►│             β”‚
β”‚   Frontend  β”‚    Bidirectional Stream    β”‚   Backend   β”‚
β”‚  (React +   β”‚    Server-Side Stream      β”‚    (Go)     β”‚
β”‚  gRPC-Web)  β”‚    Unary RPCs              β”‚             β”‚
β”‚             β”‚                             β”‚             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                             β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
                                                   β”‚
                                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
                                          β”‚                 β”‚
                                    β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
                                    β”‚ PostgreSQL β”‚   β”‚   Redis    β”‚
                                    β”‚ (Portfolio)β”‚   β”‚  (Cache)   β”‚
                                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tech Stack

Backend:

  • Go 1.24+
  • gRPC & Protocol Buffers
  • PostgreSQL (portfolio data)
  • Redis (price caching)
  • Alpha Vantage API (market data)

Frontend:

  • React 18.2+
  • gRPC-Web
  • Recharts (visualization)
  • Lucide React (icons)

DevOps:

  • Docker & Docker Compose
  • Envoy Proxy (gRPC-Web gateway)
  • Comprehensive Makefile (build, test, deploy)

πŸš€ Quick Start

Prerequisites

# Install Go 1.24+
go version

# Install Protocol Buffers Compiler
# Mac
brew install protobuf

# Ubuntu/Debian
sudo apt-get install protobuf-compiler

# Install gRPC tools
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

Quick Start with Makefile

# Clone the repository
git clone https://github.com/yourusername/realtime-portfolio-tracker.git
cd realtime-portfolio-tracker

# Complete setup (install deps, generate proto, build images)
make setup

# Start all services
make up

# View comprehensive help
make help

The application will be available at:

Alternative: Manual Development

# Start databases only
make up postgres redis envoy

# Run backend in development mode
make dev-backend

# Run frontend in development mode (new terminal)
make dev-frontend

Manual Setup

Backend:

cd backend

# Install dependencies and generate proto
make install-backend proto-backend

# Run server in development mode
make dev-backend

Frontend:

cd frontend

# Install dependencies and generate proto
make install-frontend proto-frontend

# Run development server
make dev-frontend

Demo Portfolio: The application comes with 6 pre-loaded stocks and streams live prices from 10 available symbols (AAPL, GOOGL, MSFT, AMZN, TSLA, META, NVDA, NFLX, JPM, JNJ).

Using the Makefile

The project includes a comprehensive Makefile with many useful commands:

# Development
make setup          # Complete project setup
make dev            # Start full development stack
make test           # Run all tests
make lint           # Lint all code
make format         # Format all code

# Docker operations
make up             # Start all services
make down           # Stop all services
make logs           # View all logs
make clean          # Clean everything

# Database
make db-shell       # PostgreSQL shell
make db-status      # Database status
make db-backup      # Backup database

# gRPC testing
make grpc-health    # Check gRPC health
make grpc-test      # Test gRPC endpoints

# Health checks
make health         # Check all services
make doctor         # System health check

πŸ“– API Documentation

gRPC Services

1. AddStock (Unary)

Add a new stock to your portfolio.

rpc AddStock(AddStockRequest) returns (AddStockResponse);

2. StreamPrices (Server Streaming)

Receive real-time price updates for your watchlist.

rpc StreamPrices(StreamPricesRequest) returns (stream PriceUpdate);

3. LivePortfolio (Bidirectional Streaming)

Interactive portfolio management with live updates.

rpc LivePortfolio(stream PortfolioAction) returns (stream PortfolioUpdate);

See proto/portfolio.proto for complete API definitions.

πŸ§ͺ Testing

# Run all tests
make test

# Backend tests only
make test-backend

# Frontend tests only
make test-frontend

# Generate coverage report
make test-coverage

# Run linting
make lint

# Auto-fix linting issues
make lint-fix

πŸ“Š Key Metrics

  • Latency: < 50ms for price updates
  • Throughput: Handles 10,000+ concurrent streams
  • Payload Size: 90% smaller than REST+JSON
  • Connection Efficiency: Single HTTP/2 connection for all operations

πŸ›£οΈ Roadmap

  • Basic portfolio management
  • Real-time price streaming
  • Price alerts
  • Authentication & Authorization (JWT)
  • Mobile app (React Native)
  • Advanced charts (candlestick, technical indicators)
  • Portfolio optimization suggestions
  • Multi-currency support
  • Social features (share portfolio performance)

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“ License

MIT License - see LICENSE file for details

πŸ™ Acknowledgments

  • Market data provided by Alpha Vantage
  • Built with gRPC
  • Inspired by modern trading platforms

πŸ“§ Contact

Your Name - @yourtwitter

Project Link: https://github.com/yourusername/realtime-portfolio-tracker


Note: This is a demonstration project for learning gRPC. Not intended for actual financial trading.

About

realtime-portfolio-tracker

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages