EduStream is a powerful backend API for a virtual teaching assistant platform that helps teachers manage educational materials, generate AI-powered content, perform OCR on student work, and track student analytics.
- Authentication: JWT-based authentication with access and refresh tokens
- Material Management: Upload and process PDF/DOCX files with automatic text extraction
- AI-Powered Generation:
- Generate summaries and glossaries from educational materials
- Create quiz questions automatically with configurable difficulty
- OCR Processing: Recognize text from images of student work
- Analytics Dashboard: Track student performance and visualize knowledge maps
- Privacy-First: No biometric data storage, anonymized student data
- Asynchronous: Built for efficient handling of long-running AI/OCR operations
- API Documentation: Auto-generated Swagger UI at
/docs
- Framework: FastAPI 0.109.0
- Database: PostgreSQL with SQLAlchemy ORM
- Migrations: Alembic
- Authentication: JWT with bcrypt password hashing
- AI Integration: OpenAI API (GPT-3.5-turbo)
- OCR: Tesseract OCR with Russian and English support
- File Processing: pypdf, python-docx
- Testing: Pytest with async support
- Containerization: Docker & Docker Compose
EduStream/
βββ app/
β βββ api/
β β βββ v1/
β β β βββ endpoints/
β β β β βββ auth.py # Authentication endpoints
β β β β βββ materials.py # Material management
β β β β βββ ai.py # AI generation endpoints
β β β β βββ ocr.py # OCR processing
β β β β βββ analytics.py # Analytics endpoints
β β β βββ router.py # API router
β β βββ dependencies.py # Auth dependencies
β βββ core/
β β βββ config.py # Configuration
β β βββ database.py # Database setup
β β βββ security.py # Security utilities
β βββ models/
β β βββ models.py # SQLAlchemy models
β βββ schemas/
β β βββ schemas.py # Pydantic schemas
β βββ services/
β β βββ ai_service.py # AI integration
β β βββ ocr_service.py # OCR processing
β β βββ file_processor.py # File handling
β βββ main.py # FastAPI application
βββ alembic/
β βββ versions/ # Migration scripts
β βββ env.py # Alembic environment
βββ tests/
β βββ conftest.py # Test configuration
β βββ test_main.py # Main app tests
β βββ test_auth.py # Auth tests
βββ docker-compose.yml # Docker services
βββ Dockerfile # Application container
βββ requirements.txt # Python dependencies
βββ .env.example # Environment template
βββ README.md
- Teachers and admins with JWT authentication
- Email/password login with bcrypt hashing
- Educational content with extracted text
- AI-generated summaries and glossaries
- File storage references
- AI-generated questions (MCQ and Open)
- Linked to materials
- Performance tracking by student identifier
- Weak topics identification
- Score percentages
- Session-based chat logging
- AI-analyzed FAQ and activity reports
- Python 3.10+
- PostgreSQL
- Docker & Docker Compose (optional)
- Clone the repository
git clone https://github.com/Barleennn/EduStream.git
cd EduStream- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Configure environment
cp .env.example .env
# Edit .env with your configuration- Setup database
# Create PostgreSQL database
createdb edustream_db
# Run migrations
alembic upgrade head- Run the application
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000
- Configure environment
cp .env.example .env
# Edit .env if needed- Start services
docker-compose up -dThe API will be available at http://localhost:8000
POST /register- Register new teacher/adminPOST /login- Login and get JWT tokensPOST /refresh- Refresh access token
POST /upload- Upload PDF/DOCX fileGET /{material_id}- Get material by IDGET /- List all materials
POST /generate-summary- Generate summary and glossaryPOST /generate-quiz- Generate quiz questions
POST /recognize- Recognize text from image
GET /dashboard- Get dashboard statisticsGET /knowledge-map- Get knowledge map data
Required environment variables (see .env.example):
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/edustream_db
# JWT
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
REFRESH_TOKEN_EXPIRE_DAYS=7
# OpenAI
OPENAI_API_KEY=your-openai-api-key
# Server
HOST=0.0.0.0
PORT=8000
DEBUG=True
# Upload limits and public frontend URL for share links
MAX_UPLOAD_SIZE=10485760
FRONTEND_BASE_URL=https://edu-stream-mu.vercel.app
# CORS
CORS_ORIGINS=http://localhost:3000,http://localhost:8000Run tests with pytest:
# Run all tests
pytest
# Run with coverage
pytest --cov=app
# Run specific test file
pytest tests/test_auth.py
# Run with verbose output
pytest -vOnce the server is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
# Register
curl -X POST "http://localhost:8000/api/v1/auth/register" \
-H "Content-Type: application/json" \
-d '{
"email": "teacher@example.com",
"password": "SecurePassword123",
"role": "teacher"
}'
# Login
curl -X POST "http://localhost:8000/api/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{
"email": "teacher@example.com",
"password": "SecurePassword123"
}'curl -X POST "http://localhost:8000/api/v1/materials/upload" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-F "file=@/path/to/document.pdf"curl -X POST "http://localhost:8000/api/v1/ai/generate-summary" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"material_id": "MATERIAL_UUID"
}'curl -X POST "http://localhost:8000/api/v1/ai/generate-quiz" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"material_id": "MATERIAL_UUID",
"num_questions": 5,
"difficulty": "medium"
}'- Password Hashing: Bcrypt for secure password storage
- JWT Tokens: Separate access and refresh tokens
- CORS: Configurable CORS origins
- Input Validation: Pydantic schemas for all endpoints
- SQL Injection Protection: SQLAlchemy ORM
- Privacy-First: No biometric data storage
Logs are configured with Loguru:
- Console output with color formatting
- File rotation (500 MB)
- 10-day retention
- Logs stored in
logs/app.log
Follow PEP 8 Python style guidelines.
# Create a new migration
alembic revision --autogenerate -m "Description"
# Apply migrations
alembic upgrade head
# Rollback migration
alembic downgrade -1This project is part of the EduStream platform.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions, please open an issue in the GitHub repository.