Deployment Notes
Environments
| Environment | APP_ENV value | Description |
|---|---|---|
| Local Development | LOCAL | Developer machine with local paths |
| VPS Production | VPS | Remote server deployment |
Environment Variables (Production)
Set the following in the server environment or in a .env file:
APP_ENV=VPS
DATABASE_URL=postgresql://user:password@localhost:5432/tradeentry
VPS_CSV_PATH=/data/tradeentry/csv
VPS_AMI_PATH=/data/tradeentry/ami
Deploying the Backend
# On the VPS:
cd /opt/tradeentry-VPS/backend
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8000
For production, use a process manager such as systemd or Supervisor:
# /etc/systemd/system/tradeentry.service
[Unit]
Description=TradeEntry FastAPI Backend
After=network.target
[Service]
User=www-data
WorkingDirectory=/opt/tradeentry-VPS/backend
ExecStart=/opt/tradeentry-VPS/backend/venv/bin/uvicorn app.main:app --host 0.0.0.0 --port 8000
Restart=always
[Install]
WantedBy=multi-user.target
Deploying the Frontend
cd frontend
npm install
npm run build
# Serve the dist/ folder via nginx
Nginx configuration example:
server {
listen 80;
server_name yourdomain.com;
root /opt/tradeentry-VPS/frontend/dist;
index index.html;
location / {
try_files $uri /index.html;
}
location /api/ {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
Docker Compose
A docker-compose.yml is included in the project root for containerized deployment:
docker-compose up -d
This starts:
postgres— Databasebackend— FastAPI appfrontend— Nginx-served React build
Database Migrations
cd backend
alembic upgrade head
Deploying the Docs
cd docs
npm run build
# Serve docs/build/ via nginx on a subdomain e.g. docs.yourdomain.com
Scheduled Bhav Download (Cron)
To auto-download NSE bhav copies at market close (e.g. 5:30 PM IST / 12:00 UTC):
0 12 * * 1-5 cd /opt/tradeentry-VPS/backend && venv/bin/python -m nseeod.downloadbhav
Last updated: 2026-05-24