# {{projectName}}

A SpecVerse **backend-only** starter — Fastify + Prisma REST API,
no frontend. Use this for microservices, API-first development, or
when the frontend lives in a separate repo.

## Quick start

```bash
# 1. Generate code, install dependencies, set up the database
npm run setup

# 2. Start the API
npm run dev               # http://localhost:3000

# 3. Hit it
curl http://localhost:3000/api/products
```

## Project structure

```
{{projectName}}/
├── specs/
│   └── main.specly              # Your API specification — edit this
├── manifests/
│   └── implementation.yaml      # Technology stack config
├── generated/
│   └── code/                    # Generated API — do NOT edit by hand
│       ├── src/                 # Controllers, services, routes, main.ts
│       └── prisma/              # Database schema + dev.db
├── docs/                        # Generated docs and diagrams
├── CLAUDE.md                    # AI assistant guide
└── package.json
```

## Commands

| Command | Description |
|---|---|
| `npm run validate` | Validate the spec |
| `npm run infer` | Run AI inference (writes `specs/inferred.specly`) |
| `npm run build` | Validate + realize (regenerates `generated/code/`) |
| `npm run setup` | Build + install deps + set up database |
| `npm run dev` | Start the API in dev mode |
| `npm run start` | Run the production build |
| `npm run gen:docs` | Generate documentation under `docs/` |
| `npm run gen:diagrams` | Generate Mermaid diagrams under `docs/diagrams/` |
| `npm run clean` | Remove `generated/code/` and `specs/inferred.specly` |

## What ships in the starter spec

A `Product` model with simple CURED operations (Create, Update,
Retrieve, Evolve, Delete). Replace it with your domain — the
realize engine generates routes, services, and Prisma schema
from whatever you put in `specs/main.specly`.

## Technology stack

| Layer | Technology |
|---|---|
| Framework | Fastify + TypeScript |
| ORM | Prisma |
| Database | **SQLite** for `development` (zero-deps), **PostgreSQL** for `production` (set `DATABASE_URL`) |
| API style | REST with CURED operations (Create, Update, Retrieve, Evolve, Delete) |

To switch the dev database to Postgres, edit
`manifests/implementation.yaml` → `configuration.environments.development.database`
and rerun `npm run build`.

## Prerequisites

- **Node.js 20+**
- **`@specverse/self`** installed globally:
  ```bash
  npm install -g @specverse/self
  ```

## Iterate

1. Edit `specs/main.specly`
2. `npm run validate`
3. `npm run build`
4. `cd generated/code && npm run db:push` if your models changed
5. The dev server watches and restarts automatically

## Learn more

- [SpecVerse User Guide](https://github.com/SpecVerse/specverse-self/blob/main/docs/guides/SPECVERSE-USER-GUIDE.md)
