# Data Layer

`@neutron-build/data` contains optional backend primitives for TypeScript
applications. The framework core does not install a database, cache, or queue
on its own.

## Available drivers

| Area | Included interface and implementations |
| --- | --- |
| Database | Drizzle profiles for SQLite, PostgreSQL, and Nucleus |
| Cache | In-memory, Redis/Dragonfly, and Nucleus KV clients |
| Sessions | Generic cache-backed store and Redis/Dragonfly store |
| Queues | In-memory driver and BullMQ |
| Storage | In-memory, S3-compatible, and Nucleus Blob drivers |
| Realtime | In-memory, Redis/Dragonfly, and Nucleus PubSub buses |

The integrations load their third-party dependencies lazily. Install only the
drivers an application uses:

```bash
npm install @neutron-build/data
npm install drizzle-orm postgres       # PostgreSQL or Nucleus SQL
npm install drizzle-orm @libsql/client # SQLite
npm install ioredis bullmq              # Redis/Dragonfly and queues
```

## Database selection

`resolveDataConfig()` uses an explicit `database` option when supplied.
Otherwise it checks `NUCLEUS_URL`, then `DATABASE_URL`, and falls back to a
local SQLite file at `.neutron/dev.db`.

```ts
import { resolveDataConfig } from "@neutron-build/data";

const config = resolveDataConfig({ database: "nucleus" });
```

This resolution selects a profile; it does not start local services or
provision production infrastructure.

## In-memory defaults

The cache, queue, storage, and realtime modules include in-memory
implementations for local use and tests. Choose an external driver explicitly
when state must be shared across processes.

Continue with [Database and Drizzle](/docs/data-layer/database),
[Caching loaders](/docs/data-layer/caching), or
[Redis and Dragonfly](/docs/data-layer/dragonfly).
