https://github.com/joshbaneycs/stock-tracker
My first attempt at making a Dockerized stock platform with Golang backend and ReackJS frontend
https://github.com/joshbaneycs/stock-tracker
Last synced: 11 months ago
JSON representation
My first attempt at making a Dockerized stock platform with Golang backend and ReackJS frontend
- Host: GitHub
- URL: https://github.com/joshbaneycs/stock-tracker
- Owner: JoshBaneyCS
- Created: 2025-07-11T13:27:49.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-07-11T14:36:42.000Z (12 months ago)
- Last Synced: 2025-07-11T15:49:44.592Z (12 months ago)
- Language: Go
- Size: 66.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# π Stock Tracker
A full-stack, real-time stock tracking and alerting web application built with **React**, **Go**, **Python**, and **MySQL** β fully containerized with **Docker**. Users can register, select up to 50 stocks, view live graphing and history, set alerts, and customize their settings.
---
## π Project Directory Structure
stock-tracker/
βββ backend/
β βββ main.go
β βββ handlers/
β βββ models/
β βββ middleware/
β βββ utils/
β βββ stock_fetcher.py
β βββ requirements.txt
β βββ go.mod
β
βββ frontend/
β βββ public/
β βββ src/
β β βββ pages/
β β βββ components/
β β βββ index.js
β βββ Dockerfile
β βββ package.json
β
βββ db/
β βββ schema.sql
βββ .env
βββ docker-compose.yml
βββ README.md
---
π§ Backend Stack
- **Language:** Go (Golang)
- **Framework:** `gin-gonic`
- **Authentication:** JWT (stored in client storage)
- **Email Alerts:** SMTP via `net/smtp`
- **Data Fetching:** Calls a Python script (`stock_fetcher.py`) using `os/exec`
- **Python Dependencies:** `yfinance`, `pandas`, `numpy`
- **Database:** MySQL 8.x via GORM ORM
π¨ Frontend Stack
- **Library:** React (with React Router v6)
- **Graphing:** Chart.js via `react-chartjs-2`
- **API:** Axios for HTTP requests
- **Styling:** CSS modules + responsive layout
- **Background:** [particles.js](https://vincentgarreau.com/particles.js/)
- **Session:** JWT stored in `localStorage`
βοΈ Technology Stack
- **Frontend:** React + Chart.js
- **Backend:** Go + Python
- **Database:** MySQL
- **Containerization:** Docker
- **Email + Alerts:** SMTP
- **Currency Conversion:** exchangerate.host
- **Reverse Proxy (optional):** Nginx
---
## π οΈ Installation Guide
### Prerequisites
- [Docker](https://www.docker.com/products/docker-desktop)
- [Docker Compose](https://docs.docker.com/compose/)
- (Optional) Python installed locally for testing `stock_fetcher.py`
---
### 1. Clone the Repository
```bash
git clone https://github.com/JoshBaneyCS/stock-tracker.git
cd stock-tracker
```
### 2. Setup Environment Variables
Create a .env file in the project root:
```.env
PORT=8080
DB_HOST=db
DB_PORT=3306
DB_USER=root
DB_PASS=password
DB_NAME=stocktracker
JWT_SECRET=supersecretjwtkey
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_email_password
```
### 3. Build and Run!
```bash
docker-compose up --build
```
This will:
Build and run the Go backend + Python inside 1 container
Serve the React frontend via Nginx on port 3000
Set up a MySQL database and schema
### 4. Open in Browser
Frontend: http://localhost:3000 (Or whatever you have your port mapped to)
Backend API: http://localhost:8080 (Or whatever you have your port mapped to)
## π Default Routes
Method Endpoint Description
POST /register Register a new user
POST /login Login and get JWT
GET /api/favorites Get userβs saved stocks
POST /api/favorites Save userβs selected stocks
GET /api/stocks Fetch live stock data
GET /api/settings Get user profile/settings
POST /api/settings Update name, email, etc.
POST /api/alerts Create price alert
GET /api/alerts View all alerts
DELETE /api/alerts/:id Delete alert
JWT must be sent as a Bearer token in Authorization headers for protected endpoints.
## π§ Features
- β
User authentication (JWT-based login/register)
- β
Select up to 50 favorite stocks
- β
Market index toggle support (e.g., S&P 500)
- β
Real-time stock graphing (using Chart.js)
- β
Custom color-coded lines per stock
- β
Search bar to quickly find stocks
- β
Historical data box (market cap, high/low, etc.)
- β
Auto-refresh every 5 minutes
- β
Email alerts when price reaches or falls below threshold
- β
Currency conversion via exchangerate.host
- β
Customizable account settings (name, email, password, currency)
- β
IP address is logged on login and registration
- β
Dockerized with flexible port management via `.env`
- β
Front page includes `particles.js` animated background and logo
## π Security Notes
- Passwords are hashed securely using **bcrypt**
- JWTs are used for stateless authentication
- Frontend stores JWT in `localStorage`
- CSRF is avoided by using token-only auth
- SMTP email alerts use secure environment variables
## π§ͺ Development Notes
To test the Python stock data script locally:
```bash
cd backend
pip install -r requirements.txt
python3 stock_fetcher.py AAPL TSLA
```
This will return a JSON response for the given stock tickers.
## π License
This project is licensed under the MIT License. You may use, modify, and distribute it freely, with proper attribution.