================================================================================ 🚀 BACKEND SETUP GUIDE - HishabPlus SaaS Rent/SMS Management ================================================================================ Laravel 12 Backend | MySQL + Redis | SSLCommerz + SMS.NET.BD Complete setup instructions for development and production deployment ================================================================================ 📋 TABLE OF CONTENTS ================================================================================ 1. Prerequisites 2. Initial Setup (Development) 3. Database Configuration 4. Environment Variables 5. Running Migrations & Seeders 6. Queue & Scheduler Setup 7. Testing the Backend 8. Production Deployment 9. Troubleshooting 10. API Endpoints Reference ================================================================================ 1️⃣ PREREQUISITES ================================================================================ Required Software: ✅ PHP 8.2 or higher ✅ Composer (latest version) ✅ MySQL 8.0 or higher ✅ Redis Server 6.0+ ✅ Node.js 18+ and NPM (for asset compilation if needed) ✅ Git Optional (for production): ✅ Supervisor (Linux) or similar process manager ✅ Nginx/Apache web server Check versions: ```bash php -v # Should show 8.2+ composer -V # Composer version mysql --version # MySQL version redis-cli --version # Redis version ``` ================================================================================ 2️⃣ INITIAL SETUP (Development) ================================================================================ Step 1: Clone the repository ```bash git clone https://github.com/Dev-Majharul/finance-project-shojol.git cd finance-project-shojol/dashbord/backend ``` Step 2: Install PHP dependencies ```bash composer install ``` Step 3: Create environment file ```bash # Copy example to actual .env cp .env.example .env # Generate application key php artisan key:generate ``` Step 4: Create necessary directories ```bash # Storage directories (if not exist) mkdir -p storage/app/invoices mkdir -p storage/app/archives/users mkdir -p storage/logs # Set permissions (Linux/Mac) chmod -R 775 storage bootstrap/cache ``` ================================================================================ 3️⃣ DATABASE CONFIGURATION ================================================================================ Step 1: Create MySQL database ```sql -- Login to MySQL mysql -u root -p -- Create database CREATE DATABASE hishabplus_backend CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; -- Create user (optional) CREATE USER 'hishabplus'@'localhost' IDENTIFIED BY 'your_secure_password'; GRANT ALL PRIVILEGES ON hishabplus_backend.* TO 'hishabplus'@'localhost'; FLUSH PRIVILEGES; -- Exit MySQL EXIT; ``` Step 2: Configure .env database connection ```env DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=hishabplus_backend DB_USERNAME=hishabplus DB_PASSWORD=your_secure_password ``` Step 3: Test database connection ```bash php artisan db:show # Should display database information ``` ================================================================================ 4️⃣ ENVIRONMENT VARIABLES ================================================================================ Edit .env file and configure ALL the following sections: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 APPLICATION SETTINGS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```env APP_NAME=HishabPlus APP_ENV=local # Use 'production' for live APP_DEBUG=true # Set to false in production APP_URL=http://localhost:8000 # Your backend URL FRONTEND_URL=http://localhost:3000 # User frontend ADMIN_SUBDOMAIN=admin.hishabplus.com # Admin frontend ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 DATABASE (Already configured above) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ [See section 3] ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 REDIS CONFIGURATION (Required for queues) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```env QUEUE_CONNECTION=redis # Use Redis for queues REDIS_CLIENT=phpredis # Or predis REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null # Set if Redis has password REDIS_PORT=6379 REDIS_URL=redis://127.0.0.1:6379 ``` Test Redis connection: ```bash redis-cli ping # Should return: PONG ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 SMS PROVIDER (api.sms.net.bd) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```env SMS_PROVIDER_URL=https://api.sms.net.bd/sendsms SMS_PROVIDER_BALANCE_URL=https://api.sms.net.bd/user/balance/ SMS_API_KEY=your_sms_api_key_here # ⚠️ REQUIRED - Get from SMS provider SMS_SENDER_ID=HishabPlus SMS_PROVIDER_CHUNK_SIZE=100 SMS_SEND_QUEUE=send_sms SMS_MAX_SEND_TRIES=5 SMS_TIMEOUT_SECONDS=10 SMS_RATE_LIMIT_PER_MINUTE=30 SMS_GLOBAL_RATE_LIMIT_PER_MINUTE=500 SMS_ALERT_EMAIL=ops@yourdomain.com # For SMS alerts SMS_ALERT_THRESHOLD=3 ``` ⚠️ **Get SMS API Key:** Register at https://api.sms.net.bd/ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 PAYMENT GATEWAY (SSLCommerz) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```env SSLCOMMERZ_STORE_ID=your_store_id # ⚠️ REQUIRED SSLCOMMERZ_STORE_PASSWORD=your_password # ⚠️ REQUIRED SSLCOMMERZ_SANDBOX=true # true for testing, false for production # Callback URLs (adjust based on your domain) PAYMENT_CALLBACK_URL=https://api.hishabplus.com/api/payments/sslcommerz/callback PAYMENT_SUCCESS_URL=https://app.hishabplus.com/payment/success PAYMENT_FAIL_URL=https://app.hishabplus.com/payment/fail PAYMENT_CANCEL_URL=https://app.hishabplus.com/payment/cancel ``` ⚠️ **Get SSLCommerz Credentials:** - Sandbox: https://developer.sslcommerz.com/registration/ - Production: https://sslcommerz.com/ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 MAIL CONFIGURATION (For invoices & notifications) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```env MAIL_MAILER=smtp MAIL_HOST=smtp.gmail.com # Or your SMTP server MAIL_PORT=587 MAIL_USERNAME=your-email@gmail.com MAIL_PASSWORD=your-app-password MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS=noreply@hishabplus.com MAIL_FROM_NAME="${APP_NAME}" ``` For Gmail: Enable 2FA and create App Password ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 ADMIN CREDENTIALS (For seeding) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```env ADMIN_EMAIL=admin@hishabplus.com ADMIN_PASSWORD=SecurePassword123! ADMIN_PHONE=+8801700000000 ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📌 APPLICATION SETTINGS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```env TRIAL_DAYS=30 GRACE_PERIOD_DAYS=15 TRIAL_SMS_BALANCE=10 ``` ================================================================================ 5️⃣ RUNNING MIGRATIONS & SEEDERS ================================================================================ Step 1: Run migrations (creates all tables) ```bash php artisan migrate ``` Expected output: ``` Migration table created successfully. Migrating: 0001_01_01_000000_create_users_table Migrated: 0001_01_01_000000_create_users_table (123.45ms) Migrating: 0001_01_01_000001_create_cache_table ... Migrating: 2025_11_09_000003_create_sms_topups_table Migrated: 2025_11_09_000003_create_sms_topups_table (45.67ms) ``` Step 2: Seed essential data (run in order) ```bash php artisan db:seed --class=PropertyCategorySeeder php artisan db:seed --class=PackageSeeder php artisan db:seed --class=SettingSeeder php artisan db:seed --class=AdminSeeder php artisan db:seed --class=SmsTemplateSeeder ``` Or seed all at once: ```bash php artisan db:seed ``` Step 3: Verify setup ```bash php artisan app:verify-setup ``` Expected output: ``` 🔍 Verifying Application Setup... ✅ Packages seeded: 5 packages found ✅ Trial package configured: "Trial" (ID: 1) ✅ Admin user exists: admin@hishabplus.com (Super Admin) ✅ SMS Provider docs configured: https://api.sms.net.bd/ ✅ SSLCommerz docs configured: https://github.com/sslcommerz/SSLCommerz-Laravel ✅ SMS provider API examples configured ✅ Essential settings configured ✨ All checks passed! Your application is properly configured. ``` Step 4: Create a test user (optional) ```bash php artisan tinker ``` ```php $user = User::factory()->create([ 'email' => 'test@example.com', 'password' => bcrypt('password'), 'trial_ends_at' => now()->addDays(30) ]); ``` ================================================================================ 6️⃣ QUEUE & SCHEDULER SETUP ================================================================================ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔥 DEVELOPMENT (Run in separate terminals) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Terminal 1: Start Laravel dev server ```bash php artisan serve # Runs on http://localhost:8000 ``` Terminal 2: Start queue worker ```bash php artisan queue:work redis --queue=send_sms,default --sleep=3 --tries=5 --backoff=60 --timeout=120 ``` Terminal 3: Start scheduler ```bash php artisan schedule:work ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔥 PRODUCTION (Supervisor + Cron) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Option A: Supervisor Configuration (Recommended for Linux) Create file: /etc/supervisor/conf.d/hishabplus-worker.conf ```ini [program:hishabplus-worker] process_name=%(program_name)s_%(process_num)02d command=php /var/www/hishabplus/backend/artisan queue:work redis --queue=send_sms,default --sleep=3 --tries=5 --max-time=3600 autostart=true autorestart=true stopasgroup=true killasgroup=true user=www-data numprocs=3 redirect_stderr=true stdout_logfile=/var/www/hishabplus/backend/storage/logs/worker.log stopwaitsecs=3600 ``` Start supervisor: ```bash sudo supervisorctl reread sudo supervisorctl update sudo supervisorctl start hishabplus-worker:* sudo supervisorctl status ``` Option B: Laravel Scheduler (Cron) Add to crontab: ```bash crontab -e # Add this line: * * * * * cd /var/www/hishabplus/backend && php artisan schedule:run >> /dev/null 2>&1 ``` Scheduled Jobs: - subscriptions:expire → Daily at 2 AM - subscriptions:process-grace → Daily at 3 AM - sms:send-scheduled → Every minute - sms:fetch-balance → Every 10 minutes - ArchiveExpiredUserDataJob → Weekly on Sunday at 4 AM - Activity log cleanup → Monthly at 5 AM ================================================================================ 7️⃣ TESTING THE BACKEND ================================================================================ Run all tests: ```bash php artisan test ``` Run specific test suites: ```bash # Model tests php artisan test --filter=ModelsTest # SMS balance calculation php artisan test --filter=SmsBalanceCalculationTest # Subscription lifecycle php artisan test --filter=SubscriptionLifecycleTest # SMS subsystem php artisan test --filter=Sms # Payment system php artisan test --filter=Payment # Templates php artisan test --filter=Template ``` Expected result: ``` Tests: 105 passed (XXX assertions) Duration: XX.XXs ``` ================================================================================ 8️⃣ API TESTING (Manual) ================================================================================ Use Postman, Insomnia, or curl to test endpoints: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1. Register a user ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```bash POST http://localhost:8000/api/auth/register Content-Type: application/json { "name": "John Doe", "email": "john@example.com", "password": "password123", "password_confirmation": "password123", "business_name": "John Properties", "phone": "+8801712345678" } ``` Save the token from response. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2. Get user dashboard ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```bash GET http://localhost:8000/api/dashboard Authorization: Bearer {token} ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3. Create a property ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```bash POST http://localhost:8000/api/properties Authorization: Bearer {token} Content-Type: application/json { "category_id": 1, "title": "Green Villa Apartment", "address": "123 Main Street, Dhaka", "default_rent_amount": 15000, "status": "vacant" } ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4. Initiate payment checkout ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ```bash POST http://localhost:8000/api/payments/checkout Authorization: Bearer {token} Content-Type: application/json { "type": "subscription", "package_id": 2 } ``` Returns checkout_url → redirect user to SSLCommerz ================================================================================ 9️⃣ PRODUCTION DEPLOYMENT ================================================================================ Pre-deployment checklist: ✅ Set APP_ENV=production ✅ Set APP_DEBUG=false ✅ Set SSLCOMMERZ_SANDBOX=false ✅ Use production database credentials ✅ Configure real SMTP settings ✅ Set strong ADMIN_PASSWORD ✅ Configure proper FRONTEND_URL and callback URLs ✅ Set up HTTPS/SSL certificates ✅ Configure firewall rules Optimization commands: ```bash # Cache configuration php artisan config:cache # Cache routes php artisan route:cache # Cache views php artisan view:cache # Optimize autoloader composer install --optimize-autoloader --no-dev ``` Web server configuration: **Nginx (example):** ```nginx server { listen 80; server_name api.hishabplus.com; root /var/www/hishabplus/backend/public; add_header X-Frame-Options "SAMEORIGIN"; add_header X-Content-Type-Options "nosniff"; index index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.(?!well-known).* { deny all; } } ``` ================================================================================ 🔟 TROUBLESHOOTING ================================================================================ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Problem: Migration fails ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Solution: ```bash # Check database connection php artisan db:show # Fresh migration (⚠️ deletes all data) php artisan migrate:fresh # Rollback last migration php artisan migrate:rollback # Check migration status php artisan migrate:status ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Problem: Queue not processing jobs ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Solution: ```bash # Check Redis connection redis-cli ping # List failed jobs php artisan queue:failed # Retry failed jobs php artisan queue:retry all # Clear failed jobs php artisan queue:flush # Monitor queue php artisan queue:monitor send_sms --max=1000 # Restart queue worker php artisan queue:restart ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Problem: SMS not sending ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Solution: ```bash # Check SMS provider balance php artisan sms:fetch-balance --sync # Check queue jobs php artisan queue:work --once # Check logs tail -f storage/logs/laravel.log # Test SMS provider connection php artisan tinker ``` ```php Http::get('https://api.sms.net.bd/user/balance/', ['api_key' => env('SMS_API_KEY')]); ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Problem: Payment webhook not working ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Solution: ```bash # Check callback URL is publicly accessible # SSLCommerz must be able to reach your server # Use ngrok for local testing: ngrok http 8000 # Update PAYMENT_CALLBACK_URL in .env to ngrok URL # Check logs for callback attempts grep "SSLCommerz callback" storage/logs/laravel.log # Manually reconcile pending payments php artisan payments:process --reconcile ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Problem: Permission denied errors ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Solution (Linux): ```bash # Fix storage permissions sudo chown -R www-data:www-data storage bootstrap/cache sudo chmod -R 775 storage bootstrap/cache ``` ================================================================================ 1️⃣1️⃣ API ENDPOINTS REFERENCE ================================================================================ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🔐 AUTHENTICATION (No auth required) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ POST /api/auth/register # User registration (14-day trial) POST /api/auth/login # User login POST /api/auth/logout # User logout (requires auth) GET /api/auth/me # Get authenticated user ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 🏘️ PROPERTIES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ GET /api/properties # List user's properties POST /api/properties # Create property GET /api/properties/{id} # View property PUT /api/properties/{id} # Update property DELETE /api/properties/{id} # Delete property ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 👥 RENTERS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ GET /api/renters # List renters POST /api/renters # Create renter GET /api/renters/{id} # View renter PUT /api/renters/{id} # Update renter DELETE /api/renters/{id} # Delete renter POST /api/renters/{id}/end-rent # End rent ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📱 SMS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ GET /api/sms # List sent messages POST /api/sms/send # Send SMS (throttled: 30/min) POST /api/sms/schedule # Schedule SMS POST /api/sms/purchase # Purchase SMS credits ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📝 SMS TEMPLATES ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ GET /api/sms-templates # List templates POST /api/sms-templates # Create template GET /api/sms-templates/{id} # View template PUT /api/sms-templates/{id} # Update template DELETE /api/sms-templates/{id} # Delete template ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 💳 PAYMENTS ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ POST /api/payments/checkout # Initiate payment ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 📊 ADMIN ENDPOINTS (prefix: /admin/api) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ POST /admin/api/auth/login # Admin login GET /admin/api/users # List all users GET /admin/api/packages # List packages GET /admin/api/payments # List all payments GET /admin/api/reports/sms-usage # SMS usage report GET /admin/api/reports/revenue # Revenue report All user/admin endpoints require Bearer token in Authorization header. ================================================================================ 🛠️ USEFUL COMMANDS ================================================================================ # Clear all caches php artisan optimize:clear # View routes php artisan route:list # Check database php artisan db:show # Tinker (interactive shell) php artisan tinker # View logs (live) tail -f storage/logs/laravel.log # Check queue status php artisan queue:monitor send_sms # List scheduled tasks php artisan schedule:list # Fetch SMS balance php artisan sms:fetch-balance --sync # Process subscriptions manually php artisan subscriptions:expire php artisan subscriptions:process-grace # Verify setup php artisan app:verify-setup # Reconcile payments php artisan payments:process --reconcile ================================================================================ 📧 MAIL TESTING (Development) ================================================================================ Use Mailtrap for testing emails: 1. Sign up at https://mailtrap.io 2. Get SMTP credentials 3. Update .env: ```env MAIL_MAILER=smtp MAIL_HOST=sandbox.smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=your_mailtrap_username MAIL_PASSWORD=your_mailtrap_password MAIL_ENCRYPTION=tls ``` ================================================================================ 🎯 QUICK START SUMMARY ================================================================================ ```bash # 1. Initial setup composer install cp .env.example .env php artisan key:generate # 2. Configure .env (database, Redis, SMS, SSLCommerz, mail) # 3. Setup database php artisan migrate php artisan db:seed # 4. Verify php artisan app:verify-setup # 5. Start services (3 terminals) php artisan serve php artisan queue:work redis --queue=send_sms,default php artisan schedule:work # 6. Test php artisan test # 7. Test API # Register user → Get token → Test endpoints ``` ================================================================================ 📚 ADDITIONAL RESOURCES ================================================================================ Laravel Documentation: https://laravel.com/docs/12.x SSLCommerz Integration: https://github.com/sslcommerz/SSLCommerz-Laravel SMS Provider Docs: https://api.sms.net.bd/ Redis Documentation: https://redis.io/docs/ ================================================================================ ✅ BACKEND SETUP COMPLETE ================================================================================ Your backend is now ready! Next step: Build the frontend (see frontend_guide.txt) For support or issues, check: - storage/logs/laravel.log - GitHub Issues: https://github.com/Dev-Majharul/finance-project-shojol/issues ================================================================================