curl -X POST https://app.expert-research.in/api/auth/send-otp \
-H "Content-Type: application/json" \
-d '{"phone":"919876543210","purpose":"login"}'
System Summary
Stack: PHP + MySQL. Auth: WhatsApp OTP + JWT (7 days). Roles: admin, agent, investor.
Admin login bypasses OTP. No cron/background jobs; due states are computed with query-time rules.
Implementation
| Item | Value |
|---|---|
| Entrypoint | api/public/index.php |
| Main API Class | api/src/App.php |
| Server Rewrite | api/public/.htaccess routes all API paths to index.php |
| Auth Header | Authorization: Bearer {{access_token}} |
| Environment Vars | DB_HOST DB_PORT DB_NAME DB_USER DB_PASS JWT_SECRET APP_ENV |
| DB Schema | Import api/database.sql before running APIs. |
| Test Seed | Import api/test_seed.sql for login accounts + dummy test data. |
| Response Format | JSON for all endpoints. Error format: {"error":"message"} |
| Admin Auth | Admin user can verify login without OTP via /api/auth/verify-otp using phone. |
| Direct Login | POST /api/auth/login with phone + password (bcrypt hash in users.password_hash). |
Business Rules
| Rule | Value |
|---|---|
| Minimum Investment | INR 100000 |
| Plan Tenure | 20 months |
| Monthly Payout | 10% total = 5% principal + 5% interest |
| Lock-in | 3 months |
| Early Closure | After lock-in, settlement = remaining principal only |
| Agent Commission | 5% upfront + 1% monthly for 20 months |
| Payout Cycles | Invested on 1-10 -> 15th next month; 11-20 -> 25th next month; 21-31 -> 5th month-after-next |
Database Mapping
Core tables: users, bank_accounts, bank_change_requests, investments, payout_schedule,
agent_commissions, otp_verifications, investor_requests, payout_batches, payout_batch_items.
API payloads below align to these entities.
Authentication APIs
curl -X POST https://app.expert-research.in/api/auth/login \
-H "Content-Type: application/json" \
-d '{"phone":"919900000001","password":"Admin@123"}'
curl -X POST https://app.expert-research.in/api/auth/verify-otp \
-H "Content-Type: application/json" \
-d '{"phone":"919876543210","otp":"123456"}'
curl -X POST https://app.expert-research.in/api/auth/refresh-token \
-H "Content-Type: application/json" \
-d '{"refresh_token":"your_refresh_token"}'
User APIs
curl -X GET https://app.expert-research.in/api/user/profile \
-H "Authorization: Bearer {{access_token}}"
curl -X POST https://app.expert-research.in/api/user/update-profile \
-H "Authorization: Bearer {{access_token}}" \
-H "Content-Type: application/json" \
-d '{"name":"Amit Shah","pan_number":"ABCDE1234F","aadhaar_number":"123412341234"}'
Investor APIs
curl -X GET https://app.expert-research.in/api/investor/dashboard -H "Authorization: Bearer {{access_token}}"curl -X GET https://app.expert-research.in/api/investor/investments -H "Authorization: Bearer {{access_token}}"curl -X GET https://app.expert-research.in/api/investor/payouts?status=paid -H "Authorization: Bearer {{access_token}}"curl -X POST https://app.expert-research.in/api/investor/request-investment \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"amount":100000,"txn_id":"TXN12345","proof_image":"https://cdn/proof.jpg"}'curl -X POST https://app.expert-research.in/api/investor/request-closure \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"investment_id":45,"message":"Need funds urgently"}'curl -X POST https://app.expert-research.in/api/investor/bank-change-request \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"account_holder":"Rahul Jain","bank_name":"HDFC","account_number":"1234567890","ifsc_code":"HDFC0000123","branch":"Andheri"}'Agent APIs
curl -X GET https://app.expert-research.in/api/agent/dashboard -H "Authorization: Bearer {{access_token}}"curl -X POST https://app.expert-research.in/api/agent/investor/create \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"name":"Priya Singh","phone":"919811112222","pan_number":"ABCDE1234F"}'curl -X GET https://app.expert-research.in/api/agent/investors -H "Authorization: Bearer {{access_token}}"curl -X POST https://app.expert-research.in/api/agent/investment/create \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"investor_id":12,"amount":200000,"txn_id":"TXN9911","proof_image":"https://cdn/inv-proof.jpg"}'curl -X GET https://app.expert-research.in/api/agent/commissions?status=pending -H "Authorization: Bearer {{access_token}}"curl -X POST https://app.expert-research.in/api/agent/bank-change-request \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"account_holder":"Agent Name","bank_name":"ICICI","account_number":"9988776655","ifsc_code":"ICIC0001234","branch":"Pune"}'Admin APIs
curl -X POST https://app.expert-research.in/api/admin/agent/create \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"name":"New Agent","phone":"919900001111"}'curl -X POST https://app.expert-research.in/api/admin/investor/create \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"name":"New Investor","phone":"919900002222"}'curl -X GET https://app.expert-research.in/api/admin/investments/pending -H "Authorization: Bearer {{access_token}}"curl -X POST https://app.expert-research.in/api/admin/investment/approve \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"investment_id":45}'curl -X POST https://app.expert-research.in/api/admin/investment/reject \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"investment_id":45,"reason":"Payment proof mismatch"}'curl -X POST https://app.expert-research.in/api/admin/closure/approve \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"request_id":77}'curl -X POST https://app.expert-research.in/api/admin/closure/reject \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"request_id":77,"reason":"Lock-in not completed"}'curl -X POST https://app.expert-research.in/api/admin/closure/schedule-settlement \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"investment_id":45,"settlement_amount":70000,"payout_date":"2026-04-25"}'curl -X POST https://app.expert-research.in/api/admin/bank-change/approve \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"request_id":31}'curl -X POST https://app.expert-research.in/api/admin/bank-change/reject \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"request_id":31,"reason":"Invalid IFSC"}'Payout APIs
curl -X GET https://app.expert-research.in/api/payouts/due -H "Authorization: Bearer {{access_token}}"curl -X POST https://app.expert-research.in/api/payouts/generate-batch \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"payout_date":"2026-03-25"}'curl -X POST https://app.expert-research.in/api/payouts/mark-paid \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"payout_ids":[101,102,103],"paid_at":"2026-03-25T12:30:00"}'curl -X GET "https://app.expert-research.in/api/payouts/history?from=2026-01-01&to=2026-03-31" \
-H "Authorization: Bearer {{access_token}}"Commission APIs
curl -X GET https://app.expert-research.in/api/commissions/due -H "Authorization: Bearer {{access_token}}"curl -X POST https://app.expert-research.in/api/commissions/generate-batch \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"cycle_month":"2026-03"}'curl -X POST https://app.expert-research.in/api/commissions/mark-paid \
-H "Authorization: Bearer {{access_token}}" -H "Content-Type: application/json" \
-d '{"commission_ids":[221,222],"paid_at":"2026-03-25T14:00:00"}'curl -X GET "https://app.expert-research.in/api/commissions/history?status=paid" \
-H "Authorization: Bearer {{access_token}}"Report APIs
curl -X GET "https://app.expert-research.in/api/reports/investments?status=active" \
-H "Authorization: Bearer {{access_token}}"curl -X GET "https://app.expert-research.in/api/reports/payouts?from=2026-01-01&to=2026-03-01" \
-H "Authorization: Bearer {{access_token}}"curl -X GET "https://app.expert-research.in/api/reports/commissions?agent_id=5" \
-H "Authorization: Bearer {{access_token}}"curl -X GET https://app.expert-research.in/api/reports/agents \
-H "Authorization: Bearer {{access_token}}"