================================================================================
                         QUICK START GUIDE - SUI API
================================================================================

Created: 27 Mei 2026
API URL: https://sui.akfo.cc/api

================================================================================
1. PROJECT FILES
================================================================================

✓ api.php
  Main application file. Handles routing dan request dispatching untuk semua
  endpoints (users, products, notifications, logs)

✓ config/database.php
  Database configuration dan koneksi ke MySQL remote. Auto-create tables saat
  first run.

✓ models/User.php
  User model dengan CRUD operations

✓ models/Product.php
  Product model dengan CRUD operations

✓ models/Notification.php
  Notification model - untuk menyimpan push notifications dari Flask app

✓ models/Log.php
  Log model - untuk menyimpan activity logs dari aplikasi

✓ helpers/Response.php
  Helper class untuk standardized JSON responses

✓ .htaccess
  URL rewriting configuration untuk Apache (API routing)

✓ test_connection.php
  Script untuk test koneksi database dan lihat struktur tabel

✓ tutorial.txt ⭐
  LENGKAP dengan:
  - Penjelasan database structure
  - Semua API endpoints
  - Client integration examples
  - HTTP service class
  - User client code tips
  - Testing guide
  - Best practices & troubleshooting

✓ README.md
  Project overview, endpoints summary, setup guide

✓ API_EXAMPLES.txt
  Contoh request & response untuk semua endpoints

================================================================================
2. DATABASE INFORMATION
================================================================================

Host: ftp.akfo.cc
Port: 3306
Username: akfomyid_sui
Password: sui029060
Database: akfomyid_sui

Tables yang digunakan:
- users (existing)
- products (existing)
- sui_notifications (existing - 8 records)
- sui_logs (existing - 43 records)

================================================================================
3. API ENDPOINTS SUMMARY
================================================================================

Base URL: https://sui.akfo.cc/api

NOTIFICATIONS:
  GET    /notifications              - Get all
  GET    /notifications?sui_id=1     - Get by user
  GET    /notifications/:id          - Get specific
  POST   /notifications              - Create
  PUT    /notifications/:id          - Update
  DELETE /notifications/:id          - Delete

LOGS:
  GET    /logs                       - Get all
  GET    /logs?sui_id=1              - Get by user
  GET    /logs/:id                   - Get specific
  POST   /logs                       - Create
  PUT    /logs/:id                   - Update
  DELETE /logs/:id                   - Delete

USERS:
  GET    /users                      - Get all
  GET    /users/:id                  - Get specific
  POST   /users                      - Create
  PUT    /users/:id                  - Update
  DELETE /users/:id                  - Delete

PRODUCTS:
  GET    /products                   - Get all
  GET    /products/:id               - Get specific
  POST   /products                   - Create
  PUT    /products/:id               - Update
  DELETE /products/:id               - Delete

HEALTH CHECK:
  GET    /health                     - API status

================================================================================
4. SETUP INSTRUCTIONS
================================================================================

A. Upload ke Server:
   1. Pastikan folder sui_api sudah upload ke public_html
   2. Folder structure harus tetap sama (config/, models/, helpers/)
   3. Make sure .htaccess can execute (a2enmod rewrite)

B. Test Koneksi:
   $ php /path/to/sui_api/test_connection.php
   
   Expected output:
   ✓ Database Connected Successfully!
   ✓ Available tables: access, products, sui_logs, sui_notifications, users
   ✓ sui_notifications: 8 records
   ✓ sui_logs: 43 records

C. Test API:
   $ curl https://sui.akfo.cc/api/health
   
   Expected response:
   {
     "status": "success",
     "code": 200,
     "data": {
       "status": "success",
       "message": "API is running"
     }
   }

================================================================================
5. CLIENT INTEGRATION
================================================================================

API ini dapat digunakan oleh aplikasi Android/Kotlin, iOS/Swift, web, atau aplikasi lain
yang mendukung HTTP dan JSON.

A. Client libraries:
   - Android: OkHttp, Retrofit, Volley
   - Kotlin: HttpURLConnection, ktor-client
   - iOS: URLSession, Alamofire
   - Web: fetch, Axios

