Quantum backend project: Python Qiskit server with VPS deployment.
For Quantum Game Jam 2025, I built a production Python Flask server that implements real quantum computing using IBM's Qiskit library. This project demonstrates advanced backend development with quantum circuits, action-based HTTP API design, and professional deployment practices on a VPS with systemd service management.
This was a real team project where we all came together to share our expertise for a common goal. We implemented quantum circuits from scratch using Qiskit 2.1.2's Statevector simulator, creating clean abstractions for quantum gates (Hadamard, Pauli-X, Pauli-Z, Y-rotation) while maintaining proper quantum state throughout operations. The Qubit class handles initialization to |0⟩ state, gate transformations, wavefunction collapse measurement, and superposition strength calculation. The server exposes two main HTTP endpoints: /quantum_gate for direct gate operations and /quantum_text for context-aware text transformations based on quantum effects.
Collaborating with MajaQ on quantum logic design, we implemented text transformation algorithms with a 150+ word categorization system that maps keywords (memory, AI, quantum, consciousness) to specific quantum gate sequences. The server includes comprehensive Flask-CORS configuration for cross-origin requests, error handling with proper HTTP status codes, and a /health endpoint with Qiskit verification. Deployed to my VPS with systemd service configuration, the server handles concurrent requests with automatic restart on failure, journalctl logging, and proper environment management. This showcases production-ready backend development with cutting-edge quantum computing integration.
Qiskit Quantum Circuit Implementation
Real quantum gates using IBM's Statevector simulator
I implemented real quantum computing using Qiskit's Statevector simulator to create a Qubit class with proper quantum state management. The class initializes qubits to |0⟩ state ([1, 0] amplitude vector), applies quantum gate transformations using matrix operations, and measures outcomes with probabilistic collapse. I implemented four core gates: Pauli-X (bit flip), Pauli-Z (phase flip), Hadamard (superposition creation), and Ry (Y-axis rotation). The measure() method uses NumPy's random.choice with probabilities derived from amplitude squared (Born rule), causing authentic wavefunction collapse. The get_superposition_strength() method calculates |amplitude₁|² to quantify how much the qubit is in the |1⟩ state. This demonstrates deep understanding of quantum mechanics principles translated into production code.
from qiskit.quantum_info import Statevector, Operator
import numpy as np
class Qubit:
def __init__(self):
self.state = Statevector([1, 0]) # |0⟩ state
def bit_flip(self):
# Pauli-X gate: |0⟩ → |1⟩, |1⟩ → |0⟩
X = Operator([[0, 1], [1, 0]])
self.state = self.state.evolve(X)
def phase_flip(self):
# Pauli-Z gate: |1⟩ → -|1⟩
Z = Operator([[1, 0], [0, -1]])
self.state = self.state.evolve(Z)
def hadamard(self):
# Hadamard: creates equal superposition
H = (1/np.sqrt(2)) * np.array([[1, 1], [1, -1]])
self.state = self.state.evolve(Operator(H))
def rotate_y(self, theta):
# Y-axis rotation by angle theta
Ry = np.array([
[np.cos(theta/2), -np.sin(theta/2)],
[np.sin(theta/2), np.cos(theta/2)]
])
self.state = self.state.evolve(Operator(Ry))
def measure(self):
# Collapse to 0 or 1 based on |amplitude|²
probs = self.state.probabilities()
return np.random.choice([0, 1], p=probs)
def get_superposition_strength(self):
# Return |amplitude₁|² (probability of |1⟩)
return abs(self.state.data[1]) ** 2
Flask Action-Based HTTP API with CORS
RPC-style endpoints with stateless operations
I designed a clean action-oriented HTTP API with Flask exposing two main operation endpoints. The /quantum_gate endpoint accepts POST requests with gate_type ('bit_flip', 'phase_flip', 'rotation') and optional rotation_angle, creates a fresh qubit, applies the transformation, measures the result, and returns JSON with measurement (0/1), superposition_strength (0.0-1.0), and success boolean. The /quantum_text endpoint processes text using context-aware quantum transformations based on keyword detection. Rather than managing persistent resources (true REST), this API follows an RPC-style pattern perfect for stateless quantum computations that return immediate results. I configured Flask-CORS to allow cross-origin requests from multiple origins (game clients, web apps, local emulators), ensuring proper headers are included in responses. The API includes comprehensive error handling with try-catch blocks, proper HTTP status codes (200, 400, 500), and descriptive error messages. I also implemented a /health endpoint that verifies Qiskit availability and returns server status with version info.
Context-Aware Text Transformation System
150+ word categorization with quantum gate mapping
Collaborating with MajaQ, I built a sophisticated text transformation system that analyzes input for quantum-relevant keywords and applies appropriate gate sequences. I categorized 150+ words into themes: MEMORY (remember, forget, past, recall, amnesia), AI (algorithm, data, neural, intelligence, learning), QUANTUM (superposition, entanglement, qubit, measurement, coherence), and CONSCIOUSNESS (aware, think, thought, mind, perceive). When text contains memory-related words, the system applies Y-rotation gates for 'quantum fragmentation' effects. AI content gets Hadamard gates for maximum scrambling. The algorithm uses keyword density to determine transformation strength—more quantum keywords result in more aggressive effects. This creates narrative-appropriate visual distortions where technical discussions appear more 'quantum' than casual dialogue, demonstrating creative application of quantum computing to text manipulation.
VPS Deployment with systemd Service
Production infrastructure with automatic restart and logging
I deployed the quantum server to my personal VPS running Linux, configuring it as a systemd service for production reliability. The service unit file specifies the working directory, Python virtual environment path, user permissions (deployer), and restart policy (always restart with 10-second delay on failure). I configured the server to start automatically on boot, log all output to journalctl for debugging, and run in the background without blocking the terminal. The deployment process includes setting up the Python venv with all dependencies (Qiskit 2.1.2, Flask, NumPy, Flask-CORS), configuring the firewall to allow port 8000 traffic, and testing both HTTP endpoints. I documented the deployment with bash scripts for reproducibility. The server has been running reliably throughout the game jam, handling concurrent requests from the web app and Godot game simultaneously. This demonstrates professional DevOps practices including service management, logging, resource limits, and environment configuration.