Bull Bear is a stock intelligence app with:
- A Next.js frontend at port
3000 - A Python Flask prediction backend at port
5001 - A TensorFlow/Keras
.h5model for stock prediction
This guide is a full, step-by-step install and runbook with verification checks after each major step.
Install these first:
- Node.js
20+ - npm
10+ - Python
3.13.x(recommended for this backend venv) gitcurl
Verify:
node -v
npm -v
python3 --version
git --version
curl --versionExpected:
- All commands return versions
- No command should fail with
not found
git clone <your-repo-url>
cd bull-bearVerify folder structure:
lsExpected entries include:
appbackendpackage.json
Create a root .env file (same folder as package.json) and set your required keys.
Minimum keys used in code:
MONGODB_URIFINNHUB_API_KEY(orNEXT_PUBLIC_FINNHUB_API_KEY)- Clerk keys (for auth)
- Optional:
PYTHON_API_BASE_URL(defaults tohttp://127.0.0.1:5001) - Optional mail/news keys if you use those flows:
NODEMAILER_EMAIL,NODEMAILER_KEY,GEMINI_API_KEY
Quick check (no secret values printed):
grep -E '^(MONGODB_URI|FINNHUB_API_KEY|NEXT_PUBLIC_FINNHUB_API_KEY|PYTHON_API_BASE_URL|NODEMAILER_EMAIL|NODEMAILER_KEY|GEMINI_API_KEY|CLERK_)=' .envExpected:
- Required keys appear as lines
From project root:
npm installVerify:
npm ls --depth=0 > /tmp/bull-bear-npm-check.txt && tail -n 20 /tmp/bull-bear-npm-check.txtExpected:
- Command completes without install errors
- Top-level dependencies are listed
From project root:
cd backend
python3 -m venv venvVerify interpreter exists:
./venv/bin/python --versionExpected:
- A Python version is printed
From backend folder:
./venv/bin/python -m pip install --upgrade pip
./venv/bin/python -m pip install -r requirements.txt
./venv/bin/python -m pip install tf_kerasWhy tf_keras:
- Your legacy
.h5model uses settings that require TensorFlow legacy Keras compatibility.
Verify imports:
./venv/bin/python - <<'PY'
import flask
import numpy
import pandas
import tensorflow
import tf_keras
import yfinance
print('backend imports: OK')
PYExpected:
- Output prints
backend imports: OK
From project root, run with explicit paths to avoid cwd mistakes:
./backend/venv/bin/python ./backend/app.pyExpected log:
Running on http://127.0.0.1:5001
Keep this terminal running.
curl -sS -m 15 -w '\nHTTP_STATUS:%{http_code}\n' http://127.0.0.1:5001/api/healthExpected:
- JSON body:
{"status":"ok"} - HTTP status:
200
curl -sS -m 60 -X POST http://127.0.0.1:5001/api/predict \
-H 'Content-Type: application/json' \
-d '{"symbol":"AAPL","includeCharts":false}' \
-w '\nHTTP_STATUS:%{http_code}\n'Expected:
- JSON with
"status":"success" data.predictedPrice,data.currentPrice,data.changePercent- HTTP status:
200
From project root:
npm run devExpected log:
Local: http://localhost:3000
Keep this terminal running.
In another terminal:
curl -sS -m 90 -X POST http://127.0.0.1:3000/api/prediction \
-H 'Content-Type: application/json' \
-d '{"symbol":"AAPL","includeCharts":false}' \
-w '\nHTTP_STATUS:%{http_code}\n'Expected:
- JSON with
"status":"success" - Same prediction structure as backend API
- HTTP status:
200
- Open
http://localhost:3000 - Sign in
- Open
http://localhost:3000/prediction - Enter symbol (example
AAPL) - Click
Predict
Expected:
- Predicted next close card appears
- Current price and change metrics appear
- Optional charts appear when requested
You already have:
backend/scripts/verify_prediction.sh
Run backend-only checks:
chmod +x backend/scripts/verify_prediction.sh
./backend/scripts/verify_prediction.shRun backend + Next proxy checks:
./backend/scripts/verify_prediction.sh --nextExpected:
- Step logs
[1/6] ... [6/6] All checks passed.
-
ModuleNotFoundErrorwhen running backend: Use backend venv interpreter only:./backend/venv/bin/python ./backend/app.py -
Port
5000returnsAirTunes/403: This project uses port5001by default to avoid macOS conflict. -
Next.js API cannot reach Python: Ensure backend is running and
PYTHON_API_BASE_URLpoints tohttp://127.0.0.1:5001(or leave unset for default). -
Auth pages not working: Verify Clerk env keys are present and valid.
-
Prediction endpoint slow first time: First model inference can take longer due model load/warm-up.
- Flask in this repo runs as a development server.
- For production, run behind Gunicorn/Uvicorn workers and proper reverse proxy.
- Keep secrets only in environment variables, never commit
.env.