{"id":50483319,"url":"https://github.com/prisma/pokedex-prisma-next","last_synced_at":"2026-06-01T19:31:05.310Z","repository":{"id":342280323,"uuid":"1168603083","full_name":"prisma/pokedex-prisma-next","owner":"prisma","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-05T12:09:31.000Z","size":2322,"stargazers_count":4,"open_issues_count":3,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-14T20:37:37.582Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prisma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-27T15:28:08.000Z","updated_at":"2026-03-13T01:25:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/prisma/pokedex-prisma-next","commit_stats":null,"previous_names":["prisma/pokedex-prisma-next"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/prisma/pokedex-prisma-next","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fpokedex-prisma-next","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fpokedex-prisma-next/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fpokedex-prisma-next/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fpokedex-prisma-next/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prisma","download_url":"https://codeload.github.com/prisma/pokedex-prisma-next/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prisma%2Fpokedex-prisma-next/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33790706,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-01T19:31:04.238Z","updated_at":"2026-06-01T19:31:05.297Z","avatar_url":"https://github.com/prisma.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prisma Next Pokedex Demo\n\nA Pokédex built to showcase **Prisma Next** — a contract-first data access layer for PostgreSQL.\n\n## Highlights\n\n- **ORM collections with custom scopes** — chainable `.where()`, `.include()`, `.orderBy()`, reusable query fragments like `.legendary()` and `.search()`\n- **Streaming** — `.all()` returns an `AsyncIterable`, stream rows to the client as they arrive\n- **Type-safe aggregations** — `.groupBy().aggregate()` without raw SQL\n- **Kysely escape hatch** — `db.kysely()` gives a fully typed Kysely instance derived from the contract\n- **Contract-first schema** — TypeScript-defined, deterministic, machine-readable\n\n## Quick Start\n\n```bash\nbun install\n```\n\nConfigure `apps/server/.env`:\n\n```bash\nDATABASE_URL=postgresql://USER:PASSWORD@HOST:5432/DB_NAME\nCORS_ORIGIN=http://localhost:3001\n```\n\nInitialize and run:\n\n```bash\nbun run db:init\nbun run dev\n```\n\n- Web: http://localhost:3001\n- API: http://localhost:3000\n\nOpen the web app and click **Import Pokemon** to seed the database from PokeAPI.\n\n## Project Structure\n\n```\napps/\n  server/          Hono + oRPC API server\n  web/             React + TanStack Router frontend\npackages/\n  api/             API router definitions (oRPC procedures)\n  db/              Prisma Next contract, runtime, ORM collections, seed\n  config/          Shared TypeScript config\n```\n\n## Important Files\n\n| File | Purpose |\n|------|---------|\n| `packages/db/src/prisma/contract.ts` | Prisma Next contract (Pokemon + SpawnPoint tables, models, relations) |\n| `packages/db/src/prisma/db.ts` | Runtime bootstrap + connection |\n| `packages/db/src/index.ts` | ORM collections with custom scopes (`PokemonCollection`, `SpawnPointCollection`) |\n| `packages/db/src/prisma/seed.ts` | Seed script — fetches from PokeAPI, bulk inserts with `createCount()` |\n| `packages/api/src/routers/pokedex.ts` | API routes showcasing each Prisma Next feature |\n\n## Features Demonstrated\n\n### ORM Collections with Custom Scopes\n\nDefined in `packages/db/src/index.ts`. Collections are reusable, composable query builders — like Rails scopes:\n\n```typescript\nclass PokemonCollection extends Collection\u003cContract, \"Pokemon\"\u003e {\n  legendary()    { return this.where({ isLegendary: true }); }\n  byType(type)   { return this.where((p) =\u003e or(p.primaryType.ilike(...), ...)); }\n  search(term)   { return this.where((p) =\u003e or(p.name.ilike(...), ...)); }\n}\n```\n\n### Streaming\n\n`listPokemon` in `pokedex.ts` streams rows with `for await...of`:\n\n```typescript\nfor await (const row of query.include(\"spawnPoints\", (sp) =\u003e sp).take(limit).all()) {\n  yield row;\n}\n```\n\n### groupBy + aggregate\n\n`typeBreakdown` runs type-safe aggregations without raw SQL:\n\n```typescript\npokemon.groupBy(\"primaryType\").aggregate((agg) =\u003e ({ total: agg.count() }))\n```\n\n### Kysely Escape Hatch\n\n`teamBuilder` uses `db.kysely()` for a fully typed Kysely query when the ORM isn't enough:\n\n```typescript\nconst kysely = db.kysely(db.runtime());\nkysely.selectFrom(\"pokemon\").select([...]).where(...).execute();\n```\n\n## Scripts\n\n| Script | Description |\n|--------|-------------|\n| `bun run dev` | Run web + server |\n| `bun run db:init` | Emit contract + initialize schema |\n| `bun run db:emit` | Emit contract artifacts |\n| `bun run db:push` | Push schema to database |\n| `bun run db:verify` | Verify marker/contract compatibility |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fpokedex-prisma-next","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprisma%2Fpokedex-prisma-next","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprisma%2Fpokedex-prisma-next/lists"}