Welcome to the complete deployment guide for GmGnAPI - your professional Python client for GMGN.ai WebSocket API.
- Quick Start
- Documentation Website
- PyPI Publishing
- Production Deployment
- Docker Deployment
- Kubernetes Deployment
- Monitoring & Observability
pip install gmgnapigit clone https://github.com/theshadow76/GmGnAPI.git
cd GmGnAPI
pip install -e .import asyncio
from gmgnapi import GmGnClient
async def main():
async with GmGnClient() as client:
await client.subscribe_new_pools()
@client.on_new_pool
async def handle_pool(data):
print(f"New pool detected: {data}")
await client.listen()
if __name__ == "__main__":
asyncio.run(main())The comprehensive documentation website is located in the docs/ directory with the following pages:
- index.html - Landing page with features and quick start
- getting-started.html - Detailed installation and setup guide
- api-reference.html - Complete API documentation
- examples.html - Practical usage examples
- advanced.html - Advanced features and enterprise usage
To test the documentation locally:
cd docs
python -m http.server 8000Then visit http://localhost:8000 in your browser.
- Push to GitHub repository
- Go to Settings → Pages
- Select source:
Deploy from a branch - Choose
mainbranch and/docsfolder - Your docs will be available at:
https://yourusername.github.io/GmGnAPI/
- Drag and drop the
docsfolder to Netlify - Get instant deployment with custom domain options
- Connect your GitHub repository to Vercel
- Set build settings:
- Framework Preset: Other
- Root Directory:
docs - Build Command: (leave empty)
- Output Directory: (leave empty)
- Create PyPI account at pypi.org
- Generate API token in account settings
- Configure
.pypircfile
Use the provided script:
python scripts/publish_to_pypi.py# Install publishing tools
pip install build twine
# Build the package
python -m build
# Upload to PyPI
twine upload dist/*Set these environment variables for automated publishing:
export PYPI_TOKEN="your-pypi-token"
export GITHUB_TOKEN="your-github-token" # For creating releases- Create production environment file:
# .env.production
GMGN_ACCESS_TOKEN=your_production_token
LOG_LEVEL=INFO
MAX_CONNECTIONS=100
RECONNECT_ATTEMPTS=5
HEARTBEAT_INTERVAL=30
DATABASE_URL=postgresql://user:pass@localhost/gmgnapi
REDIS_URL=redis://localhost:6379
MONITORING_ENABLED=true
METRICS_PORT=9090- Production configuration:
# config/production.py
import os
from gmgnapi import GmGnConfig
config = GmGnConfig(
access_token=os.getenv('GMGN_ACCESS_TOKEN'),
max_reconnect_attempts=int(os.getenv('RECONNECT_ATTEMPTS', 5)),
heartbeat_interval=int(os.getenv('HEARTBEAT_INTERVAL', 30)),
enable_monitoring=os.getenv('MONITORING_ENABLED', 'false').lower() == 'true'
)- API tokens securely stored
- Logging configured
- Monitoring enabled
- Error alerting setup
- Database configured
- Backup strategy in place
- Performance metrics tracked
- Security scanning completed
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy application
COPY . .
# Create non-root user
RUN useradd -m -u 1000 gmgnapi && chown -R gmgnapi:gmgnapi /app
USER gmgnapi
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import gmgnapi; print('OK')" || exit 1
CMD ["python", "main.py"]version: '3.8'
services:
gmgnapi:
build: .
restart: unless-stopped
environment:
- GMGN_ACCESS_TOKEN=${GMGN_ACCESS_TOKEN}
- DATABASE_URL=postgresql://postgres:password@db:5432/gmgnapi
- REDIS_URL=redis://redis:6379
depends_on:
- db
- redis
volumes:
- ./logs:/app/logs
networks:
- gmgn-network
db:
image: postgres:15
restart: unless-stopped
environment:
- POSTGRES_DB=gmgnapi
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=password
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- gmgn-network
redis:
image: redis:7-alpine
restart: unless-stopped
volumes:
- redis_data:/data
networks:
- gmgn-network
prometheus:
image: prom/prometheus:latest
restart: unless-stopped
ports:
- "9090:9090"
volumes:
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
networks:
- gmgn-network
grafana:
image: grafana/grafana:latest
restart: unless-stopped
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
volumes:
- grafana_data:/var/lib/grafana
networks:
- gmgn-network
volumes:
postgres_data:
redis_data:
prometheus_data:
grafana_data:
networks:
gmgn-network:
driver: bridgeapiVersion: v1
kind: Namespace
metadata:
name: gmgnapiapiVersion: v1
kind: Secret
metadata:
name: gmgn-secrets
namespace: gmgnapi
type: Opaque
data:
access-token: <base64-encoded-token>
database-url: <base64-encoded-db-url>apiVersion: apps/v1
kind: Deployment
metadata:
name: gmgnapi
namespace: gmgnapi
labels:
app: gmgnapi
spec:
replicas: 3
selector:
matchLabels:
app: gmgnapi
template:
metadata:
labels:
app: gmgnapi
spec:
containers:
- name: gmgnapi
image: gmgnapi:latest
ports:
- containerPort: 8080
env:
- name: GMGN_ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: gmgn-secrets
key: access-token
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: gmgn-secrets
key: database-url
resources:
limits:
memory: "1Gi"
cpu: "500m"
requests:
memory: "512Mi"
cpu: "250m"
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
readinessProbe:
httpGet:
path: /ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 5apiVersion: v1
kind: Service
metadata:
name: gmgnapi-service
namespace: gmgnapi
spec:
selector:
app: gmgnapi
ports:
- protocol: TCP
port: 80
targetPort: 8080
type: ClusterIPapiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: gmgnapi-hpa
namespace: gmgnapi
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: gmgnapi
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 80# monitoring/prometheus.yml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'gmgnapi'
static_configs:
- targets: ['gmgnapi:8080']
metrics_path: /metrics
scrape_interval: 5s
- job_name: 'postgres'
static_configs:
- targets: ['db:5432']
- job_name: 'redis'
static_configs:
- targets: ['redis:6379']Create dashboards for:
- Message Processing Rate - Messages per second
- Connection Health - Active connections, reconnections
- Error Rates - Failed connections, processing errors
- Resource Usage - CPU, memory, disk usage
- Database Performance - Query times, connection pool
Structured logging with JSON format:
import structlog
import logging
# Configure structured logging
structlog.configure(
processors=[
structlog.stdlib.filter_by_level,
structlog.stdlib.add_logger_name,
structlog.stdlib.add_log_level,
structlog.stdlib.PositionalArgumentsFormatter(),
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.StackInfoRenderer(),
structlog.processors.format_exc_info,
structlog.processors.UnicodeDecoder(),
structlog.processors.JSONRenderer()
],
context_class=dict,
logger_factory=structlog.stdlib.LoggerFactory(),
wrapper_class=structlog.stdlib.BoundLogger,
cache_logger_on_first_use=True,
)
logger = structlog.get_logger()Set up alerts for:
- Connection failures
- High error rates
- Memory usage > 80%
- CPU usage > 70%
- Disk space < 20%
- Failed health checks
- Deploy Documentation - Host your docs on GitHub Pages or Netlify
- Publish to PyPI - Make your package available for
pip install - Set Up CI/CD - Automate testing and deployment
- Monitor Performance - Track metrics and optimize
- Scale as Needed - Add more instances or optimize code
- Documentation: [Your hosted docs URL]
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: contact@gmgnapi.dev
🎉 Congratulations! You now have a professional-grade, production-ready GMGN API client with beautiful documentation and deployment infrastructure!