> For the complete documentation index, see [llms.txt](https://perps.gitbook.io/perps./llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://perps.gitbook.io/perps./overview-1/system-architecture.md).

# System Architecture

High-level architecture:

* Frontend: Next.js application.
* Auth and wallet access: Privy.
* Smart contracts: creator-token lifecycle, bonding-curve trading, perpetual-market logic, and oracle/reference-price paths.
* Data layer: indexed on-chain events and derived read models for product views.

## Core Contracts

* `TokenFactory`: creator-token launch, bonding-curve trading, lifecycle events, and fee accounting.
* `PerpEngine`: perpetual markets, positions, margin, funding, and risk controls.
* `PriceOracle`: registered reference-price paths used by supported markets.

## Runtime Data Paths

The app combines:

* Direct on-chain reads for critical state.
* Indexed event data for history, charts, activity feeds, and profiles.
* Derived read models for user-facing market and progression views.

## Lifecycle and Trading Readiness

The app should distinguish:

* Bonding-curve token state.
* Graduation state.
* Perpetual-market readiness.
* Oracle readiness.
* Paused or unavailable trading state.

This prevents users from assuming that a graduated token is automatically ready for every trading mode.

## Risk Controls

Perpetual markets may include controls such as max leverage, open-interest caps, skew limits, position-size caps, and pause controls.

These controls are part of making creator perps safer to test and reason about.
