No description
  • TypeScript 96.5%
  • Makefile 1.4%
  • Dockerfile 0.9%
  • CSS 0.8%
  • JavaScript 0.4%
Find a file
2026-05-23 13:40:25 +00:00
backend fix encrypt 2026-05-23 13:40:25 +00:00
frontend fix auth 2 2026-05-23 12:55:38 +00:00
.env.example fix crypto 2026-05-23 13:28:31 +00:00
.gitignore feat docker 2026-05-23 08:24:33 +00:00
DB.md init 2026-05-23 08:16:59 +00:00
docker-compose.yml fix auth 2 2026-05-23 12:55:38 +00:00
DOCKER.md feat docker 2026-05-23 08:24:33 +00:00
DOCKER_QUICKFIX.md fix docker 2026-05-23 09:47:53 +00:00
DOCKER_SUMMARY.md feat docker 2026-05-23 08:24:33 +00:00
DOCKER_TROUBLESHOOTING.md fix docker 2026-05-23 09:47:53 +00:00
Makefile fix auth 2026-05-23 12:46:33 +00:00
PROJECT_STRUCTURE.md init 2026-05-23 08:16:59 +00:00
PROJECT_SUMMARY.md init 2026-05-23 08:16:59 +00:00
QUICKSTART.md init 2026-05-23 08:16:59 +00:00
README.md feat docker 2026-05-23 08:24:33 +00:00

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

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

Frontend

🗄️ Database Schema

Tables

  1. users - User accounts
  2. subscriptions - Subscription plans
  3. servers - Upstream LLM servers
  4. models - Model mappings
  5. subs_servers - Subscription-server links
  6. user_keys - User API keys
  7. 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

  1. Set NODE_ENV=production
  2. Use strong JWT_SECRET
  3. Generate secure SERVER_KEY_ENCRYPTION_KEY
  4. Configure proper CORS_ORIGIN
  5. Use strong database passwords
  6. Enable PostgreSQL SSL
  7. Enable Redis password
  8. Setup database backups
  9. Use process manager (PM2/systemd)
  10. Setup reverse proxy (nginx)

Frontend

  1. Build: npm run build
  2. Upload dist/ folder to static hosting
  3. Configure VITE_API_URL to production backend
  4. Setup CDN (optional)
  5. 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_ORIGIN sesuai dengan frontend URL
  • Restart backend setelah mengubah CORS

Cannot Connect to Backend

  • Pastikan backend running di http://localhost:3000
  • Check VITE_API_URL di 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

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. 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! 🚀