af9bf84d0a302adf55c6e7e085fd97a136c85c10
Stock Tax Analyzer - Deployment Guide
A complete stock portfolio analyzer with tax-eligible holdings calculation, real-time prices, and stock split adjustments.
Project Structure
stock-tax-analyzer/
├── main.go # Go backend server
├── go.mod # Go module file
├── index.html # React frontend app
├── Dockerfile # Multi-stage Docker build
├── docker-compose.yml # Docker Compose configuration
└── README.md # This file
Features
- 📊 Analyze Revolut trading statements
- 💰 Real-time stock prices in EUR
- 🏆 Tax-eligible holdings (stocks held >2 years)
- 📈 Stock split adjustments (NVDA, TSLA, AAPL, GOOGL, AMZN)
- 💵 Portfolio valuation with gain/loss calculations
- 🔒 Runs entirely on your server - no data leaves your infrastructure
Quick Start
Option 1: Using Docker Compose (Recommended)
- Create a directory and copy all files:
mkdir stock-tax-analyzer
cd stock-tax-analyzer
# Copy: main.go, go.mod, index.html, Dockerfile, docker-compose.yml
- Build and run:
docker-compose up -d
- Access the application:
http://localhost:8080
Option 2: Using Docker
- Build the image:
docker build -t stock-analyzer .
- Run the container:
docker run -d -p 8080:8080 --name stock-analyzer stock-analyzer
- Access the application:
http://localhost:8080
Option 3: Manual Build (without Docker)
-
Install Go 1.21 or higher
-
Build the Go backend:
go build -o stock-analyzer main.go
- Create static directory:
mkdir -p static
cp index.html static/
- Run the server:
./stock-analyzer
- Access the application:
http://localhost:8080
How to Use
- Open the application in your browser
- Click "Click to upload CSV file"
- Select your Revolut trading statement CSV file
- Wait for the analysis to complete
- Review your portfolio:
- Total Holdings: All your stocks
- Tax-Eligible Holdings: Stocks bought more than 2 years ago
API Endpoint
POST /api/stock-prices
Fetches current stock prices from Yahoo Finance.
Request:
{
"tickers": ["AAPL", "MSFT", "GOOGL"]
}
Response:
{
"prices": {
"AAPL": {
"ticker": "AAPL",
"usd": 150.25,
"eur": 138.23,
"success": true
}
},
"exchangeRate": 0.92
}
Configuration
Environment Variables
PORT: Server port (default: 8080)TZ: Timezone (default: Europe/Zagreb)
Supported Stock Splits
The application includes historical stock split data for:
- NVDA: 6 splits (including 10:1 in 2024)
- TSLA: 2 splits (3:1 and 5:1)
- AAPL: 5 splits (including 4:1 in 2020)
- GOOGL: 1 split (20:1 in 2022)
- AMZN: 4 splits (including 20:1 in 2022)
Architecture
Multi-stage Docker Build
- Stage 1 (static-builder): Prepares static HTML files
- Stage 2 (go-builder): Compiles Go backend
- Stage 3 (final): Clean Alpine image with binary and static files
Benefits:
- Small final image size (~15MB)
- No build tools in production image
- Secure and efficient
Backend (Go)
- HTTP server on port 8080
- Fetches stock prices from Yahoo Finance
- Handles CORS and rate limiting
- Serves static frontend files
Frontend (React)
- Pure client-side React app
- No build step required
- Processes CSV files in browser
- Calls backend API for stock prices
Troubleshooting
Stock prices showing as N/A
- Check if Yahoo Finance is accessible from your server
- Verify network connectivity
- Check Docker logs:
docker-compose logs -f
Port already in use
Change the port in docker-compose.yml:
ports:
- "9090:8080" # Use port 9090 instead
File upload not working
- Ensure the CSV file is a valid Revolut trading statement
- Check browser console for errors
- Verify file size is reasonable (<10MB)
Security Notes
- Application runs entirely on your server
- CSV files are processed in the browser (never sent to server)
- Only stock tickers are sent to backend for price fetching
- No data is stored or logged
Development
Running locally for development
# Terminal 1: Run Go backend
go run main.go
# Terminal 2: Serve static files (or just open index.html)
python3 -m http.server 8000
Then open http://localhost:8080 (backend serves both API and static files)
License
MIT License - Feel free to modify and use as needed.
Support
For issues or questions, check the application logs:
docker-compose logs -f stock-analyzer
Description
Languages
HTML
90.8%
Go
7.7%
Dockerfile
1.4%