A production-ready Full Stack FastAPI template with integrated Razorpay payment gateway, ready-to-use checkout pages, payment analytics, and complete payment flow management.
π Bootstrap your monetized app in minutes - Everything you need for payments is already integrated!
- Razorpay Gateway Integration - One-time payments with secure signature verification
- Webhook Handling - Real-time payment status updates
- Payment Analytics Dashboard - Track payments, success rates, and revenue
- Checkout UI - Beautiful, responsive checkout page with Razorpay modal
- Payment History - Complete order and payment tracking in database
- Backend: FastAPI + SQLModel + PostgreSQL
- Frontend: React + TypeScript + Chakra UI
- DevOps: Docker Compose with hot-reload
- Testing: Pytest + Playwright E2E tests
- Deployment: Production-ready with Traefik & HTTPS
- JWT authentication
- Secure password hashing
- Email-based password recovery
- Role-based access control
- Payment signature verification
Complete payment dashboard with integrated checkout form and payment analytics. Users can make payments and view their payment history all in one place.
Seamless Razorpay checkout modal integration with secure payment processing.
git clone https://github.com/yourusername/full-stack-fastapi-payment-template.git
cd full-stack-fastapi-payment-templateCopy .env and update the following:
# Security Keys (generate with: python -c "import secrets; print(secrets.token_urlsafe(32))")
SECRET_KEY=your-secret-key-here
POSTGRES_PASSWORD=your-db-password
FIRST_SUPERUSER_PASSWORD=admin-password
# Razorpay Payment Gateway
RAZORPAY_KEY_ID=rzp_test_xxxxxxxxxxxxx
RAZORPAY_KEY_SECRET=your-razorpay-key-secret
RAZORPAY_WEBHOOK_SECRET=your-webhook-secret # For production webhooksdocker compose watchThis will:
- Start all services (backend, frontend, database)
- Run database migrations automatically
- Enable hot-reload for development
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Checkout Page: http://localhost:5173/checkout
- Go to http://localhost:5173/signup
- Create an account
- Navigate to
/checkoutto test payments
- Sign Up: Visit Razorpay Dashboard
- Get Test Keys (no KYC required):
- Log in to Razorpay Dashboard
- Go to Settings β API Keys
- Copy your Key ID (starts with
rzp_test_) and Key Secret
- Add to
.env:RAZORPAY_KEY_ID=rzp_test_your_key_id RAZORPAY_KEY_SECRET=your_key_secret
Use Razorpay test cards:
- Success:
4111 1111 1111 1111(any CVV, any future expiry) - Failure:
4000 0000 0000 0002 - See Razorpay Test Cards for more options
- Complete KYC verification in Razorpay Dashboard
- Switch to Live Mode
- Generate Live API keys
- Update
.envwith live keys - Configure webhooks (see backend/README.md)
- Development Guide - Local development with Docker Compose
- Deployment Guide - Production deployment instructions
- Backend README - Backend development, migrations, and payment API details
- Frontend README - Frontend development guide
- Setup Instructions: See Payment Integration (Razorpay) above
- API Endpoints: See backend/README.md
- Database Models: See backend/README.md
- Webhook Configuration: See backend/README.md
.
βββ backend/ # FastAPI backend
β βββ app/
β β βββ api/ # API routes (including payments)
β β βββ models.py # Database models (Order, Payment)
β β βββ crud.py # Database operations
β β βββ services/ # Business logic (Razorpay service)
β β βββ alembic/ # Database migrations
β βββ README.md # Backend documentation
βββ frontend/ # React frontend
β βββ src/
β β βββ components/
β β β βββ Payments/ # Payment UI components
β β βββ routes/ # Application routes
β β βββ client/ # Auto-generated API client
β βββ README.md # Frontend documentation
βββ img/ # Screenshots and images
βββ docker-compose.yml # Docker services configuration
βββ development.md # Development guide
βββ deployment.md # Deployment guide
β Payment API Endpoints
- Create Razorpay orders
- Verify payment signatures
- Handle webhooks
- List user orders
- Get order details
β Database Models
Order- Payment orders with Razorpay integrationPayment- Payment records linked to orders- Automatic migrations with Alembic
β Services
- Razorpay service for API interactions
- Secure signature verification
- Payment capture handling
β Payment Components
- Checkout page with integrated dashboard
- Payment success/failure pages
- Payment analytics dashboard
- Recent orders table
β UI/UX
- Modern blue theme
- Responsive design
- Sidebar navigation
- Real-time payment updates
- User initiates payment β Enters amount on
/checkoutpage - Backend creates order β Saves to database, returns Razorpay order ID
- Razorpay modal opens β User completes payment
- Payment verification β Frontend sends payment details to backend
- Signature verification β Backend verifies Razorpay signature
- Database update β Order and payment records updated
- Success redirect β User sees payment confirmation and analytics
- Webhook update β Real-time status updates from Razorpay (optional)
docker compose exec backend bash scripts/test.shdocker compose exec playwright npm run testThis project uses Alembic for database migrations. Migrations run automatically on startup.
Quick Commands:
# Check migration status
docker compose exec backend bash -c "cd /app && alembic current"
# Create new migration
docker compose exec backend bash -c "cd /app && alembic revision --autogenerate -m 'Description'"
# Apply migrations
docker compose exec backend bash -c "cd /app && alembic upgrade head"For detailed migration guide, see backend/README.md.
docker compose watchThis enables:
- Hot-reload for backend and frontend
- Auto-regeneration of API client
- Live migration application
See backend/README.md for:
- Local development setup
- Running tests
- Creating migrations
- Payment API details
See frontend/README.md for:
- Local development
- Component structure
- API client generation
Once running, access interactive API docs:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
All payment endpoints are documented and can be tested directly from the Swagger UI.
- β Complete payment integration (Razorpay)
- β User authentication & authorization
- β Admin dashboard
- β Payment analytics
- β Webhook handling
- β Database migrations
- β API documentation
- β E2E tests
- β Production deployment config
- β Docker Compose setup
- β CI/CD ready
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
- Built on Full Stack FastAPI Template
- Payment integration powered by Razorpay
Ready to accept payments? π Clone this repo, add your Razorpay keys, and start processing payments in minutes!








