{"id":44507549,"url":"https://github.com/fwal/effect-firebase","last_synced_at":"2026-03-08T23:16:02.542Z","repository":{"id":322329824,"uuid":"1072463782","full_name":"fwal/effect-firebase","owner":"fwal","description":"Firebase adapters for Effect","archived":false,"fork":false,"pushed_at":"2026-03-04T15:18:15.000Z","size":1601,"stargazers_count":2,"open_issues_count":6,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-04T22:08:34.471Z","etag":null,"topics":["effect","effect-ts","firebase","firestore","google-cloud","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fwal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-10-08T18:52:52.000Z","updated_at":"2026-03-04T14:59:43.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/fwal/effect-firebase","commit_stats":null,"previous_names":["fwal/effect-firebase"],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/fwal/effect-firebase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwal%2Feffect-firebase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwal%2Feffect-firebase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwal%2Feffect-firebase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwal%2Feffect-firebase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fwal","download_url":"https://codeload.github.com/fwal/effect-firebase/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwal%2Feffect-firebase/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30182687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T14:42:24.748Z","status":"ssl_error","status_checked_at":"2026-03-06T14:42:14.925Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["effect","effect-ts","firebase","firestore","google-cloud","typescript"],"created_at":"2026-02-13T11:36:43.872Z","updated_at":"2026-03-08T23:16:02.520Z","avatar_url":"https://github.com/fwal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Effect Firebase\n\nType-safe Firebase integration for [Effect](https://effect.website), providing schemas, models, and utilities for building Firebase applications with Effect's powerful ecosystem.\n\n[![npm version](https://img.shields.io/npm/v/effect-firebase.svg)](https://www.npmjs.com/package/effect-firebase)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n\u003e [!WARNING]\n\u003e This project is still under heavy development and APIs may change frequently.\n\n## Overview\n\nEffect Firebase is a comprehensive library for integrating Firebase services with Effect, providing:\n\n- 🔒 **Type-Safe APIs** - Leverage TypeScript and Effect schemas for complete type safety\n- 📦 **Model \u0026 Repository Pattern** - Clean abstractions for data access with automatic validation\n- 🔍 **Type-Safe Queries** - Fluent query builder with compile-time field validation\n- 🎯 **SDK Agnostic Core** - Works with both Firebase Admin SDK and Client SDK\n- 🧪 **Testable** - Mock implementations for fast, isolated testing\n- 🚀 **Effect Native** - Built on Effect's composition and error handling\n\n## Packages\n\nThis monorepo contains several packages for different use cases:\n\n| Package                                           | Description                                                 | Version                                                                                                                   |\n| ------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |\n| [**effect-firebase**](./packages/effect-firebase) | Core library with schemas, models, and abstractions         | [![npm](https://img.shields.io/npm/v/effect-firebase.svg)](https://www.npmjs.com/package/effect-firebase)                 |\n| [**@effect-firebase/admin**](./packages/admin)    | Firebase Admin SDK implementation + Cloud Functions support | [![npm](https://img.shields.io/npm/v/@effect-firebase/admin.svg)](https://www.npmjs.com/package/@effect-firebase/admin)   |\n| [**@effect-firebase/client**](./packages/client)  | Firebase Client SDK implementation for web/mobile apps      | [![npm](https://img.shields.io/npm/v/@effect-firebase/client.svg)](https://www.npmjs.com/package/@effect-firebase/client) |\n| [**@effect-firebase/mock**](./packages/mock)      | Mock implementation for testing                             | [![npm](https://img.shields.io/npm/v/@effect-firebase/mock.svg)](https://www.npmjs.com/package/@effect-firebase/mock)     |\n\n## Quick Start\n\n### Installation\n\nChoose the packages you need based on your use case:\n\n```bash\n# Core library (required)\nnpm install effect-firebase effect @effect/experimental\n\n# For server/admin applications or Cloud Functions\nnpm install @effect-firebase/admin firebase-admin firebase-functions\n\n# For client applications (web/mobile)\nnpm install @effect-firebase/client firebase\n\n# For testing (dev dependency)\nnpm install --save-dev @effect-firebase/mock\n```\n\n### Example: Building a Blog\n\n#### 1. Define Your Model\n\n```typescript\nimport { Schema } from 'effect';\nimport { Model } from 'effect-firebase';\n\nconst PostId = Schema.String.pipe(Schema.brand('PostId'));\nconst AuthorId = Schema.String.pipe(Schema.brand('AuthorId'));\nconst AuthorRef = Model.Reference(AuthorId, 'authors');\n\nclass PostModel extends Model.Class\u003cPostModel\u003e('PostModel')({\n  id: Model.Generated(PostId),\n  createdAt: Model.DateTimeInsert,\n  updatedAt: Model.DateTimeUpdate,\n  author: AuthorRef,\n  title: Schema.String,\n  content: Schema.String,\n  status: Schema.Literal('draft', 'published'),\n  likes: Schema.Number,\n}) {}\n```\n\n#### 2. Create a Repository\n\n```typescript\nimport { Effect } from 'effect';\nimport { Model, Query } from 'effect-firebase';\n\nexport const PostRepository = Model.makeRepository(PostModel, {\n  collectionPath: 'posts',\n  idField: 'id',\n  spanPrefix: 'app.PostRepository',\n}).pipe(\n  Effect.map((repository) =\u003e ({\n    ...repository,\n    // Add custom methods\n    publishedPosts: () =\u003e\n      repository.queryStream(\n        Query.and(\n          Query.where('status', '==', 'published'),\n          Query.orderBy('createdAt', 'desc')\n        )\n      ),\n  }))\n);\n```\n\n#### 3. Use in Your Application\n\n**Client Application:**\n\n```typescript\nimport { Effect } from 'effect';\nimport { initializeApp } from 'firebase/app';\nimport { Client } from '@effect-firebase/client';\nimport { PostRepository } from './repositories/post-repository';\n\nconst app = initializeApp({\n  projectId: 'your-project-id',\n});\n\nconst program = Effect.gen(function* () {\n  const repo = yield* PostRepository;\n\n  // Create a post\n  const postId = yield* repo.add({\n    title: 'Hello Effect Firebase',\n    content: 'Building type-safe apps',\n    author: AuthorId.make('author-123'),\n    status: 'published',\n    likes: 0,\n  });\n\n  // Query posts\n  const posts = yield* repo.query(Query.where('status', '==', 'published'));\n\n  return { postId, posts };\n}).pipe(Effect.provide(PostRepository), Effect.provide(Client.layer({ app })));\n\nEffect.runPromise(program).then(console.log);\n```\n\n**Cloud Function:**\n\n```typescript\nimport { Effect, Layer } from 'effect';\nimport { initializeApp } from 'firebase-admin/app';\nimport { Admin, FunctionsRuntime, onCallEffect } from '@effect-firebase/admin';\nimport { PostRepository } from './repositories/post-repository';\n\nconst runtime = FunctionsRuntime.make(\n  Layer.mergeAll(Admin.layer({ app: initializeApp() }), PostRepository)\n);\n\nexport const createPost = onCallEffect({ runtime }, (request) =\u003e\n  Effect.gen(function* () {\n    const repo = yield* PostRepository;\n    const { title, content } = request.data;\n\n    const postId = yield* repo.add({\n      title,\n      content,\n      author: AuthorId.make(request.auth!.uid),\n      status: 'draft',\n      likes: 0,\n    });\n\n    return { postId };\n  })\n);\n```\n\n**Testing:**\n\n```typescript\nimport { Effect } from 'effect';\nimport { layer as mockFirestore } from '@effect-firebase/mock';\n\nconst test = Effect.gen(function* () {\n  const repo = yield* PostRepository;\n\n  const postId = yield* repo.add({\n    title: 'Test Post',\n    content: 'Test Content',\n    author: AuthorId.make('test-author'),\n    status: 'draft',\n    likes: 0,\n  });\n\n  const post = yield* repo.getById(postId);\n  expect(post.title).toBe('Test Post');\n}).pipe(Effect.provide(PostRepository), Effect.provide(mockFirestore));\n\nawait Effect.runPromise(test);\n```\n\n## Features\n\n### Firestore\n\n#### ✅ Schema Support\n\nPlatform-agnostic schemas for Firestore types:\n\n- `Timestamp` (including server timestamps)\n- `GeoPoint`\n- `DocumentReference`\n\n#### ✅ Model \u0026 Repository\n\n- Type-safe CRUD operations\n- Automatic schema validation\n- Generated fields (IDs, timestamps)\n- Custom repository methods\n- Real-time streaming support\n\n#### ✅ Type-Safe Queries\n\n- Field validation at compile time\n- Fluent query builder API\n- Support for all Firestore operators\n- Composite queries (AND/OR)\n- Pagination support\n- Ordering and limiting\n\n### Cloud Functions (Admin)\n\n- `onRequest` - HTTP endpoints\n- `onCall` - Callable functions\n- `onDocumentCreated` - Firestore trigger\n- `onDocumentUpdated` - Firestore trigger\n- `onDocumentDeleted` - Firestore trigger\n- `onDocumentWritten` - Firestore trigger\n- `onMessagePublished` - Pub/Sub trigger\n- `onTaskDispatched` - Cloud Tasks trigger\n\n### Planned Features\n\n- 🔄 Firebase Realtime Database support\n- 🔄 Firebase Storage integration\n- 🔄 Firebase Data Connect support\n- 🔄 Additional Cloud Functions triggers\n\n## Documentation\n\nEach package has comprehensive documentation:\n\n- **[effect-firebase](./packages/effect-firebase/README.md)** - Core classes, schemas, models, queries\n- **[@effect-firebase/admin](./packages/admin/README.md)** - Server-side usage i.e. Cloud Functions\n- **[@effect-firebase/client](./packages/client/README.md)** - Client-side usage\n- **[@effect-firebase/mock](./packages/mock/README.md)** - Testing guide\n\n## Why Effect Firebase?\n\n### Type Safety\n\nTraditional Firebase code:\n\n```typescript\n// ❌ No type safety\nconst posts = await db\n  .collection('posts')\n  .where('staus', '==', 'published') // Typo! Runtime error\n  .get();\n\nposts.forEach((doc) =\u003e {\n  const data = doc.data(); // any type\n  console.log(data.titel); // Typo! No error\n});\n```\n\nWith Effect Firebase:\n\n```typescript\n// ✅ Compile-time type safety\nconst posts =\n  yield *\n  repo.query(\n    Query.where('status', '==', 'published') // Compile error if field doesn't exist\n  );\n\nposts.forEach((post) =\u003e {\n  console.log(post.title); // Fully typed - IDE autocomplete works\n  // post.titel // Compile error\n});\n```\n\n### Error Handling\n\nTraditional Firebase:\n\n```typescript\n// ❌ Error handling is manual and inconsistent\ntry {\n  const doc = await db.collection('posts').doc(id).get();\n  if (!doc.exists) {\n    throw new Error('Not found');\n  }\n  const data = doc.data();\n  // What if data is invalid?\n} catch (error) {\n  // What type is error?\n  console.error(error);\n}\n```\n\nWith Effect Firebase:\n\n```typescript\n// ✅ Structured error handling with Effect\nconst program = repo.getById(id).pipe(\n  Effect.catchTag('NoSuchElementException', () =\u003e Effect.succeed(null)),\n  Effect.catchTag('ParseError', (error) =\u003e\n    Effect.fail(new ValidationError({ cause: error }))\n  ),\n  Effect.catchTag('FirestoreError', (error) =\u003e\n    Effect.fail(new DatabaseError({ cause: error }))\n  )\n);\n```\n\n### Composability\n\n```typescript\n// ✅ Compose operations easily with Effect\nconst program = Effect.gen(function* () {\n  const postRepo = yield* PostRepository;\n  const userRepo = yield* UserRepository;\n\n  // Get user and their posts in parallel\n  const [user, posts] = yield* Effect.all(\n    [\n      userRepo.getById(userId),\n      postRepo.query(Query.where('authorId', '==', userId)),\n    ],\n    { concurrency: 'unbounded' }\n  );\n\n  return { user, posts };\n});\n```\n\n## Development\n\nThis project uses [Nx](https://nx.dev) for monorepo management.\n\n### Setup\n\n```bash\n# Clone the repository\ngit clone https://github.com/fwal/effect-firebase.git\ncd effect-firebase\n\n# Install dependencies\npnpm install\n```\n\n### Build\n\n```bash\n# Build all packages\nnx run-many -t build\n\n# Build specific package\nnx build effect-firebase\n```\n\n### Test\n\n```bash\n# Run all tests\nnx run-many -t test\n\n# Test specific package\nnx test effect-firebase\n```\n\n### Example Application\n\nThe repository includes a full example application demonstrating all features:\n\n```bash\n# Terminal 1: Start Firebase emulators\npnpm example:emulator\n\n# Terminal 2: Start the example app\npnpm example:hosting\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n## License\n\nMIT\n\n## Resources\n\n- [Effect Documentation](https://effect.website)\n- [Firebase Documentation](https://firebase.google.com/docs)\n- [Repository](https://github.com/fwal/effect-firebase)\n- [Issue Tracker](https://github.com/fwal/effect-firebase/issues)\n\n## Acknowledgments\n\nBuilt with:\n\n- [Effect](https://effect.website) - Powerful TypeScript framework\n- [Firebase](https://firebase.google.com) - Application development platform\n- [Nx](https://nx.dev) - Smart monorepo tooling\n\nThe Model and Repository pattern is heavily inspired by the excellent [`@effect/sql`](https://github.com/Effect-TS/effect/tree/main/packages/sql) family of packages, adapted for Firestore's document-based paradigm.\n\n---\n\n**Questions or feedback?** Open an issue on [GitHub](https://github.com/fwal/effect-firebase/issues)!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwal%2Feffect-firebase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffwal%2Feffect-firebase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwal%2Feffect-firebase/lists"}