No description
- TypeScript 96.5%
- Makefile 1.4%
- Dockerfile 0.9%
- CSS 0.8%
- JavaScript 0.4%
| backend | ||
| frontend | ||
| .env.example | ||
| .gitignore | ||
| DB.md | ||
| docker-compose.yml | ||
| DOCKER.md | ||
| DOCKER_QUICKFIX.md | ||
| DOCKER_SUMMARY.md | ||
| DOCKER_TROUBLESHOOTING.md | ||
| Makefile | ||
| PROJECT_STRUCTURE.md | ||
| PROJECT_SUMMARY.md | ||
| QUICKSTART.md | ||
| README.md | ||
GPRX - Proxy Management System
Full-stack application untuk mengelola proxy, subscriptions, servers, models, dan user keys dengan UI modern.
🏗️ Architecture
gprx-ui/
├── backend/ # Bun + Hono REST API
│ ├── PostgreSQL # Primary database
│ └── Redis # Cache layer
│
└── frontend/ # React + Vite SPA
└── TailwindCSS # Styling
✨ Features
Backend (Bun + Hono)
- ✅ REST API dengan JWT authentication
- ✅ PostgreSQL untuk data storage
- ✅ Redis untuk caching
- ✅ Enkripsi API key (AES-256-GCM)
- ✅ Password hashing (SHA-256)
- ✅ CRUD untuk semua entities
- ✅ Pagination untuk logs
- ✅ Database migration & seeding
Frontend (React + Vite)
- ✅ Modern React 18 dengan TypeScript
- ✅ TailwindCSS untuk styling
- ✅ TanStack Query untuk data fetching
- ✅ Zustand untuk state management
- ✅ Protected routes dengan JWT
- ✅ Responsive design
- ✅ Real-time notifications
🚀 Quick Start
Option 1: Docker (Recommended)
Prerequisites:
- Docker 20.10+
- Docker Compose 2.0+
- PostgreSQL 15+ (external)
- Redis 7+ (external)
# 1. Setup environment
cp .env.example .env
# Edit .env dengan konfigurasi PostgreSQL dan Redis Anda
# 2. Run migration (one-time)
cd backend
bun install
bun run migrate
cd ..
# 3. Start services
docker-compose up -d
# 4. Access application
# Frontend: http://localhost
# Backend: http://localhost:3000
Using Makefile:
make build # Build images
make up # Start services
make logs # View logs
make down # Stop services
Lihat DOCKER.md untuk dokumentasi lengkap Docker.
Option 2: Manual Setup
Prerequisites:
- Bun (untuk backend)
- Node.js 18+ (untuk frontend)
- PostgreSQL 15+
- Redis 7+
1. Setup Backend
# Navigate to backend
cd backend
# Install dependencies
bun install
# Setup environment
cp .env.example .env
# Edit .env dengan konfigurasi database Anda
# Create database
psql -U postgres -c "CREATE DATABASE gprx;"
# Run migration
bun run migrate
# Seed sample data
bun run seed
# Start backend
bun run dev
Backend akan running di http://localhost:3000
2. Setup Frontend
# Navigate to frontend
cd frontend
# Install dependencies
npm install
# Setup environment
cp .env.example .env
# Start frontend
npm run dev
Frontend akan running di http://localhost:5173
3. Login
Buka browser dan akses http://localhost:5173
Default credentials:
Username: admin
Password: admin123
📚 Documentation
Backend
- Backend README - Dokumentasi lengkap
- Backend Quick Start - Panduan cepat
- API Testing Guide - Testing API
- Project Structure - Struktur project
- Build Summary - Ringkasan build
Frontend
- Frontend README - Dokumentasi lengkap
- Frontend Quick Start - Panduan cepat
- Build Summary - Ringkasan build
🗄️ Database Schema
Tables
- users - User accounts
- subscriptions - Subscription plans
- servers - Upstream LLM servers
- models - Model mappings
- subs_servers - Subscription-server links
- user_keys - User API keys
- logs - Request logs (partitioned)
Lihat DB.md untuk detail lengkap schema.
🎯 Features by Module
Users Management
- Create, read, update, delete users
- Soft delete support
- Active/inactive status
- Password management
Subscriptions Management
- CRUD subscriptions
- Credit limits (daily, weekly, max)
- Price management
- Duration settings
Servers Management
- CRUD servers
- Encrypted API key storage
- View decrypted API keys
- Weight & concurrency settings
Models Management
- CRUD models
- Link models to subscriptions
- Context & output limits
- Credit multiplier
User Keys Management
- Generate API keys
- View key prefix
- Reset usage credits
- Credit tracking
- Expiration management
Logs Viewer
- Paginated logs
- Request details
- Token usage
- Latency metrics
- Status codes
🔒 Security
- JWT Authentication - 24h token expiry
- Password Hashing - SHA-256 (use Argon2id in production)
- API Key Encryption - AES-256-GCM for server keys
- API Key Hashing - SHA-256 for user keys
- CORS Protection - Configurable origin
- Soft Delete - Users are soft-deleted
🛠️ Tech Stack
Backend
- Runtime: Bun
- Framework: Hono
- Database: PostgreSQL 15+
- Cache: Redis 7+
- Language: TypeScript
Frontend
- Library: React 18
- Build Tool: Vite
- Styling: TailwindCSS
- State: Zustand + TanStack Query
- Router: React Router
- Language: TypeScript
📊 Statistics
Backend
- 20 source files
- 3000+ lines of code
- 40+ API endpoints
- 7 database tables
- 5 documentation files
Frontend
- 25+ files
- 3500+ lines of code
- 8 pages
- 4 reusable components
- Complete CRUD for all entities
🔧 Development
Backend Development
cd backend
bun run dev # Auto-reload
bun run migrate # Run migrations
bun run seed # Seed database
Frontend Development
cd frontend
npm run dev # Auto-reload
npm run build # Production build
npm run preview # Preview build
📦 Production Deployment
Backend
- Set
NODE_ENV=production - Use strong
JWT_SECRET - Generate secure
SERVER_KEY_ENCRYPTION_KEY - Configure proper
CORS_ORIGIN - Use strong database passwords
- Enable PostgreSQL SSL
- Enable Redis password
- Setup database backups
- Use process manager (PM2/systemd)
- Setup reverse proxy (nginx)
Frontend
- Build:
npm run build - Upload
dist/folder to static hosting - Configure
VITE_API_URLto production backend - Setup CDN (optional)
- Enable HTTPS
🐛 Troubleshooting
Backend Issues
Connection Error ke PostgreSQL
# Check PostgreSQL status
sudo systemctl status postgresql
# Start PostgreSQL
sudo systemctl start postgresql
Connection Error ke Redis
# Check Redis status
sudo systemctl status redis
# Start Redis
sudo systemctl start redis
Frontend Issues
CORS Error
- Pastikan backend
CORS_ORIGINsesuai dengan frontend URL - Restart backend setelah mengubah CORS
Cannot Connect to Backend
- Pastikan backend running di
http://localhost:3000 - Check
VITE_API_URLdi frontend.env
Login Failed
- Pastikan backend sudah di-seed
- Check credentials:
admin/admin123
📝 Environment Variables
Backend (.env)
PORT=3000
NODE_ENV=development
CORS_ORIGIN=http://localhost:5173
POSTGRES_DSN=postgresql://user:pass@localhost:5432/gprx
REDIS_ADDR=localhost:6379
SERVER_KEY_ENCRYPTION_KEY=<64-hex-chars>
JWT_SECRET=<random-string>
Frontend (.env)
VITE_API_URL=http://localhost:3000
🤝 Contributing
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
📄 License
MIT
🎉 Ready to Use!
Sistem sudah 100% siap digunakan dengan:
- ✅ Complete backend API
- ✅ Complete frontend UI
- ✅ Authentication & authorization
- ✅ CRUD operations untuk semua entities
- ✅ Beautiful & responsive design
- ✅ Comprehensive documentation
Tinggal setup database, run backend & frontend, dan mulai manage data! 🚀