# Data-First Philosophy

> Azmara is built around a single idea — your data layer should not be an external dependency, it should be the foundation.

Source: https://platform.azmara.io/docs/guide/data-first

## The problem with modern stacks

Modern application stacks have fragmented what should be a cohesive system. To show a list of records you now wire together:

- A database driver
- An ORM or query builder
- A state management library
- A UI framework
- An API layer to connect them all

Each layer has its own config, its own bugs, and its own version mismatch risks. The result is more glue than product.

## What Azmara does differently

Azmara treats data, reactivity, and UI as a single integrated system — not separate tools bolted together.

```
[ Data (SQLite) ] → [ Query Engine ] → [ Reactive Signals ] → [ React UI ]
```

Every layer speaks the same language. Query results flow directly into Signals. Signals drive React components. The UI stays in sync automatically — no manual wiring.

## The core model

```
@azmr/db      ← your data lives here, secured and persistent
@azmr/query   ← you express what you want, not how to get it
@azmr/core    ← the result becomes reactive automatically
@azmr/ui      ← your UI reflects reality at all times
```

## What this means in practice

```typescript
// 1. Define your data
const db = new SQLiteAdapter(".azmara/app.db", ".azmara");
await db.createTable("orders", { customer: "string", total: "number", paid: "boolean" });

// 2. Query it
const unpaid = query(await db.getAll("orders"))
  .where(o => !o.paid)
  .orderBy((a, b) => b.total - a.total)
  .select();

// 3. Make it reactive
const unpaidSignal = new Signal(unpaid);

// 4. Render it — updates automatically
<Grid signal={unpaidSignal} />
```

No reducers. No selectors. No store configuration. Data flows in one direction, from source to screen.
