Skip to main content

Development Setup

This guide covers setting up the TradeEntry project locally for development.


Prerequisites

ToolVersionDownload
Python3.11+python.org
Node.js18+nodejs.org
PostgreSQL14+postgresql.org
GitAnygit-scm.com
VS CodeLatestcode.visualstudio.com

Clone the Repository

git clone <repository-url>
cd tradeentry-VPS

Backend Setup

cd backend
python -m venv venv

# Windows
venv\Scripts\activate

# Linux / macOS
source venv/bin/activate

pip install -r requirements.txt

Environment Variables

Create backend/.env:

DATABASE_URL=postgresql://user:password@localhost:5432/tradeentry
CSV_PATH=C:/path/to/csv/storage
AMI_PATH=C:/path/to/ami/output
APP_ENV=LOCAL

Frontend Setup

cd frontend
npm install

Docs Setup

cd docs
npm install

Database Migrations

cd backend
alembic upgrade head

VS Code is the recommended editor for this project. It is configured to launch all three services — Backend, Frontend, and Docs — directly from the editor with dedicated terminal tabs for each.

Open VS Code, then press Ctrl + Shift + P and run:

Extensions: Show Recommended Extensions

Install all suggested extensions. Key ones for this project:

ExtensionPurpose
Python (Microsoft)FastAPI backend development
PylancePython type checking and IntelliSense
ES7+ React/ReduxReact snippets and IntelliSense
TypeScript (built-in)Frontend type checking
Tailwind CSS IntelliSenseAutocomplete for Tailwind classes
PrettierCode formatting
GitLensEnhanced Git history and blame
Thunder ClientTest API endpoints inside VS Code

Step 2 — Open the Project

Always open the project root — not a subfolder:

File → Open Folder → select tradeentry-VPS/
Important

Do not open backend/, frontend/, or docs/ individually. Always open the root tradeentry-VPS/ folder so VS Code picks up the .vscode/tasks.json configuration correctly.

Step 3 — Configure Python Interpreter

  1. Press Ctrl + Shift + P
  2. Type: Python: Select Interpreter
  3. Choose the venv interpreter:
.\backend\venv\Scripts\python.exe (Windows)
./backend/venv/bin/python (Linux / macOS)

This ensures Pylance and the debugger use the correct environment.


Running the Project from VS Code

All three services start with a single keyboard shortcut.

Start All Services

Ctrl + Shift + B

This runs the Start All - TradeEntry compound task which opens three dedicated terminal tabs simultaneously:

TERMINAL
┌─────────────┬──────────────┬──────────────┐
│ Backend │ Frontend │ Docs │
│ │ │ │
│ Uvicorn │ VITE ready │ Building... │
│ :8000 ✓ │ :5173 ✓ │ then :3000 ✓ │
└─────────────┴──────────────┴──────────────┘
Terminal TabServiceURL
BackendFastAPI + Uvicornhttp://localhost:8000
FrontendReact + Vitehttp://localhost:5173
DocsDocusaurus (build + serve)http://localhost:3000
Docs take ~15 seconds

The Docs tab runs npm run build first to generate the search index, then starts the server. Wait for "Serving build directory" to appear in the Docs terminal before opening http://localhost:3000.

Search is fully available once the build completes.

Run a Single Service

To start only one service (e.g. to restart just the backend):

Ctrl + Shift + P → type: Run Task → select the service

Available individual tasks:

Task NameWhat it starts
Backend - FastAPIUvicorn dev server on :8000
Frontend - ViteVite dev server on :5173
Docs - DocusaurusDocusaurus build + serve on :3000
Start All - TradeEntryAll three in parallel

Stop All Services

Ctrl + Shift + P → Terminal: Kill All Terminals

Or click the trash icon on each terminal tab to stop services individually.


Running Without VS Code

If you prefer terminals directly, use the provided scripts from the project root:

Windows — BAT file (opens 3 separate CMD windows)

.\start-dev.bat

To stop:

.\stop-dev.bat

Any platform — Node script (mixed output in one terminal)

npm run dev:all

Service URLs Quick Reference

ServiceURLNotes
Backend APIhttp://localhost:8000FastAPI
Swagger UIhttp://localhost:8000/docsInteractive API docs
ReDochttp://localhost:8000/redocAlternative API docs
Frontendhttp://localhost:5173React app
Docshttp://localhost:3000Docusaurus (search enabled)

NSE Data Sync (standalone)

Always run from backend/ using the module flag:

cd backend
python -m nseeod.downloadbhav
Never run this way
python nseeod\downloadbhav.py # Wrong — breaks module imports

See Architecture for system design details.