A FastAPI backend for language learning, featuring authentication, AI prompt integration, and file upload support.
- User registration and login with JWT authentication
- Protected routes
- AI prompt endpoint (OpenAI integration)
- File upload endpoint
- Python 3.11+
- MySQL server
- requirements.txt dependencies
-
Clone the repository
git clone <your-repo-url> cd languge_backend
-
Create and activate a virtual environment
python -m venv venv venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Configure environment variables
- Create a
.envfile inlanguge_backend/app/(see .gitignore). - Add your OpenAI API key and any other secrets:
OPENAI_API_KEY=your_openai_api_key
- Create a
-
Configure the database
- Update the MySQL connection string in app/database.py if needed.
- Ensure your MySQL server is running and the database (
languageapp_db) exists.
-
Run the server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
-
API Endpoints
- Auth:
/auth/register,/auth/login - Protected:
/protected/ - AI Prompt:
/ai-prompt/ - File Upload:
/files/upload
- Auth:
- Uploaded files are saved in the
uploads/directory. - The OpenAI API key must be set in your environment or
.envfile. - For development, use the
--reloadflag withuvicorn.
MIT