B. Example usage:
   - GET all notifications: /api/notifications
   - GET by user: /api/notifications?sui_id=1
   - POST create notification: JSON body
   - POST create log: JSON body

C. Notes:
   - Kirim header Content-Type: application/json
   - Gunakan `sui_id` sebagai user identifier untuk notifications/logs
   - Endpoint bersifat RESTful dan bisa dipanggil dari semua platform

D. Detailed request examples dan client guide ada di `tutorial.txt`

================================================================================
6. KEY FEATURES
================================================================================

✓ RESTful API endpoints untuk notifications & logs
✓ MySQL remote database connection
✓ Auto table creation on first run
✓ CORS enabled untuk cross-origin requests
✓ Standardized JSON response format
✓ Error handling & validation
✓ Timestamps dalam milliseconds
✓ Pagination support (limit & offset)
✓ Query filtering (sui_id parameter)
✓ Complete client integration guide

================================================================================
7. BEST PRACTICES
================================================================================

Notifications:
- Selalu kirim dengan sui_id (user ID)
- Gunakan unique notification_key untuk prevent duplicates
- Store post_time dalam milliseconds
- Include package name untuk track source

Logs:
- Log semua user actions penting
- Gunakan descriptive messages
- Include timestamp untuk analysis
- Keep messages singkat dan clear

API Usage:
- Implementasi error handling
- Cache data lokal untuk offline
- Validate input sebelum send
- Use pagination untuk large datasets

================================================================================
8. TROUBLESHOOTING
================================================================================

Connection Failed:
- Check MySQL credentials
- Verify host ftp.akfo.cc accessible
- Test dengan: php test_connection.php

404 Not Found:
- Check .htaccess is enabled (a2enmod rewrite)
- Verify endpoint path correct
- Check API base URL in your mobile client

CORS Error:
- CORS sudah enabled di API
- Check request headers
- Verify Content-Type: application/json

JSON Error:
- Validate JSON format
- Check request body is valid JSON
- Use jsonencode/jsonparse properly

================================================================================
9. FILE CHECKLIST
================================================================================

Before deployment:
☐ api.php - Main router
☐ config/database.php - Database config
☐ models/User.php - User model
☐ models/Product.php - Product model
☐ models/Notification.php - Notification model
☐ models/Log.php - Log model
☐ helpers/Response.php - Response helper
☐ .htaccess - URL rewriting
☐ test_connection.php - Connection test (optional)
☐ tutorial.txt - Complete guide
☐ README.md - Documentation
☐ API_EXAMPLES.txt - Example responses

After deployment:
☐ Test connection dengan test_connection.php
☐ Test endpoints dengan curl
☐ Check .htaccess working
☐ Verify CORS enabled
☐ Test dengan client app

================================================================================
10. DEVELOPMENT NOTES
================================================================================

Database:
- Tables auto-created dari database.php
- Timestamps in milliseconds (JS convention)
- Auto-increment IDs
- Prepared statements untuk security

Models:
- CRUD operations di setiap model
- Parameterized queries untuk prevent SQL injection
- Error handling dan validation
- Return formats consistent

API:
- RESTful pattern (GET, POST, PUT, DELETE)
- Consistent error responses
- HTTP status codes proper
- CORS headers automatic

Client:
- HTTP client class untuk reusable code
- Local storage dengan SharedPreferences atau data store client lain
- Error handling & user feedback
- Example implementations provided

================================================================================
11. NEXT STEPS
================================================================================

1. Upload project ke server: sui.akfo.cc
2. Run test_connection.php untuk verify
3. Test endpoints dengan curl/Postman
4. Implement in client app menggunakan tutorial.txt
5. Test di emulator/device
6. Deploy app

================================================================================

Untuk pertanyaan atau support:
- Check tutorial.txt untuk detail
- Check API_EXAMPLES.txt untuk contoh responses
- Check README.md untuk overview

Good luck! 🚀

================================================================================
