Add Bun/TypeScript backend as exact alternative to Java backend #589
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🎯 Summary
This PR implements issue #565 by creating a complete Bun/TypeScript backend that provides 100% API compatibility with the existing Java/Spring Boot backend, allowing users to easily switch between them.
✨ What's Added
New Directory:
GPTutor-Backend-Bun/A complete reimplementation of the Java backend using modern JavaScript technologies:
🎨 Features Implemented
All features from the Java backend with 100% API compatibility:
Controllers
Middleware/Interceptors
WebSocket
/online🚀 Performance Benefits
📝 Documentation
New Files
GPTutor-Backend-Bun/README.md- Complete setup and usage guideREADME.md- Main repository README with backend switching instructionsGPTutor-Backend-Bun/.env.example- Environment variable templateGPTutor-Backend-Bun/Dockerfile- Docker containerizationUpdated Files
docker-compose-prod.yaml- Added Bun backend option (commented)docker-compose-stage.yaml- Added Bun backend option (commented)docker-compose-dev.yaml- Added Bun backend option (commented)🔄 Switching Between Backends
Method 1: Docker Compose (Recommended)
Edit your
docker-compose-*.yamlfile and swap comments:Use Java Backend (default):
Use Bun Backend:
Then redeploy:
Method 2: Local Development
Java:
cd GPTutor-Backend mvn spring-boot:runBun:
cd GPTutor-Backend-Bun bun install bun run dev🏗️ Architecture
✅ Testing
🔗 Compatibility
Both backends:
📦 Files Changed
GPTutor-Backend-Bun/README.mdTotal: 31 files, 2615 lines added
🎓 Migration Path
No migration required! Steps to switch:
🔍 Key Implementation Details
Authentication
Implements both VK and Telegram Mini Apps auth:
Rate Limiting
Token bucket algorithm with configurable limits:
/imagePOST: 10 req/min/conversation: 6 req/min/vk-doc/conversation: 3 req/minDatabase
Uses
postgres.jsfor PostgreSQL:WebSocket
Native Bun WebSocket:
🙏 Related Issues
Closes #565
📸 Preview
The Bun backend runs on the same port (8080) and provides identical responses:
🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com