A full-stack web application that provides a ChatGPT interface with Google OAuth authentication and admin functionality for API key management.
- Google OAuth 2.0 integration
- Secure JWT token-based sessions
- Protected routes and API endpoints
- Clean, responsive chat UI
- Real-time messaging with ChatGPT (GPT-4o)
- Chat history storage and retrieval
- Message streaming and error handling
- User management and statistics
- API key configuration per user
- Admin access control
- Visual API key status indicators
- Individual user API key assignment
- Default API key configuration
- Multiple API key sources (user-specific, admin default, environment)
- Clear error messages for users without API keys
- React - Modern UI framework
- Tailwind CSS - Utility-first styling
- Google OAuth - Authentication
- Axios - HTTP client
- FastAPI - High-performance Python web framework
- MongoDB - Document database
- JWT - Token-based authentication
- OpenAI API - ChatGPT integration
- Google Cloud Run - Serverless deployment
- MongoDB Atlas - Managed database
- Docker - Containerization
- Node.js 18+ and Yarn
- Python 3.11+
- MongoDB (local or Atlas)
- Google OAuth credentials
- OpenAI API key
-
Clone the repository
git clone https://github.com/yourusername/chatgpt-proxy-poc.git cd chatgpt-proxy-poc -
Backend Setup
cd backend pip install -r requirements.txt # Create .env file cp .env.example .env # Edit .env with your credentials
-
Frontend Setup
cd frontend yarn install # Create .env file cp .env.example .env # Edit .env with your backend URL and Google Client ID
-
Environment Variables
Backend (.env):
MONGO_URL=mongodb://localhost:27017 DB_NAME=chatgpt_app GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret OPENAI_API_KEY=your-openai-api-key ADMIN_EMAILS=admin@yourdomain.comFrontend (.env):
REACT_APP_BACKEND_URL=http://localhost:8001 REACT_APP_GOOGLE_CLIENT_ID=your-google-client-id -
Run the Application
# Start backend (from backend directory) uvicorn server:app --reload --port 8001 # Start frontend (from frontend directory) yarn start
- Go to Google Cloud Console
- Create a new project or select existing
- Enable Google Sign-In API
- Create OAuth 2.0 credentials
- Add authorized origins and redirect URIs:
- Origins:
http://localhost:3000,https://yourdomain.com - Redirect URIs:
http://localhost:3000/auth/google,https://yourdomain.com/auth/google
- Origins:
See the complete deployment guide in deployment/README.md.
Quick deployment:
# Update project configuration
nano deployment/deploy.sh
# Deploy to Google Cloud
chmod +x deployment/deploy.sh
./deployment/deploy.sh# Build and run with Docker Compose
docker-compose up -dOnce running, visit:
- API Docs:
http://localhost:8001/docs - Redoc:
http://localhost:8001/redoc
GET /api/user/profile- Get current userPOST /api/chat- Send message to ChatGPTGET /api/chat/history- Get chat historyPOST /api/admin/configure- Configure API keys (admin)GET /api/admin/users- List all users (admin)
- Visit the application URL
- Click "Sign in with Google"
- Complete OAuth authentication
- Start chatting with ChatGPT
- If no API key is configured, contact admin
- Sign in with admin account
- Click "Admin Panel" to access management features
- Configure API keys:
- Set default API key for all users
- Assign individual API keys to specific users
- View user statistics and manage access
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Frontend β β Backend β β Database β
β (React) βββββΆβ (FastAPI) βββββΆβ (MongoDB) β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ ββββββββββββββββββββ
β Google OAuth β β OpenAI API β
β (Auth) β β (ChatGPT) β
βββββββββββββββββββ ββββββββββββββββββββ
- Fork the repository
- Create a 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 a Pull Request
- JWT tokens with expiration
- Environment variable protection
- CORS configuration
- Input validation and sanitization
- Protected admin endpoints
- Secure API key storage
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email support@yourdomain.com or open an issue on GitHub.
- OpenAI for ChatGPT API
- Google for OAuth 2.0
- FastAPI and React communities