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
co-authored by Claude Opus 4.6
parent 61877480b3
commit b2dc2dacd7
22 changed files with 110 additions and 68 deletions
+6 -1
View File
@@ -82,5 +82,10 @@ docker/data/
# Archive # Archive
archive/ archive/
# Junk # Runtime files
bot.pid
bot_output.log
nul nul
# Screenshots
*.png
+9
View File
@@ -10,6 +10,9 @@ XAUBot AI is an automated XAUUSD (Gold) trading bot that combines Machine Learni
. .
├── main_live.py # Main async trading orchestrator ├── main_live.py # Main async trading orchestrator
├── train_models.py # Model training script ├── train_models.py # Model training script
├── Dockerfile # Docker image (must be at root)
├── docker-compose.yml # Docker orchestration (must be at root)
├── .dockerignore # Docker build exclusions (must be at root)
├── src/ # Core modules ├── src/ # Core modules
│ ├── config.py # Trading configuration & capital modes │ ├── config.py # Trading configuration & capital modes
│ ├── mt5_connector.py # MetaTrader 5 connection layer │ ├── mt5_connector.py # MetaTrader 5 connection layer
@@ -49,6 +52,12 @@ XAUBot AI is an automated XAUUSD (Gold) trading bot that combines Machine Learni
│ └── research/ # Research & analysis files │ └── research/ # Research & analysis files
├── web-dashboard/ # Next.js monitoring dashboard ├── web-dashboard/ # Next.js monitoring dashboard
├── docker/ # Docker configuration ├── docker/ # Docker configuration
│ ├── .env.docker.example # Docker environment template
│ ├── requirements-docker.txt # Docker-specific Python deps
│ ├── init-db/ # Database init scripts
│ ├── scripts/ # Docker helper scripts (.bat/.sh)
│ └── docs/ # Docker documentation
├── archive/ # Deprecated files (gitignored)
└── logs/ # Runtime logs └── logs/ # Runtime logs
``` ```
+8 -5
View File
@@ -103,7 +103,10 @@ xaubot-ai/
│ ├── arsitektur-ai/ # Architecture docs (23 components) │ ├── arsitektur-ai/ # Architecture docs (23 components)
│ └── research/ # Research & analysis │ └── research/ # Research & analysis
├── web-dashboard/ # Next.js monitoring dashboard ├── web-dashboard/ # Next.js monitoring dashboard
── docker/ # Docker configuration ── docker/ # Docker configuration & scripts
│ ├── scripts/ # Helper scripts (.bat/.sh)
│ └── docs/ # Docker documentation
└── archive/ # Deprecated files (gitignored)
``` ```
## Backtest Results (Jan 2025 - Feb 2026) ## Backtest Results (Jan 2025 - Feb 2026)
@@ -129,14 +132,14 @@ git clone https://github.com/GifariKemal/xaubot-ai.git
cd xaubot-ai cd xaubot-ai
# 2. Configure environment # 2. Configure environment
cp .env.docker.example .env cp docker/.env.docker.example .env
# Edit .env with your MT5 credentials # Edit .env with your MT5 credentials
# 3. Start all services (Windows) # 3. Start all services (Windows)
docker-start.bat docker\scripts\docker-start.bat
# 3. Start all services (Linux/Mac) # 3. Start all services (Linux/Mac)
./docker-start.sh ./docker/scripts/docker-start.sh
``` ```
**Services will be available at:** **Services will be available at:**
@@ -145,7 +148,7 @@ docker-start.bat
- 📚 API Docs: http://localhost:8000/docs - 📚 API Docs: http://localhost:8000/docs
- 🗄️ Database: localhost:5432 - 🗄️ Database: localhost:5432
**Full Docker documentation:** See [DOCKER.md](DOCKER.md) **Full Docker documentation:** See [docker/docs/DOCKER.md](docker/docs/DOCKER.md)
--- ---
@@ -25,7 +25,7 @@ Layanan baru yang ditambahkan:
```cmd ```cmd
# Tambahkan dashboard ke setup yang sudah ada # Tambahkan dashboard ke setup yang sudah ada
docker-add-dashboard.bat docker\scripts\docker-add-dashboard.bat
``` ```
Script ini akan: Script ini akan:
@@ -57,7 +57,7 @@ Setelah services running:
### Check Status ### Check Status
```cmd ```cmd
# Lihat status semua services # Lihat status semua services
docker-status.bat docker\scripts\docker-status.bat
# Atau manual # Atau manual
docker-compose ps docker-compose ps
@@ -90,7 +90,7 @@ docker-compose restart
### Remove Dashboard (Keep Database) ### Remove Dashboard (Keep Database)
```cmd ```cmd
# Hapus dashboard tapi tetap keep database # Hapus dashboard tapi tetap keep database
docker-remove-dashboard.bat docker\scripts\docker-remove-dashboard.bat
# Atau manual # Atau manual
docker-compose stop trading-api dashboard docker-compose stop trading-api dashboard
@@ -230,12 +230,16 @@ xaubot-ai/
├── Dockerfile # API image (NEW) ├── Dockerfile # API image (NEW)
├── .env # Environment config ├── .env # Environment config
├── .dockerignore # Build exclusions ├── .dockerignore # Build exclusions
├── docker-add-dashboard.bat # Add dashboard script (NEW)
├── docker-remove-dashboard.bat # Remove dashboard script (NEW)
├── docker-status.bat # Status check script (NEW)
├── docker/ ├── docker/
── init-db/ ── .env.docker.example # Environment template
└── 01-schema.sql # Database schema (EXISTING) ├── requirements-docker.txt # Docker-specific deps
│ ├── init-db/
│ │ └── 01-schema.sql # Database schema (EXISTING)
│ ├── scripts/ # Helper scripts
│ │ ├── docker-add-dashboard.bat
│ │ ├── docker-remove-dashboard.bat
│ │ └── docker-status.bat
│ └── docs/ # Docker documentation
└── web-dashboard/ └── web-dashboard/
├── Dockerfile # Dashboard image (NEW) ├── Dockerfile # Dashboard image (NEW)
└── .dockerignore # Build exclusions └── .dockerignore # Build exclusions
@@ -32,7 +32,7 @@
- Clear documentation for each setting - Clear documentation for each setting
- Default values for non-sensitive configs - Default values for non-sensitive configs
**Location:** `.env.docker.example` **Location:** `docker/.env.docker.example`
### 5. **Created Docker Ignore Files** ### 5. **Created Docker Ignore Files**
- Excludes unnecessary files from images - Excludes unnecessary files from images
@@ -46,14 +46,14 @@
### 6. **Created Helper Scripts** ### 6. **Created Helper Scripts**
#### Windows Batch Scripts: #### Windows Batch Scripts:
- `docker-start.bat` - Start all services - `docker\scripts\docker-start.bat` - Start all services
- `docker-stop.bat` - Stop services with options - `docker\scripts\docker-stop.bat` - Stop services with options
- `docker-logs.bat` - View service logs - `docker\scripts\docker-logs.bat` - View service logs
#### Linux/Mac Shell Scripts: #### Linux/Mac Shell Scripts:
- `docker-start.sh` - Start all services - `docker/scripts/docker-start.sh` - Start all services
- `docker-stop.sh` - Stop services with options - `docker/scripts/docker-stop.sh` - Stop services with options
- `docker-logs.sh` - View service logs - `docker/scripts/docker-logs.sh` - View service logs
### 7. **Updated Next.js Configuration** ### 7. **Updated Next.js Configuration**
- Enabled standalone output for Docker - Enabled standalone output for Docker
@@ -122,7 +122,7 @@
cd "Smart Automatic Trading BOT + AI" cd "Smart Automatic Trading BOT + AI"
# Create environment file # Create environment file
copy .env.docker.example .env copy docker\.env.docker.example .env
# Edit .env with your MT5 credentials # Edit .env with your MT5 credentials
notepad .env notepad .env
@@ -141,10 +141,10 @@ MT5_PATH=/path/to/mt5/terminal
**Option A: Using helper script (Recommended)** **Option A: Using helper script (Recommended)**
```cmd ```cmd
REM Start core services REM Start core services
docker-start.bat docker\scripts\docker-start.bat
REM Or start with pgAdmin REM Or start with pgAdmin
docker-start.bat --admin docker\scripts\docker-start.bat --admin
``` ```
**Option B: Manual docker-compose** **Option B: Manual docker-compose**
@@ -182,12 +182,12 @@ You'll see:
### View Logs ### View Logs
```cmd ```cmd
REM All services REM All services
docker-logs.bat docker\scripts\docker-logs.bat
REM Specific service REM Specific service
docker-logs.bat trading-api docker\scripts\docker-logs.bat trading-api
docker-logs.bat dashboard docker\scripts\docker-logs.bat dashboard
docker-logs.bat postgres docker\scripts\docker-logs.bat postgres
``` ```
### Check Status ### Check Status
@@ -208,13 +208,13 @@ docker-compose restart dashboard
### Stop Services ### Stop Services
```cmd ```cmd
REM Stop (keeps data) REM Stop (keeps data)
docker-stop.bat docker\scripts\docker-stop.bat
REM Stop and remove containers (keeps data) REM Stop and remove containers (keeps data)
docker-stop.bat --remove docker\scripts\docker-stop.bat --remove
REM Stop and remove everything including data (⚠️ DANGER!) REM Stop and remove everything including data (⚠️ DANGER!)
docker-stop.bat --clean docker\scripts\docker-stop.bat --clean
``` ```
### Update Code and Rebuild ### Update Code and Rebuild
@@ -263,7 +263,7 @@ curl http://localhost:8000/api/health
**View API logs:** **View API logs:**
```cmd ```cmd
docker-logs.bat trading-api docker\scripts\docker-logs.bat trading-api
``` ```
### Port Already in Use ### Port Already in Use
@@ -292,7 +292,7 @@ docker-compose up -d
2. Ensure MT5 terminal is accessible 2. Ensure MT5 terminal is accessible
3. View API logs for connection errors: 3. View API logs for connection errors:
```cmd ```cmd
docker-logs.bat trading-api docker\scripts\docker-logs.bat trading-api
``` ```
### Database Connection Issues ### Database Connection Issues
@@ -309,7 +309,7 @@ docker exec -it trading_bot_db pg_isready -U trading_bot
**View database logs:** **View database logs:**
```cmd ```cmd
docker-logs.bat postgres docker\scripts\docker-logs.bat postgres
``` ```
## 📊 Monitoring ## 📊 Monitoring
@@ -353,15 +353,27 @@ xaubot-ai/
├── Dockerfile # Python API Docker image ├── Dockerfile # Python API Docker image
├── docker-compose.yml # Service orchestration ├── docker-compose.yml # Service orchestration
├── .env # Environment variables (DO NOT COMMIT) ├── .env # Environment variables (DO NOT COMMIT)
├── .env.docker.example # Environment template
├── .dockerignore # Files to exclude from build ├── .dockerignore # Files to exclude from build
├── docker-start.bat # Windows start script ├── docker/
├── docker-stop.bat # Windows stop script │ ├── .env.docker.example # Environment template
├── docker-logs.bat # Windows logs script │ ├── requirements-docker.txt # Docker-specific Python deps
├── docker-start.sh # Linux/Mac start script │ ├── init-db/01-schema.sql # Database schema
├── docker-stop.sh # Linux/Mac stop script │ ├── scripts/ # Helper scripts
├── docker-logs.sh # Linux/Mac logs script │ │ ├── docker-start.bat/.sh
├── DOCKER.md # Full Docker documentation │ │ ├── docker-stop.bat/.sh
│ │ ├── docker-logs.bat/.sh
│ │ ├── docker-status.bat
│ │ ├── docker-add-dashboard.bat
│ │ ├── docker-remove-dashboard.bat
│ │ ├── start-all.bat
│ │ ├── start-api.bat
│ │ └── start-dashboard.bat
│ └── docs/ # Docker documentation
│ ├── DOCKER.md
│ ├── DOCKER-INTEGRATION.md
│ ├── DOCKER-SETUP-SUMMARY.md
│ ├── QUICK-START.md
│ └── SIMPLE-START.md
└── web-dashboard/ └── web-dashboard/
├── Dockerfile # Next.js dashboard image ├── Dockerfile # Next.js dashboard image
├── .dockerignore # Dashboard build exclusions ├── .dockerignore # Dashboard build exclusions
@@ -390,7 +402,7 @@ xaubot-ai/
If you encounter issues: If you encounter issues:
1. Check the logs: `docker-logs.bat` 1. Check the logs: `docker\scripts\docker-logs.bat`
2. Verify services: `docker-compose ps` 2. Verify services: `docker-compose ps`
3. Review troubleshooting section in [DOCKER.md](DOCKER.md) 3. Review troubleshooting section in [DOCKER.md](DOCKER.md)
4. Check service health: `curl http://localhost:8000/api/health` 4. Check service health: `curl http://localhost:8000/api/health`
+1 -1
View File
@@ -51,7 +51,7 @@ The Docker setup includes 4 services:
cd "Smart Automatic Trading BOT + AI" cd "Smart Automatic Trading BOT + AI"
# Copy environment template # Copy environment template
cp .env.docker.example .env cp docker/.env.docker.example .env
``` ```
### 2. Configure Environment ### 2. Configure Environment
@@ -14,7 +14,7 @@
cd "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI" cd "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI"
REM Copy environment template kalau belum ada REM Copy environment template kalau belum ada
copy .env.docker.example .env copy docker\.env.docker.example .env
REM Edit dengan MT5 credentials Anda REM Edit dengan MT5 credentials Anda
notepad .env notepad .env
@@ -148,7 +148,7 @@ Docker Compose Project: "smart-automatic-trading-bot-ai"
## ✅ Checklist ## ✅ Checklist
- [ ] Copy `.env.docker.example` ke `.env` - [ ] Copy `docker/.env.docker.example` ke `.env`
- [ ] Edit `.env` dengan MT5 credentials - [ ] Edit `.env` dengan MT5 credentials
- [ ] Run: `docker-compose build trading-api dashboard` - [ ] Run: `docker-compose build trading-api dashboard`
- [ ] Run: `docker-compose up -d trading-api dashboard` - [ ] Run: `docker-compose up -d trading-api dashboard`
@@ -3,7 +3,7 @@
## 🎯 Cara Tercepat (1 Command) ## 🎯 Cara Tercepat (1 Command)
```cmd ```cmd
start-all.bat docker\scripts\start-all.bat
``` ```
Script ini akan: Script ini akan:
@@ -17,19 +17,19 @@ Dua window akan terbuka otomatis!
### Option 1: Start Semua Sekaligus ### Option 1: Start Semua Sekaligus
```cmd ```cmd
start-all.bat docker\scripts\start-all.bat
``` ```
### Option 2: Start Satu-satu ### Option 2: Start Satu-satu
**Terminal 1: API** **Terminal 1: API**
```cmd ```cmd
start-api.bat docker\scripts\start-api.bat
``` ```
**Terminal 2: Dashboard** **Terminal 2: Dashboard**
```cmd ```cmd
start-dashboard.bat docker\scripts\start-dashboard.bat
``` ```
## ✅ Pre-requisites ## ✅ Pre-requisites
@@ -155,16 +155,16 @@ Dashboard akan menampilkan:
Lihat output di command windows untuk debug Lihat output di command windows untuk debug
4. **Quick Restart:** 4. **Quick Restart:**
Close windows dan run `start-all.bat` lagi Close windows dan run `docker\scripts\start-all.bat` lagi
## 📝 Files ## 📝 Files
``` ```
start-all.bat # Start API + Dashboard docker\scripts\start-all.bat # Start API + Dashboard
start-api.bat # Start API only docker\scripts\start-api.bat # Start API only
start-dashboard.bat # Start Dashboard only docker\scripts\start-dashboard.bat # Start Dashboard only
``` ```
--- ---
**Super Simple!** Tinggal double-click `start-all.bat` 🎉 **Super Simple!** Tinggal double-click `docker\scripts\start-all.bat` 🎉
@@ -1,5 +1,6 @@
@echo off @echo off
REM Add Dashboard & API to existing Docker setup REM Add Dashboard & API to existing Docker setup
cd /d "%~dp0..\.."
echo. echo.
echo ======================================== echo ========================================
@@ -11,7 +12,7 @@ REM Check if .env exists
if not exist .env ( if not exist .env (
echo WARNING: .env file not found! echo WARNING: .env file not found!
echo Creating .env from template... echo Creating .env from template...
copy .env.docker.example .env copy docker\.env.docker.example .env
echo. echo.
echo Please edit .env with your MT5 credentials: echo Please edit .env with your MT5 credentials:
echo - MT5_LOGIN echo - MT5_LOGIN
@@ -1,5 +1,6 @@
@echo off @echo off
REM XAUBot AI - Docker Logs Viewer (Windows) REM XAUBot AI - Docker Logs Viewer (Windows)
cd /d "%~dp0..\.."
set SERVICE=%1 set SERVICE=%1
set LINES=%2 set LINES=%2
@@ -2,6 +2,7 @@
# XAUBot AI - Docker Logs Viewer # XAUBot AI - Docker Logs Viewer
set -e set -e
cd "$(dirname "$0")/../.."
SERVICE="$1" SERVICE="$1"
LINES="${2:-100}" LINES="${2:-100}"
@@ -1,5 +1,6 @@
@echo off @echo off
REM Remove Dashboard & API while keeping database REM Remove Dashboard & API while keeping database
cd /d "%~dp0..\.."
echo. echo.
echo ======================================== echo ========================================
@@ -29,6 +30,6 @@ echo.
echo Database is still running: echo Database is still running:
docker ps --filter "name=trading_bot_db" --format "table {{.Names}}\t{{.Status}}" docker ps --filter "name=trading_bot_db" --format "table {{.Names}}\t{{.Status}}"
echo. echo.
echo To add dashboard back: docker-add-dashboard.bat echo To add dashboard back: docker\scripts\docker-add-dashboard.bat
echo. echo.
pause pause
@@ -1,5 +1,6 @@
@echo off @echo off
REM XAUBot AI - Docker Start Script (Windows) REM XAUBot AI - Docker Start Script (Windows)
cd /d "%~dp0..\.."
echo. echo.
echo Starting XAUBot AI Docker Services... echo Starting XAUBot AI Docker Services...
@@ -9,7 +10,7 @@ REM Check if .env exists
if not exist .env ( if not exist .env (
echo WARNING: .env file not found! echo WARNING: .env file not found!
echo Creating .env from template... echo Creating .env from template...
copy .env.docker.example .env copy docker\.env.docker.example .env
echo. echo.
echo .env created. Please edit it with your MT5 credentials: echo .env created. Please edit it with your MT5 credentials:
echo - MT5_LOGIN echo - MT5_LOGIN
@@ -86,6 +87,6 @@ echo View API logs: docker-compose logs -f trading-api
echo Stop services: docker-compose down echo Stop services: docker-compose down
echo Restart: docker-compose restart echo Restart: docker-compose restart
echo. echo.
echo Full documentation: DOCKER.md echo Full documentation: docker\docs\DOCKER.md
echo. echo.
pause pause
@@ -2,6 +2,7 @@
# XAUBot AI - Docker Start Script # XAUBot AI - Docker Start Script
set -e set -e
cd "$(dirname "$0")/../.."
echo "🚀 Starting XAUBot AI Docker Services..." echo "🚀 Starting XAUBot AI Docker Services..."
echo "" echo ""
@@ -10,7 +11,7 @@ echo ""
if [ ! -f .env ]; then if [ ! -f .env ]; then
echo "⚠️ .env file not found!" echo "⚠️ .env file not found!"
echo "📝 Creating .env from template..." echo "📝 Creating .env from template..."
cp .env.docker.example .env cp docker/.env.docker.example .env
echo "✅ .env created. Please edit it with your MT5 credentials:" echo "✅ .env created. Please edit it with your MT5 credentials:"
echo " - MT5_LOGIN" echo " - MT5_LOGIN"
echo " - MT5_PASSWORD" echo " - MT5_PASSWORD"
@@ -83,5 +84,5 @@ echo " View API logs: docker-compose logs -f trading-api"
echo " Stop services: docker-compose down" echo " Stop services: docker-compose down"
echo " Restart: docker-compose restart" echo " Restart: docker-compose restart"
echo "" echo ""
echo "📖 Full documentation: DOCKER.md" echo "📖 Full documentation: docker/docs/DOCKER.md"
echo "" echo ""
@@ -1,5 +1,6 @@
@echo off @echo off
REM Check status of all trading bot services REM Check status of all trading bot services
cd /d "%~dp0..\.."
echo. echo.
echo ======================================== echo ========================================
@@ -1,5 +1,6 @@
@echo off @echo off
REM XAUBot AI - Docker Stop Script (Windows) REM XAUBot AI - Docker Stop Script (Windows)
cd /d "%~dp0..\.."
echo. echo.
echo Stopping XAUBot AI Docker Services... echo Stopping XAUBot AI Docker Services...
@@ -39,6 +40,6 @@ echo Containers stopped
:end :end
echo. echo.
echo To restart: docker-start.bat echo To restart: docker\scripts\docker-start.bat
echo. echo.
pause pause
@@ -2,6 +2,7 @@
# XAUBot AI - Docker Stop Script # XAUBot AI - Docker Stop Script
set -e set -e
cd "$(dirname "$0")/../.."
echo "🛑 Stopping XAUBot AI Docker Services..." echo "🛑 Stopping XAUBot AI Docker Services..."
echo "" echo ""
@@ -27,5 +28,5 @@ else
fi fi
echo "" echo ""
echo "📋 To restart: ./docker-start.sh" echo "📋 To restart: ./docker/scripts/docker-start.sh"
echo "" echo ""
@@ -7,7 +7,7 @@ echo XAUBot AI - Starting All Services
echo ======================================== echo ========================================
echo. echo.
cd "%~dp0" cd /d "%~dp0..\.."
REM Check database REM Check database
echo [1/3] Checking database... echo [1/3] Checking database...
@@ -23,14 +23,14 @@ if errorlevel 1 (
echo. echo.
echo [2/3] Starting API... echo [2/3] Starting API...
start "Trading API" cmd /k start-api.bat start "Trading API" cmd /k docker\scripts\start-api.bat
echo Waiting for API to start... echo Waiting for API to start...
timeout /t 5 /nobreak >nul timeout /t 5 /nobreak >nul
echo. echo.
echo [3/3] Starting Dashboard... echo [3/3] Starting Dashboard...
start "Web Dashboard" cmd /k start-dashboard.bat start "Web Dashboard" cmd /k docker\scripts\start-dashboard.bat
echo. echo.
echo ======================================== echo ========================================
@@ -7,7 +7,7 @@ echo Starting Trading API
echo ======================================== echo ========================================
echo. echo.
cd "%~dp0" cd /d "%~dp0..\.."
REM Check if virtual environment exists REM Check if virtual environment exists
if not exist "venv" ( if not exist "venv" (
@@ -7,7 +7,7 @@ echo Starting Web Dashboard
echo ======================================== echo ========================================
echo. echo.
cd "%~dp0web-dashboard" cd /d "%~dp0..\..\web-dashboard"
REM Check if node_modules exists REM Check if node_modules exists
if not exist "node_modules" ( if not exist "node_modules" (