Automated Action 07f6a51f6f Add complete FastAPI backend for AI tutor application
- User authentication with JWT tokens (register/login)
- Tutor session management with CRUD operations
- Message tracking for tutor conversations
- SQLite database with Alembic migrations
- CORS configuration for frontend integration
- Health check and service info endpoints
- Proper project structure with models, schemas, and API routes
2025-06-23 17:55:19 +00:00

78 lines
1.9 KiB
Markdown

# AI Tutor Backend Service
A FastAPI-based backend service for an AI-powered tutoring application.
## Features
- User authentication (register/login with JWT tokens)
- Tutor session management
- Message tracking for tutor conversations
- SQLite database with Alembic migrations
- CORS enabled for frontend integration
- Health check endpoint
## Environment Variables
Copy `.env.example` to `.env` and set the following variables:
- `SECRET_KEY`: JWT secret key for token generation (required for production)
## Installation
1. Install dependencies:
```bash
pip install -r requirements.txt
```
2. Run database migrations:
```bash
alembic upgrade head
```
3. Start the development server:
```bash
uvicorn main:app --reload
```
The API will be available at `http://localhost:8000`
## API Documentation
- Swagger UI: `http://localhost:8000/docs`
- ReDoc: `http://localhost:8000/redoc`
- OpenAPI JSON: `http://localhost:8000/openapi.json`
## API Endpoints
### Authentication
- `POST /auth/register` - Register a new user
- `POST /auth/login` - Login and get access token
- `GET /auth/me` - Get current user profile
### Tutor Sessions
- `POST /tutor/sessions` - Create a new tutor session
- `GET /tutor/sessions` - Get all user sessions
- `GET /tutor/sessions/{session_id}` - Get specific session
- `PUT /tutor/sessions/{session_id}` - Update session
- `POST /tutor/sessions/{session_id}/messages` - Add message to session
- `GET /tutor/sessions/{session_id}/messages` - Get session messages
### Health
- `GET /health` - Health check endpoint
- `GET /` - Service information
## Database
The application uses SQLite database stored at `/app/storage/db/db.sqlite`. The database includes:
- `users` - User accounts
- `tutor_sessions` - Tutoring sessions
- `tutor_messages` - Messages within sessions
## Development
To run in development mode:
```bash
uvicorn main:app --reload --host 0.0.0.0 --port 8000
```