Skip to main content

Infrastructure Overview

Nex-T1 is designed for production deployment with enterprise-grade infrastructure components, comprehensive monitoring, and flexible orchestration options. Nex-T1 Infrastructure Architecture

Architecture Components

FastAPI Backend

High-performance API with LangGraph orchestration, JWT auth, and SSE streaming

PostgreSQL + pgvector

Persistent storage with vector similarity search capabilities

Observability Stack

Prometheus metrics + Grafana dashboards for real-time monitoring

Container Orchestration

Docker Compose for single-host, Kubernetes for clustered deployments

System Architecture


Docker Compose Deployments

Local Development

The docker-compose.yml configuration provides a complete development environment: Quick Start:
Development Features:
  • Hot-reload enabled with volume mounts (./app/app)
  • Reads .env.development for configuration
  • Health checks ensure service readiness
  • Shared monitoring network for service discovery
  • Persistent volumes: postgres-data, grafana-storage

Production Deployment

The docker-compose.prod.yml configuration includes production hardening:
Production Features:
  • Resource limits and reservations
  • Enhanced health checks with retry logic
  • SSL/TLS termination via Nginx reverse proxy
  • Log rotation with size limits
  • Custom network subnet (langgraph-network)
  • Separated data volumes (postgres-data-prod, prometheus-data)
  • Database initialization scripts
Deployment Commands:

Kubernetes Deployment

For multi-node clusters and auto-scaling, use the Kubernetes manifests in kubernetes/deployment.yaml.

Deployment Configuration

Service & Ingress

Horizontal Pod Autoscaler

Kubernetes Features:
  • Auto-scaling: CPU/memory-based HPA with 3-20 replica range
  • Rolling updates: Zero-downtime deployments with surge control
  • Health probes: Startup, liveness, and readiness checks
  • Security: Non-root user, capability drops, read-only configs
  • Observability: Prometheus scrape annotations on pods
  • Resource management: Requests and limits for CPU/memory
Prerequisites:
  • Namespace: nex-t1 or custom
  • Secrets: Database credentials, API keys
  • ConfigMaps: Application configuration
  • Ingress Controller: Nginx, Traefik, or cloud provider
  • Persistent Volume Claims: For PostgreSQL storage
Deployment Commands:

Metrics & Observability

Prometheus Metrics

Nex-T1 exposes comprehensive metrics at /metrics via the starlette_prometheus middleware. Configuration (app/core/metrics.py):
Custom Metrics Tracked: Prometheus Configuration (prometheus/prometheus.yml):

Grafana Dashboards

Access Grafana at http://localhost:3000 (default: admin/admin). Pre-configured Dashboards:
  1. API Overview: Request rates, latency percentiles, error rates
  2. LLM Performance: Token usage, inference time, model breakdown
  3. Multi-Agent System: Route distribution, coordinator timings, tool usage
  4. Infrastructure: CPU, memory, disk I/O, network throughput
  5. Database: Query performance, connection pool, cache hit rates
Sample PromQL Queries:

Structured Logging

Nex-T1 uses structlog for JSON-formatted logs optimized for log aggregation systems. Configuration (app/core/logging.py):
Log Output:
  • File: ./logs/app.log (JSONL format, rotated daily)
  • Console: Pretty-printed in development, JSON in production
  • Environment-aware: Configured via APP_ENV setting
Example Log Entry:

Security & Rate Limiting

Authentication

All protected endpoints require JWT bearer authentication:
Token Flow:
  1. User registers/logs in → receives JWT access token
  2. Token included in Authorization header for subsequent requests
  3. Token validated on each request via JWTBearer dependency
  4. Expired tokens rejected with 401 status
Configuration (app/core/security.py):

CORS Configuration

Cross-Origin Resource Sharing controlled via settings.ALLOWED_ORIGINS:

Rate Limiting

Implemented via slowapi with per-endpoint and default limits. Configuration (app/core/limiter.py):
Example Usage:
Rate Limit Headers:

API Documentation

Nex-T1 provides multiple interactive documentation interfaces: Convenience Redirect:
Scalar Configuration (/scalar.config.json):

Background Schedulers

Market Overview Scheduler

