
- 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
1.9 KiB
1.9 KiB
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
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the development server:
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 userPOST /auth/login
- Login and get access tokenGET /auth/me
- Get current user profile
Tutor Sessions
POST /tutor/sessions
- Create a new tutor sessionGET /tutor/sessions
- Get all user sessionsGET /tutor/sessions/{session_id}
- Get specific sessionPUT /tutor/sessions/{session_id}
- Update sessionPOST /tutor/sessions/{session_id}/messages
- Add message to sessionGET /tutor/sessions/{session_id}/messages
- Get session messages
Health
GET /health
- Health check endpointGET /
- Service information
Database
The application uses SQLite database stored at /app/storage/db/db.sqlite
. The database includes:
users
- User accountstutor_sessions
- Tutoring sessionstutor_messages
- Messages within sessions
Development
To run in development mode:
uvicorn main:app --reload --host 0.0.0.0 --port 8000