Architecture Overview
Five Core Services
Web Frontend
A full-stack web application built on Next.js, serving as the user interface, server-side rendering layer, and BFF proxy. Horizontally scaled with multiple replicas, supporting canary releases.
Core API
The business logic hub, providing dual-track REST + tRPC APIs built on the Hono framework. Handles authentication, billing, expert management, review pipelines, subscription systems, and all business orchestration.
Agent Runtime
An AI reasoning engine built in Python, implementing the Agent Loop with LangGraph. Responsible for context construction, tool scheduling, streaming output, self-evolution, and other core AI capabilities.
Cloud Sandbox
Provides an isolated cloud container environment for each AI conversation, pre-installed with development toolchains. Supports file persistence, network access, process isolation, and sub-second warm starts.
Marketing Site & Developer Platform
The marketing site is deployed with SSR/ISR, supporting real-time blog publishing. The developer platform provides API Key management, call logs, and usage analytics.
Data Flow: From User to AI
A typical Expert conversation follows this path:1
User sends a message
The user sends a message from the browser/IM/IDE, routed through Nginx to the Web frontend.
2
Core orchestrates the request
The Web frontend forwards the request to the Core API. Core performs identity authentication, credit verification, Expert configuration loading, and sandbox preparation, then sends the complete runtime payload to Agent Runtime.
3
Agent reasoning loop
The Runtime builds the context (message history + memory + skills + tool declarations) and calls the LLM for reasoning. If the model decides to use tools, the Runtime executes operations in the sandbox and feeds results back to the model for continued reasoning.
4
Streaming response
The entire process streams to the client in real time via Server-Sent Events (SSE) — the user sees the AI thinking and responding simultaneously, with tool execution results appearing in real time.
Monorepo Structure
The entire codebase is organized as a Monorepo, sharing types and infrastructure:Three-Tier Environments and Release Strategy
Each environment runs in an independent Kubernetes namespace, sharing load balancer entry points but fully isolating data. Critical services (Web, Core, Runtime) support canary replicas — new versions are first validated with a small traffic percentage before full rollout.
Multi-Provider Model Routing
Profy is not locked into a single LLM provider. Core has a built-in unified Provider management system that supports:- Multi-provider access: Simultaneously connects to DashScope, Volcengine, Anthropic, OpenAI, and more
- Smart routing: Automatically selects the optimal key based on RPM/TPM quotas, balance, and health status
- Token-aware scheduling: Sliding window rate limiting to prevent saturating individual keys
- Differentiated parameters: Each model receives parameters according to its declared capabilities (e.g., temperature compatibility)
Supporting Infrastructure
PostgreSQL — Business Data Persistence
PostgreSQL — Business Data Persistence
Persistent storage for all business data, using Drizzle ORM for schema migration management. Supports optimistic locking for concurrency control, advisory locks for distributed mutual exclusion, and partitioned indexes for query performance optimization.
Redis — Caching and Real-Time Communication
Redis — Caching and Real-Time Communication
Handles session caching, rate limit counters, distributed locks, worker task queues, real-time state synchronization, and more. Uses multi-key namespace isolation for different business domains.
COS Object Storage — Files and Media
COS Object Storage — Files and Media
All user-uploaded files, AI-generated media resources, and static assets are stored in Tencent Cloud COS. Buckets are isolated by environment, supporting pre-signed URL direct uploads and CDN acceleration.
IM Gateway — Multi-Platform Message Bridge
IM Gateway — Multi-Platform Message Bridge
Provides unified access to Feishu, DingTalk, WeCom, and other IM platforms, converting messaging protocols into standard Agent calls so Experts can “live” in the communication tools users already use daily.
Design Philosophy
Profy’s architecture follows several core principles:- Separation of concerns: Each service does one thing — Core doesn’t do reasoning, Runtime doesn’t handle billing, Sandbox doesn’t touch business logic
- Declarative over imperative: Expert capabilities are composed through declarations (skill Manifests, tool configurations) rather than hardcoded
- Progressive degradation: When any external dependency is unavailable, core conversation capability should not be interrupted — if the sandbox is down, fall back to no-sandbox mode; if Redis is down, fall back to database
- Observability first: Every request carries complete trace context, and every Agent decision step has an audit log
This is an actively evolving architecture. We continue to invest in three directions: reducing AI inference latency, improving sandbox cold-start speed, and enhancing multi-tenant isolation security.

