A comprehensive AI-powered study assistant platform featuring intelligent chat, file knowledge extraction, and persistent learning history. Built with modern web technologies and powered by OpenAI GPT models.
- π€ AI Study Chat: Interactive conversations with GPT-4/GPT-3.5 models for learning assistance
- π File Knowledge Extraction: Upload study materials and automatically extract structured knowledge points
- π Learning History: Persistent storage and retrieval of all study sessions and extracted knowledge
- π Study Dashboard: Real-time statistics and performance tracking
- π¨ Modern UI: Beautiful, responsive interface built with React + Tailwind CSS
- π Secure & Reliable: Built-in rate limiting, error handling, and data persistence
- π Easy Deployment: Docker containerization support
- Framework: Flask + SQLAlchemy
- Database: SQLite (with auto-migration)
- AI API: OpenAI GPT API
- File Processing: Auto-encoding detection (UTF-8, GBK, GB2312, etc.)
- Deployment: Docker + Gunicorn
- Framework: React 18
- Styling: Tailwind CSS
- Icons: Lucide React
- Routing: React Router
- HTTP Client: Axios
- Notifications: React Hot Toast
- Node.js 16+
- Python 3.8+
- Docker & Docker Compose (optional)
git clone <repository-url>
cd model-fine-tuning-deployment# Copy environment variables file
cp env.example .env
# Edit .env file and add your OpenAI API key
OPENAI_API_KEY=your_api_key_here# Install Python dependencies
pip install -r requirements.txt
# Start backend service (auto-creates database)
python app.py# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm startVisit http://localhost:3000 to access the application.
Clean and intuitive main interface with AI chat for study assistance
Upload study materials and extract structured knowledge points automatically
Browse all uploaded files and extracted knowledge points with search functionality
Real-time statistics and learning analytics with visual charts
# Start all services with one command
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down- Real-time Chat: Interactive conversations with AI for study assistance
- Model Selection: Choose between GPT-4, GPT-3.5 Turbo, and other models
- Conversation History: Intelligent token management and context preservation
- Streaming Responses: Character-by-character streaming for better UX
- Message Actions: Copy, like/dislike responses
- Usage Statistics: Token consumption tracking
- Multi-format Support: txt, md, pdf, doc, docx files
- Auto-encoding Detection: Handles UTF-8, GBK, GB2312, Big5, and more
- Intelligent Chunking: Text splitting while maintaining sentence integrity
- Knowledge Point Extraction: Structured extraction with:
- Title and definition
- Core principles/formulas
- Examples and use cases
- Common pitfalls
- Source citations
- Subject tags
- Batch Processing: Extract knowledge points from multiple chunks
- Real-time Preview: View extraction progress and results
- File Management: View all uploaded files with metadata
- Knowledge Point Browser: Access all extracted knowledge points
- Search & Filter: Find specific content quickly
- Export Functionality: Download knowledge points as JSON
- Statistics Overview: File counts, extraction metrics, activity tracking
- Real-time Statistics: Live data from database
- Performance Metrics: Study sessions, questions asked, response times
- Activity Tracking: Recent study activity and progress
- Learning Analytics: Subject performance and knowledge acquisition trends
- Visual Charts: Interactive graphs and progress indicators
uploaded_file: File metadata, encoding info, chunk countsknowledge_point: Extracted knowledge with full structured data
- Auto-migration: Database tables created automatically on first run
- Persistent Storage: All data survives application restarts
- Relationship Management: Foreign key constraints and cascading deletes
- Encoding Support: Stores file encoding information for future reference
# Streaming chat (recommended)
POST /api/chat-stream
Content-Type: application/json
{
"message": "Explain quantum physics",
"model": "gpt-4",
"conversation_history": [...]
}
# Non-streaming fallback
POST /api/chat
Content-Type: application/json
{
"message": "Explain quantum physics",
"model": "gpt-4"
}# Upload file
POST /api/upload-file
Content-Type: multipart/form-data
# Process file into chunks
POST /api/process-file
Content-Type: application/json
{
"file_id": "uuid-string"
}
# Extract knowledge points
POST /api/extract-knowledge
Content-Type: application/json
{
"chunk_content": "text content",
"chunk_id": "chunk-id",
"chapter_title": "Chapter 1"
}# Get all files
GET /api/files
# Get knowledge points for specific file
GET /api/files/{file_id}/knowledge-points
# Get all knowledge points (paginated)
GET /api/knowledge-points?page=1&per_page=20
# Get statistics
GET /api/stats# Get available models
GET /api/models
# Test streaming
GET /api/test-stream# OpenAI API Configuration
OPENAI_API_KEY=your_openai_api_key_here
# Flask Configuration
FLASK_ENV=production
FLASK_DEBUG=False
# Database Configuration (auto-configured)
SQLALCHEMY_DATABASE_URI=sqlite:///study_assistant.db
# File Upload Configuration
MAX_CONTENT_LENGTH=16777216 # 16MB
UPLOAD_FOLDER=uploads- Chat endpoints: 20 requests/minute
- File upload: 10 requests/hour
- Knowledge extraction: 20 requests/hour
- Global limit: 100 requests/hour
- Supported formats: txt, md, pdf, doc, docx
- Maximum file size: 16MB
- Encoding support: Auto-detection for UTF-8, GBK, GB2312, GB18030, Big5
- Processing: Intelligent text chunking with configurable overlap
- API Key Protection: Secure storage of OpenAI credentials
- Rate Limiting: Multi-tier protection against abuse
- Input Validation: Comprehensive request validation
- File Security: Safe file handling with type validation
- CORS Configuration: Proper cross-origin resource sharing
- Error Sanitization: Safe error message handling
- SQL Injection Protection: SQLAlchemy ORM with parameterized queries
# Backend
pip install -r requirements.txt
python app.py
# Frontend
cd frontend && npm install && npm start# Docker Compose (recommended)
docker-compose up -d
# Manual deployment
# 1. Build frontend
cd frontend && npm run build
# 2. Start backend with production server
gunicorn -w 4 -b 0.0.0.0:5000 app:app- Configure environment variables in
.env - Set up reverse proxy (Nginx recommended)
- Configure SSL certificates
- Set up monitoring and logging
- Configure backup strategy for SQLite database
- Study Q&A: Ask questions about any subject
- Material Processing: Extract key points from textbooks and papers
- Progress Tracking: Monitor learning activity and knowledge acquisition
- Review Sessions: Access historical knowledge points for review
- Content Analysis: Process educational materials for key concepts
- Student Assistance: Provide AI-powered tutoring support
- Curriculum Development: Extract and organize learning objectives
- Assessment Preparation: Generate study materials from source texts
- Literature Review: Extract key points from academic papers
- Knowledge Management: Organize and retrieve research insights
- Collaboration: Share extracted knowledge points with team members
- Documentation: Maintain persistent records of research findings
βββ app.py # Flask backend application
βββ requirements.txt # Python dependencies
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β βββ App.js # Main application
β β βββ index.js # Entry point
β βββ public/ # Static assets
β βββ package.json # Node.js dependencies
βββ uploads/ # File upload storage
βββ study_assistant.db # SQLite database (auto-created)
βββ docker-compose.yml # Container orchestration
- Backend changes: Modify
app.py, restart Flask server - Frontend changes: Edit React components, hot reload enabled
- Database changes: Modify models in
app.py, restart to auto-migrate - API testing: Use built-in test endpoints for debugging
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Make your changes and test thoroughly
- Commit changes:
git commit -m "Add new feature" - Push to branch:
git push origin feature/new-feature - Submit Pull Request
- Follow existing code style and patterns
- Add tests for new functionality
- Update documentation for API changes
- Ensure all features work in both development and production modes
MIT License - see LICENSE file for details.