graphql modules
Fact8 Modules
Case Study
Updated: 2026-10-01A full-stack social media ecosystem featuring a NestJS GraphQL backend with Prisma and Redis Pub/Sub, a responsive Next.js web application with Apollo Client and Zustand, and a cross-platform mobile client.
graphql modules
Fact8 Modules
database models
Fact12 Prisma Models
pubsub broker
FactRedis Pub/Sub
clients
FactWeb (Next.js) + Mobile
Single source of truth (TypeScript types -> schema), tight integration with NestJS dependency injection and guards.
Trade-off: Faster developer experience and type-safety vs larger generated schema artifact; requires extra care to keep DTOs/resolvers performant (no schema stitching).
Strong TypeScript integration, migration history, and expressive relation modeling. Unique/index constraints (e.g., @@unique([postId, createdById])) encode idempotency rules.
Trade-off: Abstraction simplifies queries but can hide SQL optimizations; for complex reporting queries raw SQL or materialized views may be required.
Enables multi-instance deployment without in-process pubsub; Redis offers low-latency fan-out and familiar operational model.
Trade-off: Redis cluster adds operational cost; developer must ensure message topology and retention are managed; subscriber reconnection semantics must be hardened.
Provides a single backend service that manages social data (profiles, feed, chat, notifications) with realtime updates and strong type safety for clients.
Monolithic, modular NestJS application using an event-driven style internally (CQRS + EventEmitter) with external real-time delivery via Redis Pub/Sub and GraphQL Subscriptions.
Key measurable signals: Prisma migrations (8), DB models (11), GraphQL schema types (approx) (~50).
| Dimension | Selected Option | Impact | Compromise |
|---|---|---|---|
| API protocol | GraphQL (code-first) + websocket subscriptions | Strong typing, flexible client-driven queries, native realtime push | More complex server-side resolver performance concerns and over-fetching prevention must be managed |
| Data access | Prisma ORM on PostgreSQL | Type-safe queries, fast iteration, migrations versioned | Complex analytical queries may need raw SQL or separate OLAP store |
Failure Path & Recovery Invariants
DB outage: Behavior: Prisma client throws; PrismaService retry logic attempts reconnect and eventually surfaces error.
Add distributed tracing (OpenTelemetry) and metrics (Prometheus) to correlate GraphQL operations, DB queries, and Redis pub/sub latency.
Introduce a durable background job queue (e.g., BullMQ / Redis Streams) for side effects (email, push notifications, heavy denormalizations) to improve resiliency and allow retries with dead-lettering.