refactor: reorganize project structure — consolidate Docker files, clean root

- Delete temp files: _tmp_analysis.py, nul, dashboard_screenshot.png
- Move ea/ to archive/ea/ (deprecated)
- Move 12 Docker helper scripts (.bat/.sh) to docker/scripts/
- Move 5 Docker docs to docker/docs/
- Move .env.docker.example, requirements-docker.txt to docker/
- Update all scripts with cd to project root for correct path resolution
- Update all doc references to new paths
- Update .gitignore with bot.pid, bot_output.log, *.png patterns
- Update CLAUDE.md, README.md directory trees

Root reduced from ~40 files to 12 essential files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
GifariKemal
2026-02-08 14:21:11 +07:00
parent 61877480b3
commit b2dc2dacd7
22 changed files with 110 additions and 68 deletions
+65
View File
@@ -0,0 +1,65 @@
@echo off
REM Add Dashboard & API to existing Docker setup
cd /d "%~dp0..\.."
echo.
echo ========================================
echo Adding Dashboard to Existing Setup
echo ========================================
echo.
REM Check if .env exists
if not exist .env (
echo WARNING: .env file not found!
echo Creating .env from template...
copy docker\.env.docker.example .env
echo.
echo Please edit .env with your MT5 credentials:
echo - MT5_LOGIN
echo - MT5_PASSWORD
echo - MT5_SERVER
echo - MT5_PATH
echo.
pause
)
REM Check if Docker is running
docker info >nul 2>&1
if errorlevel 1 (
echo ERROR: Docker is not running!
echo Please start Docker Desktop and try again.
pause
exit /b 1
)
echo [1/4] Checking existing services...
docker ps --filter "name=trading_bot_db" --format "table {{.Names}}\t{{.Status}}"
echo.
echo [2/4] Building new services API and Dashboard...
docker-compose build trading-api dashboard
echo.
echo [3/4] Starting new services...
docker-compose up -d trading-api dashboard
echo.
echo [4/4] Checking all services...
docker-compose ps
echo.
echo ========================================
echo Dashboard Added Successfully!
echo ========================================
echo.
echo Access Points:
echo Dashboard: http://localhost:3000
echo API: http://localhost:8000
echo API Docs: http://localhost:8000/docs
echo Database: localhost:5432 (already running)
echo.
echo View logs:
echo docker-compose logs -f dashboard
echo docker-compose logs -f trading-api
echo.
pause
+19
View File
@@ -0,0 +1,19 @@
@echo off
REM XAUBot AI - Docker Logs Viewer (Windows)
cd /d "%~dp0..\.."
set SERVICE=%1
set LINES=%2
if "%LINES%"=="" set LINES=100
if "%SERVICE%"=="" (
echo Viewing logs for all services...
echo Tip: Use 'docker-logs.bat SERVICE [LINES]' to view specific service
echo Available: trading-api, dashboard, postgres, pgadmin
echo.
docker-compose logs -f --tail=%LINES%
) else (
echo Viewing logs for: %SERVICE% last %LINES% lines
echo.
docker-compose logs -f --tail=%LINES% %SERVICE%
)
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# XAUBot AI - Docker Logs Viewer
set -e
cd "$(dirname "$0")/../.."
SERVICE="$1"
LINES="${2:-100}"
if [ -z "$SERVICE" ]; then
echo "📋 Viewing logs for all services..."
echo "💡 Tip: Use './docker-logs.sh SERVICE [LINES]' to view specific service"
echo " Available: trading-api, dashboard, postgres, pgadmin"
echo ""
docker-compose logs -f --tail=$LINES
else
echo "📋 Viewing logs for: $SERVICE (last $LINES lines)"
echo ""
docker-compose logs -f --tail=$LINES $SERVICE
fi
@@ -0,0 +1,35 @@
@echo off
REM Remove Dashboard & API while keeping database
cd /d "%~dp0..\.."
echo.
echo ========================================
echo Removing Dashboard & API Services
echo ========================================
echo.
echo This will stop and remove:
echo - trading_bot_dashboard
echo - trading_bot_api
echo.
echo Database (trading_bot_db) will remain running.
echo.
pause
echo Stopping services...
docker-compose stop trading-api dashboard
echo.
echo Removing containers...
docker-compose rm -f trading-api dashboard
echo.
echo ========================================
echo Dashboard Removed!
echo ========================================
echo.
echo Database is still running:
docker ps --filter "name=trading_bot_db" --format "table {{.Names}}\t{{.Status}}"
echo.
echo To add dashboard back: docker\scripts\docker-add-dashboard.bat
echo.
pause
+92
View File
@@ -0,0 +1,92 @@
@echo off
REM XAUBot AI - Docker Start Script (Windows)
cd /d "%~dp0..\.."
echo.
echo Starting XAUBot AI Docker Services...
echo.
REM Check if .env exists
if not exist .env (
echo WARNING: .env file not found!
echo Creating .env from template...
copy docker\.env.docker.example .env
echo.
echo .env created. Please edit it with your MT5 credentials:
echo - MT5_LOGIN
echo - MT5_PASSWORD
echo - MT5_SERVER
echo - MT5_PATH
echo.
pause
)
REM Check if Docker is running
docker info >nul 2>&1
if errorlevel 1 (
echo ERROR: Docker is not running!
echo Please start Docker Desktop and try again.
pause
exit /b 1
)
echo Docker is running
echo.
REM Parse arguments
set PROFILE_FLAG=
if "%1"=="--admin" set PROFILE_FLAG=--profile admin
if "%1"=="-a" set PROFILE_FLAG=--profile admin
if defined PROFILE_FLAG (
echo Starting with pgAdmin admin profile...
) else (
echo Starting core services postgres, api, dashboard...
echo Tip: Use 'docker-start.bat --admin' to include pgAdmin
)
echo.
echo Pulling latest base images...
docker-compose pull
echo.
echo Building services...
docker-compose build
echo.
echo Starting services...
docker-compose %PROFILE_FLAG% up -d
echo.
echo Waiting for services to be healthy...
timeout /t 10 /nobreak >nul
echo.
echo Checking service health...
docker-compose ps
echo.
echo ========================================
echo Services started successfully!
echo ========================================
echo.
echo Access Points:
echo Dashboard: http://localhost:3000
echo API: http://localhost:8000
echo API Docs: http://localhost:8000/docs
echo Database: localhost:5432
if defined PROFILE_FLAG (
echo pgAdmin: http://localhost:5050
)
echo.
echo Useful Commands:
echo View logs: docker-compose logs -f
echo View API logs: docker-compose logs -f trading-api
echo Stop services: docker-compose down
echo Restart: docker-compose restart
echo.
echo Full documentation: docker\docs\DOCKER.md
echo.
pause
+88
View File
@@ -0,0 +1,88 @@
#!/bin/bash
# XAUBot AI - Docker Start Script
set -e
cd "$(dirname "$0")/../.."
echo "🚀 Starting XAUBot AI Docker Services..."
echo ""
# Check if .env exists
if [ ! -f .env ]; then
echo "⚠️ .env file not found!"
echo "📝 Creating .env from template..."
cp docker/.env.docker.example .env
echo "✅ .env created. Please edit it with your MT5 credentials:"
echo " - MT5_LOGIN"
echo " - MT5_PASSWORD"
echo " - MT5_SERVER"
echo " - MT5_PATH"
echo ""
read -p "Press Enter after editing .env to continue..."
fi
# Check if Docker is running
if ! docker info > /dev/null 2>&1; then
echo "❌ Docker is not running!"
echo "Please start Docker Desktop and try again."
exit 1
fi
echo "✅ Docker is running"
echo ""
# Parse command line arguments
PROFILE_FLAG=""
if [ "$1" == "--admin" ] || [ "$1" == "-a" ]; then
PROFILE_FLAG="--profile admin"
echo "📊 Starting with pgAdmin (admin profile)..."
else
echo "📊 Starting core services (postgres, api, dashboard)..."
echo "💡 Use './docker-start.sh --admin' to include pgAdmin"
fi
echo ""
# Pull latest images
echo "📥 Pulling latest base images..."
docker-compose pull
echo ""
echo "🔨 Building services..."
docker-compose build
echo ""
echo "🎯 Starting services..."
docker-compose $PROFILE_FLAG up -d
echo ""
echo "⏳ Waiting for services to be healthy..."
sleep 10
# Check health
echo ""
echo "🏥 Checking service health..."
docker-compose ps
echo ""
echo "✅ Services started successfully!"
echo ""
echo "📍 Access Points:"
echo " Dashboard: http://localhost:3000"
echo " API: http://localhost:8000"
echo " API Docs: http://localhost:8000/docs"
echo " Database: localhost:5432"
if [ "$1" == "--admin" ] || [ "$1" == "-a" ]; then
echo " pgAdmin: http://localhost:5050"
fi
echo ""
echo "📋 Useful Commands:"
echo " View logs: docker-compose logs -f"
echo " View API logs: docker-compose logs -f trading-api"
echo " Stop services: docker-compose down"
echo " Restart: docker-compose restart"
echo ""
echo "📖 Full documentation: docker/docs/DOCKER.md"
echo ""
+56
View File
@@ -0,0 +1,56 @@
@echo off
REM Check status of all trading bot services
cd /d "%~dp0..\.."
echo.
echo ========================================
echo Trading Bot Docker Services Status
echo ========================================
echo.
docker-compose ps
echo.
echo ========================================
echo Service Health Checks
echo ========================================
echo.
echo [Database]
docker exec trading_bot_db pg_isready -U trading_bot 2>nul
if %errorlevel%==0 (
echo Status: HEALTHY
) else (
echo Status: NOT RUNNING
)
echo.
echo [API]
curl -s http://localhost:8000/api/health >nul 2>&1
if %errorlevel%==0 (
echo Status: HEALTHY
echo URL: http://localhost:8000
) else (
echo Status: NOT RUNNING or UNHEALTHY
)
echo.
echo [Dashboard]
curl -s http://localhost:3000 >nul 2>&1
if %errorlevel%==0 (
echo Status: HEALTHY
echo URL: http://localhost:3000
) else (
echo Status: NOT RUNNING or UNHEALTHY
)
echo.
echo ========================================
echo Quick Commands
echo ========================================
echo View logs: docker-compose logs -f
echo Restart: docker-compose restart
echo Stop all: docker-compose stop
echo Start all: docker-compose up -d
echo.
pause
+45
View File
@@ -0,0 +1,45 @@
@echo off
REM XAUBot AI - Docker Stop Script (Windows)
cd /d "%~dp0..\.."
echo.
echo Stopping XAUBot AI Docker Services...
echo.
if "%1"=="--remove" goto remove
if "%1"=="-r" goto remove
if "%1"=="--clean" goto clean
if "%1"=="-c" goto clean
goto stop
:remove
echo Stopping and removing containers...
docker-compose down
echo.
echo Containers stopped and removed
goto end
:clean
echo WARNING: This will remove all data including database!
set /p confirm="Are you sure? (yes/no): "
if /i "%confirm%"=="yes" (
docker-compose down -v
echo.
echo Containers, networks, and volumes removed
) else (
echo.
echo Cancelled
)
goto end
:stop
echo Stopping containers data will be preserved...
docker-compose stop
echo.
echo Containers stopped
:end
echo.
echo To restart: docker\scripts\docker-start.bat
echo.
pause
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
# XAUBot AI - Docker Stop Script
set -e
cd "$(dirname "$0")/../.."
echo "🛑 Stopping XAUBot AI Docker Services..."
echo ""
# Parse arguments
if [ "$1" == "--remove" ] || [ "$1" == "-r" ]; then
echo "⚠️ Stopping and removing containers..."
docker-compose down
echo "✅ Containers stopped and removed"
elif [ "$1" == "--clean" ] || [ "$1" == "-c" ]; then
echo "⚠️ WARNING: This will remove all data including database!"
read -p "Are you sure? (yes/no): " confirm
if [ "$confirm" == "yes" ]; then
docker-compose down -v
echo "✅ Containers, networks, and volumes removed"
else
echo "❌ Cancelled"
fi
else
echo "🔄 Stopping containers (data will be preserved)..."
docker-compose stop
echo "✅ Containers stopped"
fi
echo ""
echo "📋 To restart: ./docker/scripts/docker-start.sh"
echo ""
+52
View File
@@ -0,0 +1,52 @@
@echo off
REM Start API and Dashboard in separate windows
echo.
echo ========================================
echo XAUBot AI - Starting All Services
echo ========================================
echo.
cd /d "%~dp0..\.."
REM Check database
echo [1/3] Checking database...
docker ps --filter "name=trading_bot_db" --format "{{.Names}}: {{.Status}}" 2>nul
if errorlevel 1 (
echo.
echo WARNING: Database not running!
echo Please start with: docker-compose up -d postgres
echo.
pause
exit /b 1
)
echo.
echo [2/3] Starting API...
start "Trading API" cmd /k docker\scripts\start-api.bat
echo Waiting for API to start...
timeout /t 5 /nobreak >nul
echo.
echo [3/3] Starting Dashboard...
start "Web Dashboard" cmd /k docker\scripts\start-dashboard.bat
echo.
echo ========================================
echo All Services Started!
echo ========================================
echo.
echo Access Points:
echo - Dashboard: http://localhost:3000
echo - API: http://localhost:8000
echo - API Docs: http://localhost:8000/docs
echo - Database: localhost:5432
echo.
echo Two windows will open:
echo 1. Trading API (FastAPI)
echo 2. Web Dashboard (Next.js)
echo.
echo Close this window when done.
echo.
pause
+35
View File
@@ -0,0 +1,35 @@
@echo off
REM Start Trading API (FastAPI)
echo.
echo ========================================
echo Starting Trading API
echo ========================================
echo.
cd /d "%~dp0..\.."
REM Check if virtual environment exists
if not exist "venv" (
echo Creating virtual environment...
python -m venv venv
echo.
)
REM Activate virtual environment
call venv\Scripts\activate.bat
REM Install/update dependencies
echo Installing dependencies...
pip install -q fastapi uvicorn pydantic python-dotenv aiohttp
echo.
echo ========================================
echo API Starting on http://localhost:8000
echo ========================================
echo.
echo Press Ctrl+C to stop
echo.
REM Start the API
python web-dashboard\api\main.py
+28
View File
@@ -0,0 +1,28 @@
@echo off
REM Start Next.js Dashboard
echo.
echo ========================================
echo Starting Web Dashboard
echo ========================================
echo.
cd /d "%~dp0..\..\web-dashboard"
REM Check if node_modules exists
if not exist "node_modules" (
echo Installing dependencies...
npm install
echo.
)
echo.
echo ========================================
echo Dashboard Starting on http://localhost:3000
echo ========================================
echo.
echo Press Ctrl+C to stop
echo.
REM Start dashboard
npm run dev