docs: add Section 6 to API_DOCUMENTATION.md - ENV vars, CORS config, email service, SMS roadmap
This commit is contained in:
@@ -1214,3 +1214,85 @@ The platform provides two pre-configured accounts for administration and end-to-
|
|||||||
| **Super Admin** | `admin@pragativeer.com` | `admin123` | Full access to `/admin` management console & question bank |
|
| **Super Admin** | `admin@pragativeer.com` | `admin123` | Full access to `/admin` management console & question bank |
|
||||||
| **AI Coach Student** | `demo@pragativeer.com` | `Pv9#kL2$mQ8!vX4@` | Full AI Coach access (AI Tutor SSE stream, College Predictor, CBT Mock Engine, Spaced Repetition) |
|
| **AI Coach Student** | `demo@pragativeer.com` | `Pv9#kL2$mQ8!vX4@` | Full AI Coach access (AI Tutor SSE stream, College Predictor, CBT Mock Engine, Spaced Repetition) |
|
||||||
|
|
||||||
|
> **Note:** No other accounts are seeded. Any login attempt with a non-registered email returns `401 Unauthorized`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Environment Variables & Infrastructure Configuration
|
||||||
|
|
||||||
|
### 6.1 Backend Environment Variables (`backend/.env`)
|
||||||
|
|
||||||
|
| Variable | Example Value | Purpose |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| `OPENAI_API_KEY` | `6a1b502...` | LLM API key for AI Coach (deferred to Phase 2) |
|
||||||
|
| `LLM_BASE_URL` | `https://ollama.com/v1` | LLM inference endpoint |
|
||||||
|
| `LLM_MODEL_NAME` | `gemma4:31b-cloud` | Model identifier |
|
||||||
|
| `RAZORPAY_KEY_ID` | `rzp_test_XXXXXX` | Razorpay public key (test mode) |
|
||||||
|
| `RAZORPAY_KEY_SECRET` | `your_secret` | Razorpay private key (server-side only) |
|
||||||
|
| `RAZORPAY_WEBHOOK_SECRET` | `your_webhook_secret` | Razorpay webhook signature verification |
|
||||||
|
| `SMTP_HOST` | `smtp.gmail.com` | Transactional email SMTP server |
|
||||||
|
| `SMTP_PORT` | `587` | SMTP TLS port |
|
||||||
|
| `SMTP_USER` | `no-reply@pragativeer.com` | SMTP login username |
|
||||||
|
| `SMTP_PASS` | `app_password_here` | Gmail App Password or SMTP password |
|
||||||
|
| `SMTP_FROM_NAME` | `PragatiVeer` | Display name in sent emails |
|
||||||
|
| `SMTP_FROM_EMAIL` | `no-reply@pragativeer.com` | Reply-to address |
|
||||||
|
| `FRONTEND_URL` | `https://pragativeer.com` | Production frontend domain (CORS & email links) |
|
||||||
|
| `API_URL` | `https://api.pragativeer.com` | Production API domain |
|
||||||
|
| `MINIO_ENDPOINT` | `minio:9000` | MinIO internal endpoint |
|
||||||
|
| `MINIO_ACCESS_KEY` | `minio_admin` | MinIO access key |
|
||||||
|
| `MINIO_SECRET_KEY` | `minio_secure_password` | MinIO secret key |
|
||||||
|
| `MINIO_BUCKET` | `pragativeer-uploads` | Default uploads bucket |
|
||||||
|
| `MINIO_AVATARS_BUCKET` | `avatars` | Avatar image bucket |
|
||||||
|
|
||||||
|
> ⚠️ `backend/.env` is `.gitignore`-listed — **never commit real secrets**. Use `backend/.env.example` as a safe-to-commit template.
|
||||||
|
|
||||||
|
### 6.2 Frontend Environment Variables (`.env.local`)
|
||||||
|
|
||||||
|
| Variable | Example Value | Purpose |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| `NEXT_PUBLIC_RAZORPAY_KEY_ID` | `rzp_test_XXXXXX` | Razorpay public key (exposed to browser) |
|
||||||
|
| `NEXT_PUBLIC_API_URL` | `http://localhost:8000` | Backend API base URL |
|
||||||
|
| `NEXT_PUBLIC_PAYMENT_GATEWAY` | `razorpay` | Payment provider identifier |
|
||||||
|
|
||||||
|
> ⚠️ `.env.local` is `.gitignore`-listed. Only `NEXT_PUBLIC_*` variables are safe to expose to the browser.
|
||||||
|
|
||||||
|
### 6.3 CORS Configuration
|
||||||
|
|
||||||
|
The backend accepts requests from these origins (configured in `backend/main.py`):
|
||||||
|
|
||||||
|
| Origin | Environment |
|
||||||
|
| :--- | :--- |
|
||||||
|
| `http://localhost:3000` | Local development |
|
||||||
|
| `http://127.0.0.1:3000` | Local development |
|
||||||
|
| `https://pragativeer.com` | Production |
|
||||||
|
| `https://www.pragativeer.com` | Production (www redirect) |
|
||||||
|
| `https://api.pragativeer.com` | Production API-to-API |
|
||||||
|
|
||||||
|
### 6.4 Email Service (`backend/email_service.py`)
|
||||||
|
|
||||||
|
Transactional emails are dispatched via `email_service.py` using `smtplib`:
|
||||||
|
|
||||||
|
| Trigger | Template Function | Email Subject |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| New user registration | `send_welcome_email(to, name)` | "🎉 Welcome to PragatiVeer — Your JEE/NEET Journey Starts Now!" |
|
||||||
|
| Login/verification OTP | `send_otp_email(to, otp, purpose)` | "PragatiVeer: Your Verification OTP" |
|
||||||
|
| Password reset | `send_password_reset_email(to, reset_link)` | "PragatiVeer: Reset Your Password" |
|
||||||
|
|
||||||
|
> **Fallback behavior:** If `SMTP_HOST`, `SMTP_USER`, or `SMTP_PASS` are not set, the service logs the email to console and returns `True` (no-op mode). This prevents boot failures in staging environments.
|
||||||
|
|
||||||
|
### 6.5 SMS / Phone OTP (Pending)
|
||||||
|
|
||||||
|
SMS delivery is ready for integration. Variables are defined but commented out in `.env` pending DLT sender ID registration:
|
||||||
|
|
||||||
|
```
|
||||||
|
SMS_PROVIDER=fast2sms
|
||||||
|
SMS_API_KEY=your_api_key
|
||||||
|
SMS_DLT_SENDER_ID=PVREDU
|
||||||
|
SMS_DLT_TEMPLATE_ID=your_template_id
|
||||||
|
```
|
||||||
|
|
||||||
|
Once DLT registration completes, implement `sms_service.py` following the same pattern as `email_service.py`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Document last updated: September 2026*
|
||||||
|
|||||||
Reference in New Issue
Block a user