# ECM Platform - Backend Folder Structure

```
d:/Trade/FTP/
├── app/
│   ├── Console/
│   │   └── Kernel.php                          # Laravel scheduler configuration
│   ├── Http/
│   │   └── Controllers/
│   │       └── Api/
│   │           └── Mt5SyncController.php       # MT5 sync API endpoints
│   ├── Jobs/
│   │   ├── ProcessDailyProfitDistribution.php  # Queue job for profit distribution
│   │   ├── ProcessMt5Sync.php                  # Queue job for MT5 sync processing
│   │   ├── CreateDailyProfitSnapshot.php       # Queue job for daily snapshots
│   │   └── RecalculateInvestorUnits.php        # Queue job for unit recalculation
│   ├── Models/
│   │   ├── Investor.php                        # Investor model
│   │   ├── Mt5Account.php                      # MT5 account model
│   │   ├── Trade.php                           # Trade model
│   │   ├── ProfitDistribution.php              # Profit distribution model
│   │   ├── TradeHistory.php                    # Trade history model
│   │   ├── DailyProfitSnapshot.php             # Daily snapshot model
│   │   ├── InvestorProfitLog.php               # Investor profit log model
│   │   ├── SafetyFund.php                      # Safety fund model
│   │   ├── Referral.php                        # Referral model
│   │   └── ReferralCommission.php              # Referral commission model
│   └── Services/
│       ├── ProfitSharingService.php            # Profit distribution business logic
│       └── Mt5SyncService.php                  # MT5 sync business logic
├── config/
│   └── services.php                             # Service configuration (MT5 API key)
├── database/
│   └── migrations/
│       ├── 2024_01_01_000001_create_investors_table.php
│       ├── 2024_01_01_000002_create_mt5_accounts_table.php
│       ├── 2024_01_01_000003_create_trades_table.php
│       ├── 2024_01_01_000004_create_trade_histories_table.php
│       ├── 2024_01_01_000005_create_profit_distributions_table.php
│       ├── 2024_01_01_000006_create_investor_profit_logs_table.php
│       ├── 2024_01_01_000007_create_safety_funds_table.php
│       ├── 2024_01_01_000008_create_referrals_table.php
│       ├── 2024_01_01_000009_create_referral_commissions_table.php
│       └── 2024_01_01_000010_create_daily_profit_snapshots_table.php
├── python-mt5-bridge/
│   ├── mt5_sync.py                              # Basic MT5 sync bridge
│   ├── mt5_sync_advanced.py                     # Advanced MT5 sync with retry logic
│   ├── requirements.txt                         # Python dependencies
│   ├── .env.example                             # Environment variables template
│   └── README.md                                # Python bridge documentation
├── routes/
│   └── api.php                                  # API routes configuration
├── .env.example                                 # Laravel environment variables template
├── ARCHITECTURE.md                              # Architecture overview
├── EXAMPLE_CALCULATIONS.md                      # Calculation examples and SQL inserts
└── PRODUCTION_RECOMMENDATIONS.md                # Deployment and production guide
```
