An AI-powered research assistant that lets you create persistent chat sessions, upload documents, and query GPT models in real time. Built with FastAPI, Svelte, MySQL, and Redis.
/ trigger special handlersResearchGPT/
āāā server/ # Python / FastAPI backend
ā āāā app/ # HTTP routes, WebSocket endpoint, middleware, auth
ā āāā database/ # SQLAlchemy (MySQL) models, Redis client, repository layer
ā āāā gpt/ # LLM integration, streaming, document embeddings, commands
ā āāā nginx/ # Reverse-proxy config and Dockerfile
ā āāā main.py # Application entry point
ā āāā docker-compose.yaml
ā āāā pyproject.toml
āāā client/ # Svelte / TypeScript frontend
āāā src/
āāā lib/pages/ # Home and Assistant pages
āāā lib/components/ # Chat UI, message display, visualizations
āāā lib/views/ # Articles, Journals, Authors, Resources
āāā lib/apis/ # HTTP + WebSocket API calls
Backend services (via Docker Compose)
| Service | Role | Port |
|---|---|---|
api |
FastAPI HTTP server | 8000 |
ws |
FastAPI WebSocket worker | 8001 |
web |
Nginx reverse proxy + SSL | 80 / 443 |
database |
MySQL | 3306 |
cache |
Redis (session cache + vector store) | 6379 |
certbot |
Let's Encrypt certificate renewal | ā |
HTTP traffic routes to api; WebSocket connections (/ws/) route to the dedicated ws worker.
Server
Client
cd server
poetry install
cp config/.env.example config/.env
Edit config/.env and fill in at minimum:
OPENAI_API_KEY=sk-...
JWT_SECRET=<random secret>
MYSQL_HOST=localhost
MYSQL_USER=admin
MYSQL_PASSWORD=...
MYSQL_DATABASE=researchgpt
REDIS_HOST=localhost
REDIS_PASSWORD=...
Use the VSCode Run and Debug panel (a launch.json is included). On successful startup you should see:
INFO: Started server process [...]
INFO: Waiting for application startup.
FastAPI:CRITICAL - MySQL DB connected!
FastAPI:CRITICAL - Redis CACHE connected!
INFO: Application startup complete.
Verify with:
curl http://127.0.0.1:8000
# {"message":"Server is running..."}
# Issue SSL certificates
sudo chmod +x server/certbot.sh && sudo ./server/certbot.sh
# Start all services
sudo docker-compose --env-file server/config/.env up -d --build --remove-orphans
# View logs
sudo docker exec -it researchgpt_api_1 cat log/app.log
# Tear down and clean up
sudo docker-compose --env-file server/config/.env down && sudo docker system prune --force --all
Set CERTBOT_EMAIL and CERTBOT_DOMAIN in your .env before running certbot.
cd client
npm install
npm run dev # dev server at http://localhost:8080
npm run build # output in dist/
Other scripts: npm run lint, npm run check, npm run format.
| Variable | Description |
|---|---|
HOST_MAIN |
Allowed CORS origin (your frontend URL) |
DEBUG_MODE |
1 for debug logging, 0 for production |
JWT_SECRET |
Secret used to sign JWTs |
OPENAI_API_KEY |
OpenAI API key |
DEFAULT_LLM_MODEL |
gpt_4 or gpt_3_5_turbo |
MYSQL_HOST |
MySQL hostname |
MYSQL_USER |
MySQL username |
MYSQL_PASSWORD |
MySQL password |
MYSQL_PORT |
MySQL port (default 3306) |
MYSQL_DATABASE |
Database name |
REDIS_HOST |
Redis hostname |
REDIS_PORT |
Redis port (default 6379) |
REDIS_DB |
Redis database index |
REDIS_PASSWORD |
Redis password |
REDIS_USER |
Redis username (default default) |
CERTBOT_EMAIL |
Email for Let's Encrypt registration |
CERTBOT_DOMAIN |
Domain for SSL certificate |
See server/config/.env.example for the full template.