A production-ready full-stack web application built with Axum (Rust backend) and React (TypeScript frontend) for managing payments.
- Modern Backend: Async REST API built with Axum framework
- React Frontend: Component-based UI with TypeScript
- Real-time Status: Live server health monitoring
- Responsive Design: Mobile-friendly interface with TailwindCSS
- CORS Enabled: Development-ready CORS configuration
- Docker Support: Containerized deployment for both services
- Rust 1.70+ (Install)
- Cargo package manager
- Node.js 18+ (Install)
- npm or yarn
-
Clone and setup:
cd {{ project_name }} cp backend/.env.example backend/.env cp frontend/.env.example frontend/.env -
Start Backend (Terminal 1):
cd backend cargo runBackend runs on
http://localhost:{{ backend_port }} -
Start Frontend (Terminal 2):
cd frontend npm install npm run devFrontend runs on
http://localhost:{{ frontend_port }} -
Access the Application: Open
http://localhost:{{ frontend_port }}in your browser
Build and run both services:
docker-compose up --build- Backend:
http://localhost:{{ backend_port }} - Frontend:
http://localhost:{{ frontend_port }}
GET /api/healthResponse:
{
"status": "healthy",
"service": "x402-fullstack-api",
"version": "0.1.0"
}POST /api/payments
Content-Type: application/json
{
"amount": 5000,
"description": "Monthly subscription"
}GET /api/paymentsGET /api/payments/:id{{ project_name }}/
├── backend/
│ ├── src/
│ │ └── main.rs # API server and routes
│ ├── Cargo.toml # Backend dependencies
│ └── .env.example # Environment variables template
├── frontend/
│ ├── src/
│ │ ├── main.tsx # React entry point
│ │ ├── App.tsx # Main application component
│ │ └── App.css # Styling
│ ├── index.html # HTML template
│ ├── vite.config.ts # Vite configuration
│ ├── tsconfig.json # TypeScript configuration
│ ├── package.json # Frontend dependencies
│ └── .env.example # Environment variables template
├── docker-compose.yml # Docker services configuration
└── README.md # This file
cd backend
# Run development server with hot reload
cargo run
# Format code
cargo fmt
# Lint code
cargo clippy
# Run tests
cargo testcd frontend
# Install dependencies
npm install
# Start dev server with hot reload
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Lint code
npm run lint- Framework: Axum web framework with Tokio async runtime
- API Pattern: RESTful endpoints with JSON
- State Management: Arc<Mutex<Vec>> for in-memory storage
- CORS: Permissive for development (restrict in production)
- Middleware: Tracing and CORS support
- Library: React 18 with TypeScript
- Build Tool: Vite for fast development and optimized production builds
- Styling: Plain CSS with CSS custom properties for theming
- HTTP Client: Axios for API requests
- State Management: React hooks (useState, useEffect)
Create .env in backend/:
BACKEND_PORT=3000
RUST_LOG=infoCreate .env in frontend/:
VITE_API_BASE_URL=http://localhost:3000/apiFor production, update to your production API URL.
Backend:
cd backend
cargo build --release
./target/release/{{ project_name }}-backendFrontend:
cd frontend
npm run build
# Upload `dist/` directory to static hosting- Update
docker-compose.ymlto useprodimage tag - Restrict CORS in backend for production
- Update API URLs to production domain
- Build and push images to registry
- Ensure backend is running on the correct port
- Check
VITE_API_BASE_URLenvironment variable - Verify CORS is enabled (it is by default)
- Clear browser cache and try again
- Check that frontend is running on the correct port ({{ frontend_port }})
- Check browser console for errors
- Ensure no other process is using port {{ backend_port }}
- Check
RUST_LOGenvironment variable - Verify Rust version is 1.70+
- Ensure Docker daemon is running
- Check Docker disk space:
docker system prune - Rebuild images:
docker-compose up --build
Before deploying to production:
- Replace permissive CORS with specific allowed origins
- Implement authentication (JWT, OAuth, etc.)
- Add input validation and rate limiting
- Use HTTPS
- Implement proper error handling that doesn't expose internals
- Add database persistence instead of in-memory storage
- Set appropriate environment variables for production
- Use environment secrets management
- Implement logging and monitoring
- Add comprehensive error handling
- Add Authentication: Integrate JWT or OAuth2
- Database: Replace in-memory storage with PostgreSQL
- Validation: Add comprehensive input validation
- Testing: Write unit and integration tests
- Monitoring: Add observability (logs, metrics, traces)
- Documentation: Add OpenAPI/Swagger documentation
- Styling: Enhance UI with component library
MIT
For issues or questions:
- Check the troubleshooting section
- Review the code comments
- Check Axum and React documentation
- Open an issue on GitHub
Created with ❤️ by {{ author }}