# My FeltDB App

This small application demonstrates FeltDB's complete programming model:

- Authentication and authorization
- Multi-tenant application state
- Atomic workflows
- Agents with bounded capabilities
- Reactive UI through `@feltdb/core/react`
- Shared inspection through FeltDB Studio

## Run it

```bash
npm install
npm run feltdb:dev
```

In a second terminal:

```bash
npm run dev
```

Then sign up, create a project, invite an existing user, and run an assistant. Open the same state in Studio:

## Choose an AI model

`npm run feltdb:ai` uses private browser-local WebLLM by default. Use
`feltdb ai model set --provider local-webllm --model <model-id>` for a larger
local model, or configure an OpenAI-compatible model with a credential supplied
through `--api-key-stdin`. `feltdb ai model show` displays the active choice.
Hosted credentials remain in the operating-system vault and are never exposed
to the application or Studio.

```bash
npm run feltdb:studio
```

## How the example fits together

- `feltdb.flow` defines state, authorization, workflows, capabilities, and agents.
- `workflows/` implements project creation, invitation lifecycle, and agent-assisted summary examples.
- `capabilities/` contains the narrow read and summary operations available to assistants.
- `agents/` registers the Project and Activity assistants and persists their execution lifecycle.
- `src/` contains the authenticated React application.

These folders make the concepts easy to find; they are not mandatory application architecture. Agents and workflows use the same FeltDB collections as the UI, so they do not bypass `authenticated`, `member`, `owner`, or `self(user)` policies.

For managed FeltDB, generate with `--runtime managed`; the model and application remain the same while the runtime configuration changes.

Preview and publish the same definition to its configured cloud environment:

```bash
npm run feltdb:publish -- --dry-run
npm run feltdb:publish -- --yes
```