Optional automated market snapshots for research agents. Configuration:
Schedule:
  • Morning: 08:00 America/New_York
  • Evening: 20:00 America/New_York
Function:
  • Aggregates market data from MCP servers (DeFiLlama, Binance, etc.)
  • Stores snapshot in database for fast retrieval
  • Used by research agent for market analysis queries

Task Scheduler

Background task execution framework for async operations. Features:
  • Job queuing and prioritization
  • Retry logic with exponential backoff
  • Task status tracking and history
  • Started automatically on app startup
Example Task:

MCP (Model Context Protocol) Integration

Nex-T1 optionally mounts MCP servers for extended capabilities. Configuration (app/main.py):
Available MCP Servers: Exa MCP Details: See docs/EXA_MCP.md for API key setup and configuration. Tool Invocation:

Environment Variables

Complete reference for infrastructure configuration:

Application

Database

Authentication

LLM Providers

Security

Observability

Schedulers

MCP Servers


Deployment Checklist

1

Pre-deployment

  • Update .env.production with secure secrets
  • Configure database backup strategy
  • Set up SSL certificates (Let’s Encrypt or cloud provider)
  • Configure DNS records for domain
  • Review rate limits and resource quotas
2

Infrastructure Setup

  • Provision compute resources (VMs, Kubernetes cluster)
  • Deploy PostgreSQL with pgvector extension
  • Set up Prometheus + Grafana monitoring
  • Configure reverse proxy (Nginx/Traefik)
  • Set up log aggregation (ELK, Loki, cloud logging)
3

Application Deployment

  • Build Docker image: docker build -t nexis/nex-t1:latest .
  • Push to registry: docker push nexis/nex-t1:latest
  • Deploy with Compose or Kubernetes manifests
  • Run database migrations
  • Verify health checks: curl https://api.nex-t1.ai/health
4

Post-deployment Verification

  • Test authentication flow (register/login)
  • Test chat endpoints (non-streaming and SSE)
  • Test multi-agent routes (quote, execute, risk)
  • Verify MCP tool integrations
  • Check metrics in Grafana dashboards
  • Review logs for errors
5

Monitoring & Maintenance

  • Set up alerting rules (Prometheus Alertmanager)
  • Configure backup automation (database, logs)
  • Document incident response procedures
  • Schedule regular security audits
  • Plan capacity scaling based on load

Troubleshooting

Common Issues

Symptoms:
  • API returns 500 errors on all requests
  • Logs show sqlalchemy.exc.OperationalError
Solutions:
  1. Verify database is running: docker ps | grep db
  2. Check connection string in .env
  3. Ensure pgvector extension installed: CREATE EXTENSION IF NOT EXISTS vector;
  4. Test connection: psql -h localhost -U nexis -d nexis
Symptoms:
  • API container using >8GB RAM
  • OOMKilled events in Kubernetes
Solutions:
  1. Review connection pool settings (DB_POOL_SIZE, DB_MAX_OVERFLOW)
  2. Check for memory leaks in LLM client connections
  3. Reduce concurrent requests with rate limiting
  4. Increase container memory limits
  5. Enable request streaming to reduce buffering
Symptoms:
  • Chat requests timeout after 30s
  • llm_inference_duration_seconds metric very high
Solutions:
  1. Check LLM provider status and quotas
  2. Verify API keys are valid and not rate-limited
  3. Use streaming endpoints for faster perceived performance
  4. Implement response caching for common queries
  5. Consider using smaller/faster models for simple tasks
Symptoms:
  • Empty dashboards in Grafana
  • Prometheus targets show “DOWN”
Solutions:
  1. Verify /metrics endpoint accessible: curl http://localhost:8000/metrics
  2. Check Prometheus targets: http://localhost:9090/targets
  3. Review prometheus/prometheus.yml configuration
  4. Ensure services on same Docker network
  5. Check firewall rules for port 8000

Performance Tuning

Database Optimization

Application Tuning

Kubernetes Resource Optimization


Support & Resources

Docker Compose Files

View docker-compose.yml and docker-compose.prod.yml

Kubernetes Manifests

Deployment, service, HPA, and ingress configs

Grafana Dashboards

Pre-built dashboard JSON for import
For production support, security inquiries, or custom deployment assistance, contact support@nexis.network.