A demo FastAPI application showcasing the Vortex Python SDK integration. This demo mirrors the functionality of the Express and Fastify demos but uses Python/FastAPI.
- Authentication System: Demo login/logout with JWT sessions
- Vortex Integration: Complete API routes matching Express/Fastify demos
- Identical Frontend: Same React-based UI as other demos
- FastAPI Framework: Modern Python web framework with automatic API docs
- Python 3.8+ (check with
python --version) - pip (Python package installer)
From the demo-python directory:
cd apps/demo-python
# Create virtual environment (recommended)
python3 -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtThe demo uses the local Vortex Python SDK. Install it in development mode:
# From the demo-python directory
pip install -e ../../packages/vortex-python-sdk# Copy environment template
cp .env.example .env
# Edit .env file if needed (optional for demo)
# VORTEX_API_KEY=your-api-key-here
# PORT=8000# Start the development server
python src/server.pyThe server will start on http://localhost:8000
π― Quick Test: After starting, visit http://localhost:8000/docs to see the interactive API documentation with all working routes!
Note: This demo uses SHA256 hashing and simplified JWT for Python 3.13 compatibility. Perfect for demo purposes and development.
- Web Interface: http://localhost:8000
- API Documentation: http://localhost:8000/docs (FastAPI auto-generated docs)
- Health Check: http://localhost:8000/health
The demo includes pre-configured users:
-
Admin:
admin@example.com/password123- Role: admin
- Groups: Engineering team, Acme Corp organization
-
User:
user@example.com/userpass- Role: user
- Groups: Engineering team
POST /api/auth/login- User loginPOST /api/auth/logout- User logoutGET /api/auth/me- Get current user info
GET /api/demo/users- Get demo users listGET /api/demo/protected- Protected route (requires login)
POST /api/vortex/jwt- Generate Vortex JWTGET /api/vortex/invitations/by-target- Get invitations by targetGET /api/vortex/invitations/{id}- Get specific invitationPOST /api/vortex/invitations/accept- Accept invitationsDELETE /api/vortex/invitations/{id}- Revoke invitationGET /api/vortex/invitations/by-group/{type}/{id}- Get group invitationsDELETE /api/vortex/invitations/by-group/{type}/{id}- Delete group invitationsPOST /api/vortex/invitations/{id}/reinvite- Reinvite
apps/demo-python/
βββ src/
β βββ server.py # Main FastAPI application
β βββ auth.py # Demo authentication system
β βββ __init__.py # Python package marker
βββ public/
β βββ index.html # Frontend (identical to Express demo)
βββ requirements.txt # Python dependencies
βββ pyproject.toml # Python project configuration
βββ .env.example # Environment template
βββ README.md # This file
- Modern Python web framework with automatic API documentation
- Pydantic models for request/response validation
- Dependency injection for authentication
- Exception handling with proper HTTP status codes
- Direct import and usage of the Vortex Python SDK
- Both sync and async methods available (demo uses sync for simplicity)
- Proper error handling with VortexApiError exceptions
- JWT generation and invitation management
- Bcrypt password hashing
- JWT session tokens in HTTP-only cookies
- Dependency injection for protected routes
- Demo users with different roles and groups
# Install production dependencies
pip install gunicorn
# Run with Gunicorn
gunicorn src.server:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000VORTEX_API_KEY- Your Vortex API key (default: "demo-api-key")PORT- Server port (default: 8000)JWT_SECRET- JWT signing secret (default: "demo-secret-key")
- Start the server following the Quick Start guide
- Open http://localhost:8000 in your browser
- Log in using one of the demo users
- Test Vortex features using the web interface
- Check API docs at http://localhost:8000/docs for interactive testing
This demo provides identical API compatibility with the Express and Fastify demos:
- Same route paths and HTTP methods
- Same request/response formats
- Same authentication flow
- Same frontend interface
The only differences are:
- Python/FastAPI server implementation
- FastAPI automatic API documentation
- Pydantic validation instead of TypeScript types
-
Python version issues:
- Too old: Ensure Python 3.8+
- Python 3.13: Fully supported with simplified dependencies
-
Module not found errors:
- Make sure virtual environment is activated:
source venv/bin/activate - Install dependencies:
pip install -r requirements.txt
- Make sure virtual environment is activated:
-
Port already in use: Change PORT in .env or kill the process using the port
-
Vortex SDK import error: Ensure the SDK is installed with
pip install -e ../../packages/vortex-python-sdk -
API returns demo data: This is normal! Configure VORTEX_API_KEY environment variable for real API data
The server runs in debug mode by default with auto-reload. Check the console output for detailed error messages.
FastAPI provides detailed request/response logging. Check the console where you started the server for debugging information.
- Custom Integration: Use this demo as a template for your FastAPI applications
- Database Integration: Replace demo users with real database models
- Production Setup: Configure proper environment variables and security settings
- Testing: Add pytest tests following the patterns in the Vortex SDK