# Core Concepts

Source: https://docs.formance.com/v4.0/getting-started/concepts

Stack: v4.0

This page introduces Formance modules.

## The Big Picture

Formance helps you track and move money. At its core:

1. **Ledger** records where assets are and where they move
2. **Numscript** expresses the intent for how assets should move
3. **Connectivity** records activity from external providers like Stripe or your bank in Ledger

Let's look at each one.

***

## Ledger

The Ledger is your source of truth for money. It tracks:

- **Accounts**: Named addresses that maintain a balance of assets received or sent (e.g., `users:alice:wallet`, `platform:fees`)
- **Transactions**: Records of assets moving between accounts
- **Balances**: The net result of all assets received and sent for each account

### How it works

Every time money moves, the Ledger creates a transaction with one or more **postings**. A posting is simply: "Move X amount from account A to account B."

```json
{
  "source": "users:alice:wallet",
  "destination": "merchants:coffee-shop",
  "amount": 450,
  "asset": "USD/2"
}
```

This moves $4.50 from Alice's wallet to the coffee shop.

### Key principles

- **Double-entry**: Every transaction balances. Assets leaving one account equal assets entering another.
- **Immutable**: Transactions cannot be edited or deleted. To cancel the effect of a transaction, you create a new transaction that offsets it. This can be a reversal or a more intentional corrective booking depending on your audit requirements.
- **Atomic**: Multi-posting transactions succeed or fail together. No partial transfers.

### Account naming

Accounts are identified by addresses like `users:alice:wallet` or `orders:12345:pending`. The colons create segments you can use to organize and filter accounts.

You don't need to create accounts before using them. The first transaction involving an account creates it automatically.

### Where your ledger lives

You post transactions against a **named ledger**, which sits inside a hierarchy: a **stack** is an isolated Formance Platform instance with its own API URL and data; the stack runs the **Ledger cluster**, a set of nodes that replicate every write between themselves; and the cluster holds one or more **named ledgers**. There is no database layer in between — each node stores its own copy.

Two named ledgers never share accounts, balances, or transaction numbering — the same account name can exist in both without interference. What a named ledger does _not_ buy you is write parallelism: every ledger in a cluster is ordered by the same consensus group. [How Ledger stores and replicates data →](https://docs.formance.com/v4.0/modules/ledger/get-started/architecture)

[Learn more about Ledger →](https://docs.formance.com/v4.0/modules/ledger)

***

## Numscript

Numscript is a domain-specific language for expressing the **intent** of money movements. Instead of writing code to calculate splits and handle edge cases, you describe what should happen and Numscript produces **deterministic postings**.

### Why use it?

Consider paying out a rideshare driver: the rider pays $10, the platform takes 20%, and the driver gets the rest. In Numscript:

```numscript
send [USD/2 1000] (
  source = @rider:wallet
  destination = {
    20% to @platform:fees
    remaining to @driver:wallet
  }
)
```

Numscript captures your intent, ensures the transaction balances, and produces predictable, auditable postings every time.

### Key features

- **Percentage splits**: Divide payments automatically (`50% to @a, remaining to @b`)
- **Multiple sources**: Pull from several accounts to fund a payment
- **Overdraft control**: Express precisely how overdrafts should be handled. Accounts can be bounded (prevent negative balances), allowed a specific limit, or unbounded.
- **Metadata**: Attach information to transactions for tracking

The `@` symbol denotes an account. `@world` is a special account that is unbounded by default, useful for creating initial balances.

[Learn more about Numscript →](https://docs.formance.com/v4.0/modules/numscript)

***

## Connectivity

Connectivity connects external providers, such as payment processors, banks, exchanges, and cloud billing, to your Ledger. Each connector covers a defined part of a provider's activity and records it in Ledger as accounts, transactions, and metadata. One provider can have several connectors for different products or activities.

A connector keeps the provider's own meaning. It maps each provider identity to a stable Ledger account address, records supported movements as balanced transactions, and keeps provider references and timestamps as metadata, so every Ledger entry can be traced back to its source. It records only the objects and lifecycle stages listed in its coverage.

Some connectors also record the balance a provider reports, next to the balance Ledger derives from postings. When the two differ, the connector keeps both as evidence; comparing them and deciding what to do is a control you run on your side. See [Two views of a balance](https://docs.formance.com/v4.0/modules/connectivity/what-it-models#two-views-of-a-balance).

Connectivity is part of Formance Enterprise Edition. A Stack v4.0 installs the Ledger module by default; Connectivity is not installed by default.

[Learn more about Connectivity →](https://docs.formance.com/v4.0/modules/connectivity)

***

## How They Work Together

Here's an example of how the modules connect in a typical e-commerce marketplace:

1. **Customer pays via Stripe** → Stripe processes the card payment
2. **The Stripe Payments connector records it** → While the charge is pending, the connector records the gross amount and the processing fee as pending, under `stripe:{context}:balance:hold:{transaction}`
3. **Funds become available** → The connector settles the charge into `stripe:{context}:balance:main` and books the fee to `stripe:{context}:fees:processing:main`
4. **Your application records the order** → A Numscript program moves the funds into your own accounts, for example `orders:123:pending`
5. **Order ships** → Your application runs a second Numscript program that splits the payment between seller (80%) and platform (20%)
6. **Balances are checked** → The connector records the balance Stripe reports on `stripe:{context}:balance:main`. Because step 4 moved funds out of that account, compare the report with the accounts that represent Stripe: the counterparty and fee accounts (`stripe:{context}:counterparty:…` and `stripe:{context}:fees:…`) record every movement to and from Stripe, whatever your application did with the funds

### The role of each module

- **Connectivity** brings **external activity** into Ledger. Each connector reads one provider and records what it supports as Ledger accounts, transactions, and metadata, keeping the provider's references so every entry can be traced back to its source.

- **Ledger** is your **internal source of truth**: it tracks what assets exist and where they move within your system.

- **Numscript** expresses **how money should move**: splits, fees, and limits written once and applied as balanced transactions.

***
