Skip to content

Database

concept
2 min readUpdated

The Database subsystem manages application database access through DatabaseModule, PrismaService, and RedisService, and guards tenant-scoped Prisma reads and mutations against cross-tenant access through createTenantBackstop. It propagates per-request tenant state with runWithTenantContext and getTenantContext, detects intentional organization scoping via whereHasOrgScope, and supports explicit system-level scoping bypasses through runWithTenantBypass.

12 entities in atloria-monorepo/libs/database/src/lib. 60 other subsystems depend on it, which makes it the most depended-upon part of this codebase.

What it is made of

Its 12 entities sit in 6 files under atloria-monorepo/libs/database/src/lib: 6 functions, 2 services, 2 interfaces, 1 module and 1 more. tenant-backstop.ts holds 4 of them — more than any other file here. RedisService declares 12 methods, the widest surface here.

Where work enters

  • DatabaseModuleatloria-monorepo/libs/database/src/lib/database.module.ts:7

How it refuses and fails

2 of its components record a refusal or a failure handler. 1 of them refuses work outright, under a condition written into the component itself. Their catch blocks handle a failure that already happened in 9 places. Of those 9, 4 discard it without recording anything, 2 log it and continue, 2 turn it into a return value and 1 lets it reach the caller. RedisService holds 4 of the silent ones — a failure discarded silently leaves no trace for whoever debugs this later.

Boundaries

60 other subsystems depend on this oneActivity, Ai, Analytics, Api, Assets, Audience, Audit, Auth, Billing, Bitbucket, Boards, Branding, Capture, Change Request, Changelog, Collaboration, Comment, Content Tasks, Dashboard, Doc Version, Docs Pr, Docs Repo, Document, Documentation, Events, Git Sync, Github, Github App, Gitlab, Graph, Invitation, Issues, L10n, Manuals Insights, Notification, Ops, Organization, Parser, Parsing, Platform, Pme, Project, Reader Access, Reader Account, Scim, Screenshot, Sdk, Snippets, Suggestion, Support Agent, Technical Docs, Template, Tours, Trial, Webhooks, Code Analyzer, Users, Atloria Monorepo, Screenshot Worker, Sdk Worker. Changing what it exposes changes them.

Those 60 hold 211 edges between them, unevenly: Technical Docs reaches in across 19 edges, while 4 of them hold one each. What they reach is narrower than the folder: 3 of its 12 members carry every inbound edge — PrismaService (142), DatabaseModule (57) and RedisService (12).

It depends on no other subsystem in this repository — it is a leaf.

Was this page helpful?

Download as PDF
Database — Atloria (self dogfood)