diff --git a/PROXMOX_DEPLOYMENT.md b/PROXMOX_DEPLOYMENT.md index de308c8..1e27d82 100644 --- a/PROXMOX_DEPLOYMENT.md +++ b/PROXMOX_DEPLOYMENT.md @@ -171,7 +171,7 @@ RATE_LIMIT_WINDOW=15 RATE_LIMIT_MAX=100 # Python Service (if using) -PYTHON_SERVICE_URL=http://localhost:8000 +PYTHON_SERVICE_URL=http://localhost:8010 ``` ### 4.3 Python Service Setup @@ -333,7 +333,7 @@ Type=simple User=root WorkingDirectory=/opt/institutional_trader/backend/python_service Environment="PATH=/opt/institutional_trader/backend/python_service/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" -ExecStart=/opt/institutional_trader/backend/python_service/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8000 +ExecStart=/opt/institutional_trader/backend/python_service/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8010 Restart=always RestartSec=10 StandardOutput=journal @@ -732,7 +732,7 @@ sudo journalctl -u institutional-trader-python -n 50 # Test manually cd /opt/institutional_trader/backend/python_service source venv/bin/activate -uvicorn main:app --host 0.0.0.0 --port 8000 +uvicorn main:app --host 0.0.0.0 --port 8010 ``` ### Nginx Errors diff --git a/backend/HYBRID_SETUP.md b/backend/HYBRID_SETUP.md index b5a7cd9..5904132 100644 --- a/backend/HYBRID_SETUP.md +++ b/backend/HYBRID_SETUP.md @@ -61,13 +61,13 @@ cp .env.example .env ```bash # Development mode (with auto-reload) cd backend/python_service -uvicorn main:app --reload --port 8000 +uvicorn main:app --reload --port 8010 # Or use the Python script python main.py ``` -The service will be available at `http://localhost:8000` +The service will be available at `http://localhost:8010` ### 3. Node.js Backend Setup @@ -78,7 +78,7 @@ npm install # Configure environment # Add to your .env file: -PYTHON_SERVICE_URL=http://localhost:8000 +PYTHON_SERVICE_URL=http://localhost:8010 USE_PYTHON_SERVICE=true # Set to 'false' to disable Python service ``` @@ -110,7 +110,7 @@ LOCAL_DB_NAME=institutional_trader **Node.js Backend (.env in `backend/`):** ```env # Python Service Configuration -PYTHON_SERVICE_URL=http://localhost:8000 +PYTHON_SERVICE_URL=http://localhost:8010 USE_PYTHON_SERVICE=true # Enable/disable Python service # Existing database configuration... @@ -154,10 +154,10 @@ If Python service is unavailable or disabled: ```bash # Health check -curl http://localhost:8000/health +curl http://localhost:8010/health # Get options flow -curl "http://localhost:8000/api/options-flow?start_date=2024-01-01&end_date=2024-01-02" +curl "http://localhost:8010/api/options-flow?start_date=2024-01-01&end_date=2024-01-02" ``` ### Test Node.js Integration @@ -186,12 +186,12 @@ curl "http://localhost:3010/api/options/flow?startDate=2024-01-01&endDate=2024-0 1. Check database credentials in `.env` 2. Verify PostgreSQL is running -3. Check port 8000 is not in use +3. Check port 8010 is not in use 4. Review Python service logs ### Node.js Can't Connect to Python Service -1. Verify Python service is running: `curl http://localhost:8000/health` +1. Verify Python service is running: `curl http://localhost:8010/health` 2. Check `PYTHON_SERVICE_URL` in Node.js `.env` 3. Check firewall/network settings 4. Node.js will automatically fallback to SQL if Python unavailable diff --git a/backend/INTEGRATION_COMPLETE.md b/backend/INTEGRATION_COMPLETE.md index 8af9fb6..0b8cace 100644 --- a/backend/INTEGRATION_COMPLETE.md +++ b/backend/INTEGRATION_COMPLETE.md @@ -18,7 +18,7 @@ The hybrid Node.js + Python architecture is now fully integrated and ready for p │ HTTP │ (with fallback) ┌──────▼──────────┐ -│ Python Service │ ← FastAPI service (port 8000) +│ Python Service │ ← FastAPI service (port 8010) │ (FastAPI) │ - Data processing │ │ - Complex analytics └──────┬──────────┘ @@ -61,7 +61,7 @@ The hybrid Node.js + Python architecture is now fully integrated and ready for p ```bash cd backend/python_service pip install -r requirements.txt -uvicorn main:app --reload --port 8000 +uvicorn main:app --reload --port 8010 ``` ### 2. Start Node.js Backend @@ -89,7 +89,7 @@ curl "http://localhost:3010/api/options/flow?startDate=2024-01-01&endDate=2024-0 **Node.js (.env in `backend/`):** ```env # Python Service Configuration -PYTHON_SERVICE_URL=http://localhost:8000 +PYTHON_SERVICE_URL=http://localhost:8010 USE_PYTHON_SERVICE=true # Set to 'false' to disable # Database (existing) @@ -178,7 +178,7 @@ Periodic health checks log status: 1. **Test with Python service:** ```bash # Start Python service - cd backend/python_service && uvicorn main:app --port 8000 + cd backend/python_service && uvicorn main:app --port 8010 # Test endpoint curl "http://localhost:3010/api/options/flow" @@ -232,7 +232,7 @@ WORKDIR /app COPY requirements.txt . RUN pip install -r requirements.txt COPY . . -CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8010"] ``` ```dockerfile @@ -249,7 +249,7 @@ CMD ["npm", "start"] ### Python Service Not Starting 1. Check database credentials -2. Verify port 8000 is available +2. Verify port 8010 is available 3. Check Python dependencies 4. Review service logs diff --git a/backend/QUICK_START.md b/backend/QUICK_START.md index 7c11afd..5c0c4e2 100644 --- a/backend/QUICK_START.md +++ b/backend/QUICK_START.md @@ -47,7 +47,7 @@ LOCAL_DB_NAME=institutional_trader ### Node.js Backend Add to `backend/.env`: ```env -PYTHON_SERVICE_URL=http://localhost:8000 +PYTHON_SERVICE_URL=http://localhost:8010 USE_PYTHON_SERVICE=true # Your existing database config... @@ -59,12 +59,12 @@ USE_PYTHON_SERVICE=true ```bash cd backend/python_service source venv/bin/activate # or venv\Scripts\activate on Windows -uvicorn main:app --reload --port 8000 +uvicorn main:app --reload --port 8010 ``` You should see: ``` -INFO: Uvicorn running on http://0.0.0.0:8000 +INFO: Uvicorn running on http://0.0.0.0:8010 INFO: Application startup complete. ``` @@ -126,13 +126,13 @@ Check Node.js logs - you should see: ### Python Service Won't Start - Check database credentials in `.env` - Verify PostgreSQL is running -- Check port 8000 is available +- Check port 8010 is available - Review Python service logs ### Node.js Can't Connect - Verify `PYTHON_SERVICE_URL` in `.env` - Check Python service is running -- Test: `curl http://localhost:8000/health` +- Test: `curl http://localhost:8010/health` ### No Data Returned - Check database has data diff --git a/backend/TROUBLESHOOTING_SQL.md b/backend/TROUBLESHOOTING_SQL.md index 8421e7c..97f25e0 100644 --- a/backend/TROUBLESHOOTING_SQL.md +++ b/backend/TROUBLESHOOTING_SQL.md @@ -29,7 +29,7 @@ - Log the fallback for monitoring **To fix:** -1. Start Python service: `cd backend/python_service && uvicorn main:app --port 8000` +1. Start Python service: `cd backend/python_service && uvicorn main:app --port 8010` 2. Check `PYTHON_SERVICE_URL` in `.env` matches the service URL 3. Verify network connectivity diff --git a/backend/python_service/README.md b/backend/python_service/README.md index 74112ca..5445783 100644 --- a/backend/python_service/README.md +++ b/backend/python_service/README.md @@ -27,7 +27,7 @@ cp .env.example .env ```bash python main.py # Or with uvicorn: -uvicorn main:app --reload --port 8000 +uvicorn main:app --reload --port 8010 ``` ## API Endpoints @@ -46,7 +46,7 @@ Get processed options flow data **Example:** ```bash -curl http://localhost:8000/api/options-flow?start_date=2024-01-01&end_date=2024-01-02 +curl http://localhost:8010/api/options-flow?start_date=2024-01-01&end_date=2024-01-02 ``` ### GET /api/options-flow/stats @@ -60,7 +60,7 @@ Get flow statistics The Node.js API layer can call this service via HTTP: ```javascript -const response = await fetch('http://localhost:8000/api/options-flow?start_date=2024-01-01'); +const response = await fetch('http://localhost:8010/api/options-flow?start_date=2024-01-01'); const data = await response.json(); ``` diff --git a/backend/python_service/START_SERVICE.md b/backend/python_service/START_SERVICE.md index 7574f60..132a206 100644 --- a/backend/python_service/START_SERVICE.md +++ b/backend/python_service/START_SERVICE.md @@ -4,7 +4,7 @@ ```bash cd backend/python_service -uvicorn main:app --reload --port 8000 +uvicorn main:app --reload --port 8010 ``` ## Using Virtual Environment (Recommended) @@ -26,20 +26,20 @@ source venv/bin/activate pip install -r requirements.txt # Start service -uvicorn main:app --reload --port 8000 +uvicorn main:app --reload --port 8010 ``` ## Verify Service is Running Once started, you should see: ``` -INFO: Uvicorn running on http://127.0.0.1:8000 +INFO: Uvicorn running on http://127.0.0.1:8010 INFO: Application startup complete. ``` Test the health endpoint: ```bash -curl http://localhost:8000/health +curl http://localhost:8010/health ``` Expected response: diff --git a/backend/python_service/TESTING.md b/backend/python_service/TESTING.md index 6bb2722..dbd576a 100644 --- a/backend/python_service/TESTING.md +++ b/backend/python_service/TESTING.md @@ -28,10 +28,10 @@ Start the service and test the endpoint: ```bash # Terminal 1: Start Python service cd backend/python_service -uvicorn main:app --reload --port 8000 +uvicorn main:app --reload --port 8010 # Terminal 2: Test endpoint -curl "http://localhost:8000/api/options-flow?start_date=2024-01-01&end_date=2024-01-02" +curl "http://localhost:8010/api/options-flow?start_date=2024-01-01&end_date=2024-01-02" ``` ### 3. Integration Test with Node.js @@ -41,7 +41,7 @@ Test the full stack: ```bash # Terminal 1: Start Python service cd backend/python_service -uvicorn main:app --reload --port 8000 +uvicorn main:app --reload --port 8010 # Terminal 2: Start Node.js backend cd backend diff --git a/backend/python_service/main.py b/backend/python_service/main.py index ee08f16..6688860 100644 --- a/backend/python_service/main.py +++ b/backend/python_service/main.py @@ -306,5 +306,5 @@ async def get_flow_stats( if __name__ == "__main__": import uvicorn - uvicorn.run(app, host="0.0.0.0", port=8000) + uvicorn.run(app, host="0.0.0.0", port=8010) diff --git a/backend/python_service/start.bat b/backend/python_service/start.bat index e9832dd..c22411d 100644 --- a/backend/python_service/start.bat +++ b/backend/python_service/start.bat @@ -7,5 +7,5 @@ if exist venv\Scripts\activate.bat ( ) REM Start the service -uvicorn main:app --host 0.0.0.0 --port 8000 --reload +uvicorn main:app --host 0.0.0.0 --port 8010 --reload diff --git a/backend/python_service/start.sh b/backend/python_service/start.sh index 40423f1..4d990dc 100644 --- a/backend/python_service/start.sh +++ b/backend/python_service/start.sh @@ -7,5 +7,5 @@ if [ -d "venv" ]; then fi # Start the service -uvicorn main:app --host 0.0.0.0 --port 8000 --reload +uvicorn main:app --host 0.0.0.0 --port 8010 --reload diff --git a/backend/src/routes/health.js b/backend/src/routes/health.js index 9035a42..ddff301 100644 --- a/backend/src/routes/health.js +++ b/backend/src/routes/health.js @@ -54,7 +54,7 @@ router.get('/', async (req, res) => { available: isHealthy, lastCheck: lastCheck?.timestamp || null, status: lastCheck?.healthy ? 'healthy' : 'unhealthy', - url: process.env.PYTHON_SERVICE_URL || 'http://localhost:8000' + url: process.env.PYTHON_SERVICE_URL || 'http://localhost:8010' }; if (!isHealthy) { diff --git a/backend/src/services/pythonServiceClient.js b/backend/src/services/pythonServiceClient.js index 335aee3..6935f5c 100644 --- a/backend/src/services/pythonServiceClient.js +++ b/backend/src/services/pythonServiceClient.js @@ -18,7 +18,7 @@ if (typeof globalThis.fetch !== 'undefined') { } } -const PYTHON_SERVICE_URL = process.env.PYTHON_SERVICE_URL || 'http://localhost:8000'; +const PYTHON_SERVICE_URL = process.env.PYTHON_SERVICE_URL || 'http://localhost:8010'; /** * Call Python service for options flow processing