Skip to content

muris11/FastAPI_AIStudyPlanner

Repository files navigation

# AI Study Planner – FastAPI v2 ## Set## Integrasi dengan Laravel (cPanel) API ini dirancang untuk diintegrasikan dengan aplikasi Laravel yang dihosting di cPanel dengan domain `aistudyplanner.getmuris.my.id`. ### Konfigurasi Environment: #### Development (.env): ``` CORS_ORIGINS=http://127.0.0.1:8000,http://localhost:8000,https://aistudyplanner.getmuris.my.id ``` #### Production (Render): ```` CORS_ORIGINS=https://aistudyplanner.getmuris.my.id ```Lokal ```bash python -m venv .venv # Windows .venv\Scripts\activate # macOS/Linux # source .venv/bin/activate pip install -r requirements.txt copy .env.example .env # sesuaikan jika perlu uvicorn main:app --host 127.0.0.1 --port 8001 --reload ```` Cek: http://127.0.0.1:8001/health ## Deployment ke Vercel ### Persiapan 1. Pastikan repository sudah di-push ke GitHub 2. File `vercel.json` dan `api/index.py` sudah dibuat ### Langkah Deploy 1. Kunjungi [vercel.com](https://vercel.com) 2. Klik **"New Project"** 3. Connect GitHub repository: `FastAPI_AIStudyPlanner` 4. Konfigurasi: - **Framework Preset:** Other - **Root Directory:** `./` (default) - **Build Command:** `pip install -r requirements.txt` - **Output Directory:** (biarkan kosong) 5. **Environment Variables:** - `AI_TOKEN`: `aiplanner_110205` - `CORS_ORIGINS`: `https://aistudyplanner.getmuris.my.id` 6. Klik **"Deploy"** ### Testing Setelah deploy, Anda akan mendapat URL seperti: `https://fastapi-ai-study-planner.vercel.app` Test API: ```bash curl https://fastapi-ai-study-planner.vercel.app/health # Expected: {"ok": true} ``` ## Integrasi dengan Laravel (cPanel) API ini dirancang untuk diintegrasikan dengan aplikasi Laravel yang dihosting di cPanel dengan domain `aiplanner.getmuris.my.id`. ### Konfigurasi Laravel: Pastikan di Laravel Anda mengirim header `X-AI-TOKEN: aiplanner_110205` saat request ke API endpoints `/plan/*`. #### Contoh implementasi di Laravel: Lihat file `laravel-integration-example.php.txt` untuk contoh lengkap controller Laravel yang siap digunakan. **Setup di Laravel (.env):** ``` AI_PLANNER_API_URL=https://your-render-app-url.onrender.com ``` **Routes di Laravel (web.php atau api.php):** ```php Route::post('/api/study-planner/score', [StudyPlannerController::class, 'scoreTasks']); Route::post('/api/study-planner/schedule', [StudyPlannerController::class, 'generateSchedule']); Route::post('/api/study-planner/coach', [StudyPlannerController::class, 'generateCoach']); Route::get('/api/study-planner/health', [StudyPlannerController::class, 'healthCheck']); ``` ### Endpoint API yang tersedia: - `POST /plan/score` - Scoring prioritas tugas - `POST /plan/schedule` - Generate jadwal belajar - `POST /plan/coach` - Generate coaching plan - `POST /plan/replan` - Replan untuk multiple users - `GET /health` - Health check ## Keamanan - Set `AI_TOKEN` di environment variables, kirim header `X-AI-TOKEN: aiplanner_110205` dari Laravel. - CORS diatur via `CORS_ORIGINS` untuk mengizinkan: - Development: `http://127.0.0.1:8000`, `http://localhost:8000` - Production: `https://aistudyplanner.getmuris.my.id` # FastAPI_AIStudyPlanner

Releases

No releases published

Packages

No packages published