File size: 3,646 Bytes
be6ee20 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
---
title: Edu-AI Backend
emoji: π
colorFrom: blue
colorTo: indigo
sdk: docker
app_file: main.py
pinned: false
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
=======
>>>>>>> c230b89d102cae6b52dc586eb3f313b093b6d894
# π Edu-AI Backend
Welcome to the **Edu-AI Prop Firm Backend**, a robust and scalable API powered by **FastAPI** and **Google Gemini AI**. This backend serves as the core intelligence engine for the Edu-AI mobile application, handling everything from AI-driven mentorship to dynamic quiz generation.
## π Live on Hugging Face
<<<<<<< HEAD
This backend is hosted on **Hugging Face Spaces** using Docker, providing a global endpoint for the mobile app while maintaining a stateful connection to a cloud database.
=======
This backend is designed to be hosted on **Hugging Face Spaces** using Docker, providing a global endpoint for the mobile app while maintaining a stateful connection to a cloud database.
>>>>>>> c230b89d102cae6b52dc586eb3f313b093b6d894
---
## βοΈ Tech Stack
- **Framework:** FastAPI (Python 3.10+)
- **AI Engine:** Google Gemini (Generative AI) with intelligent key rotation.
- **Database:** PostgreSQL (Cloud-hosted via **Neon.tech**) with local SQLite fallback.
- **ORM:** SQLAlchemy 2.0
- **Deployment:** Docker on Hugging Face Spaces.
---
## β¨ Key Features
- **AI Socratic Mentor:** Context-aware chat system that adopts specific educational personas.
- **Dynamic Quiz Engine:** Generates personalized multiple-choice quizzes based on the student's level and active units.
- **Performance Analytics:** Tracks student "PnL" (Performance & Learning) and provides strategic recommendations.
- **Unit Management:** Allows students to organize their curriculum and focus areas.
- **Fault Tolerance:** Built-in Gemini API key rotation to handle rate limits and quotas automatically.
---
## π οΈ Environment Variables
<<<<<<< HEAD
To run this project, you must configure the following secrets/environment variables in your Space settings:
=======
To run this project, you must configure the following secrets/environment variables:
>>>>>>> c230b89d102cae6b52dc586eb3f313b093b6d894
| Variable | Description |
| :--- | :--- |
| `DATABASE_URL` | Neon.tech PostgreSQL connection string. |
| `GEMINI_API_KEY_1` | Primary Google Gemini API Key. |
| `GEMINI_API_KEY_2` | Secondary Key (for rotation/failover). |
| `GEMINI_API_KEY_N` | Additional keys as needed. |
---
## ποΈ Local Setup
1. **Clone the repository:**
```bash
git clone <your-repo-url>
cd backend
```
2. **Create a Virtual Environment:**
```bash
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
```
3. **Install Dependencies:**
```bash
pip install -r requirements.txt
```
4. **Run the Server:**
```bash
uvicorn main:app --reload
```
---
## π Database Migration
To sync your local SQLite data to the cloud (Neon.tech):
```bash
python migrate_data.py
```
---
## π‘ API Endpoints (Snapshot)
- `GET /`: Health check.
- `GET /api/user/{user_id}/dashboard`: Fetch comprehensive student stats.
- `POST /api/ai/chat`: Interact with the AI Mentor.
- `POST /api/ai/quiz`: Generate a new assessment.
- `POST /api/quiz/record`: Save quiz performance to history.
---
<<<<<<< HEAD
=======
## π‘οΈ Robots & Security
- `GET /robots.txt`: Configured to prevent unauthorized crawling of API endpoints.
- **CORS:** Pre-configured for cross-origin requests from the Edu-AI mobile app.
---
>>>>>>> c230b89d102cae6b52dc586eb3f313b093b6d894
**Built with β€οΈ for the next generation of learners.**
|