# AI_English_Tutor **Repository Path**: ZBeeeeeeeeee/AI_English_Tutor ## Basic Information - **Project Name**: AI_English_Tutor - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-07-27 - **Last Updated**: 2026-07-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # AI English Essay Tutor **English** | [中文](README_CN.md) A web application for daily practice and AI-powered grading of postgraduate entrance exam (考研) English essays. ## Features - **Daily Topics**: Auto-generates one big essay and one small essay topic every day - **AI Grading**: Get scores, sentence-by-suggestions, and reference essays upon submission - **Real-time Feedback**: SSE streaming for live grading progress — no refresh needed - **History**: Browse all past submissions and detailed grading results - **Admin Dashboard**: User management, essay records, and token usage charts ## Tech Stack | Layer | Technology | |---|---| | Frontend | Vue 3 + TypeScript + Vite + Element Plus + Pinia + Vue Router | | Backend | FastAPI (ASGI) + SQLAlchemy (async) + Alembic | | Async Tasks | Celery + Redis | | AI | DeepSeek / OpenAI (switchable) + LLM Adapter abstraction layer | | Database | SQLite (dev) → PostgreSQL (prod) | ## Quick Start ### Prerequisites - Python 3.9+ - Node.js 18+ - Docker (for Redis only) ### One-Command Launch (Dev Mode) ```bash ./start-dev.sh start ``` The script automatically: 1. Starts a Redis container 2. Runs database migrations + seeds sample topics 3. Starts FastAPI backend (port 8000) 4. Starts Celery Worker + Beat 5. Starts Vite frontend dev server (port 5173) ### Access | URL | Description | |---|---| | http://localhost:5173 | Frontend app | | http://localhost:8000/docs | Backend API docs (Swagger) | **The first registered user automatically becomes an admin.** ### Configure LLM Edit `backend/.env`: ```env # Use DeepSeek LLM_PROVIDER=deepseek DEEPSEEK_API_KEY=sk-your-key-here # Or use OpenAI LLM_PROVIDER=openai OPENAI_API_KEY=sk-your-key-here OPENAI_MODEL=gpt-4o ``` When no API key is configured, the app falls back to **Mock mode**, returning sample grading data so you can try the full workflow without an API key. ### Other Commands ```bash ./start-dev.sh stop # Stop all services ./start-dev.sh status # Check service status ``` ### Run E2E Tests ```bash cd backend .venv/bin/python e2e_test.py ``` ## Project Structure ``` AI_english_tutor/ ├── backend/ │ ├── app/ │ │ ├── main.py # FastAPI entry │ │ ├── config.py # Configuration │ │ ├── database.py # SQLAlchemy async engine │ │ ├── models/ # 5 data models │ │ ├── schemas/ # Pydantic schemas │ │ ├── api/ # Routes (auth/topics/essays/tasks/admin) │ │ ├── adapters/ # LLM adapter layer (base/deepseek/openai/mock) │ │ ├── agents/ # AI agents (topic generator / essay reviewer) │ │ ├── tasks/ # Celery (worker/beat) │ │ ├── services/ # Business logic │ │ └── utils/ # security/sse/redis │ ├── alembic/ # Database migrations │ ├── seed.py # Seed data │ ├── e2e_test.py # E2E regression tests │ └── requirements.txt ├── frontend/ │ ├── src/ │ │ ├── api/ # Axios wrappers │ │ ├── stores/ # Pinia (auth/topics) │ │ ├── router/ # Vue Router + guards │ │ ├── views/ # Page components │ │ ├── components/ # Layout / business components │ │ └── utils/ # SSE client │ └── vite.config.ts # Vite + proxy config └── start-dev.sh # One-command dev startup script ``` ## Dev Mode: Frontend-Backend Integration The Vite dev server (5173) proxies `/api` requests to the FastAPI backend (8000): ```ts // vite.config.ts server: { proxy: { '/api': { target: 'http://127.0.0.1:8000', changeOrigin: true } } } ``` The backend CORS allows `localhost:5173`, and SSE long-polling connections work seamlessly through the proxy. ## Docker Deployment (PostgreSQL + Nginx) ### Interactive Deploy ```bash ./deploy.sh ``` On first run, an interactive setup wizard will guide you through: 1. Enter the external port (default: 8080) 2. Choose LLM provider (DeepSeek / OpenAI) 3. Enter API key (required, format-validated) 4. JWT secret and database password are auto-generated Configuration is written to `.env.docker` (git-ignored), then containers are built and started. ### Port Configuration Edit `WEB_PORT` in `.env.docker`: ```env WEB_PORT=8080 ``` ### Other Commands ```bash ./deploy.sh stop # Stop services ./deploy.sh restart # Restart services ./deploy.sh logs # View logs ./deploy.sh down # Stop and remove all containers + data ./deploy.sh reconfig # Reconfigure (delete .env.docker, rerun wizard) ./deploy.sh ps # View status ``` ### Manual PostgreSQL Switch (Dev Mode) 1. Update `backend/.env`: ```env DATABASE_URL=postgresql+asyncpg://user:pass@localhost/essay_app ``` 2. Install asyncpg: `pip install asyncpg` 3. Run migrations: `alembic upgrade head` 4. JSON fields automatically map to JSONB