Backend Engine Overview
The NMT backend is a Rust application that serves as the platform's data brain. It continuously reads data from blockchains and external APIs, processes it, and stores it in PostgreSQL for the frontend to consume.
What It Does
The backend has two main jobs:
- Indexing — watches the blockchain for events (new positions, swaps, deposits) and records them in the database
- Valuation — periodically calculates the USD value of every user position
The frontend reads data directly from the shared PostgreSQL database via Prisma — there is no REST API layer between the frontend and the database.
What It Does NOT Do
The backend never holds private keys and never submits transactions. It is purely a read-only data layer with respect to the blockchain. All transaction execution happens through the smart wallet layer.
Tech Stack
| Component | Technology | Version |
|---|---|---|
| Language | Rust | 1.90 (edition 2024) |
| Async Runtime | Tokio | 1.48.0 |
| Runtime Framework | Axum | 0.8.1 |
| ORM | SeaORM | 1.1.17 |
| Blockchain Client | Alloy | 1.4.3 |
| Database | PostgreSQL | 16 |
| Error Tracking | Sentry | 0.45.0 |
High-Level Architecture
+-----------------------------------------------+
| Backend Application |
| |
| +---------+ +----------------+ |
| | Workers | | Scheduler | |
| | (DeFi) | | (cron-like) | |
| +---------+ +----------------+ |
| | | |
| +---------+ +---------+ +----------------+ |
| | Storage | | Types | | Channels | |
| | (SeaORM)| | (shared)| | (messaging) | |
| +---------+ +---------+ +----------------+ |
| | |
| +---------+ |
| | Math | |
| | (DeFi) | |
| +---------+ |
+-----------------------------------------------+
|
PostgreSQL 16
Project Location
All backend code lives in backend/:
backend/
├── apps/server/ # Main application entry point
├── crates/
│ ├── api/ # REST API routes and middleware
│ ├── workers/ # DeFi data indexing engine
│ ├── storage/ # Database entities and queries
│ ├── types/ # Shared type definitions
│ ├── channels/ # Inter-service messaging
│ └── math/ # DeFi calculations
├── migrations/pg/ # PostgreSQL migrations
├── infrastructure/ # Docker and build configs
├── .helm/ # Kubernetes Helm charts
├── Cargo.toml # Workspace manifest
└── Makefile # Development commands
Quick Commands
| Command | What It Does |
|---|---|
make up |
Starts Docker services + restores DB |
make down |
Stops Docker services |
make run-server |
Runs the API + workers locally |
make docker-build |
Builds the Docker image |
cargo test |
Runs all tests |
cargo clippy |
Runs the Rust linter |