Skip to content

Document

concept
3 min readUpdated

Document manages project documentation through CategoryController, CategoryService, and DocumentController, including category creation, trees, updates, deletion, and document ordering. It creates, lists, searches, updates, deletes, renders, and organizes documents; handles draft-to-publish state, publication, versions, revisions, comparisons, and restoration; and exposes public document and navigation access with audience filtering. It rejects category, project, and document operations when resources are absent or organization access is unauthorized.

182 entities in atloria-monorepo/apps/api/src/document. 7 other subsystems depend on it, which makes it the 7th most depended-upon part of this codebase.

What it is made of

Its 182 entities sit in 26 files under atloria-monorepo/apps/api/src/document: 88 doc comments, 41 HTTP endpoints, 17 interfaces, 16 classes and 20 more. document.controller.ts holds 32 of them — more than any other file here. DocumentService is what the rest of it leans on: 3 of its own members depend on it, more than on anything else inside the boundary.

Where work enters

4 controllers publish 41 HTTP endpoints — 20 GET, 14 POST, 4 PATCH and 3 DELETE. They answer under /categories, /documents and /public. DocumentController carries 29 of them; the remaining 12 are split across 3 other controllers. Every one of them declares a guard — JwtAuthGuard on 37 and OrganizationGuard on 29.

  • CategoryControlleratloria-monorepo/apps/api/src/document/category.controller.ts:23
  • createatloria-monorepo/apps/api/src/document/category.controller.ts:33
  • listatloria-monorepo/apps/api/src/document/category.controller.ts:45
  • getTreeatloria-monorepo/apps/api/src/document/category.controller.ts:55
  • getatloria-monorepo/apps/api/src/document/category.controller.ts:70
  • updateatloria-monorepo/apps/api/src/document/category.controller.ts:81

How work moves through it

mermaid
flowchart LR
  CategoryController0["CategoryController"]
  CategoryService10["CategoryService"]
  CategoryController0 --> CategoryService10
  PrismaService20["PrismaService"]
  CategoryService10 --> PrismaService20
  stop["refused"]
  CategoryService10 -. "NotFoundException" .-> stop

Work enters at CategoryController and passes through 2 other components. Each step below is a dependency edge between two entities in this repository, followed outward in order.

  1. CategoryController takes the work first — atloria-monorepo/apps/api/src/document/category.controller.ts:23.
  2. Next, CategoryController hands off to CategoryServiceatloria-monorepo/apps/api/src/document/category.service.ts:14.
  3. Finally, CategoryService hands off to PrismaServiceatloria-monorepo/libs/database/src/lib/prisma.service.ts:28.

Where the work stops

  • CategoryService stops the work with NotFoundException when !project — “Project not found”, in 3 places.
  • CategoryService stops the work with NotFoundException when !category — “Category not found”, in 3 places.

When a step fails

  • PrismaService handles failure in 1 place: it lets it reach the caller in all 1.

How it refuses and fails

6 of its components record a refusal or a failure handler. All 6 of them refuse work outright, under a condition written into the component itself. Their catch blocks handle a failure that already happened in 7 places. Of those 7, 3 log it and continue, 3 discard it without recording anything and 1 turns it into a return value. DocumentService holds 3 of the silent ones — a failure discarded silently leaves no trace for whoever debugs this later.

Boundaries

7 other subsystems depend on this oneApi, Capture, Documentation, Manuals Insights, Project, Suggestion, Technical Docs. Changing what it exposes changes them.

Those 7 hold 15 edges between them, unevenly: Project reaches in across 5 edges, while 2 of them hold one each. 15 edges arrive against 12 leaving — more of this repository reaches into it than it reaches out to. What they reach is narrower than the folder: 7 of its 182 members carry every inbound edge — DraftDocumentModule (3), DraftDocumentService (3) and UrlService (3), plus 4 more. Of the 12 it sends out, 8 go to Database — more than to any other.

It depends on Database, Auth, Docs Repo, Documentation, and on nothing else in this repository.

How this code is named

These conventions cover most of the codebase. Learning them is faster than reading an index — each one lets you find any member of its family without looking it up.

PatternWhereCountExamples
*.dto.tssrc/document/dto/11category.dto.ts, create-version.dto.ts, document-stats.dto.ts, bulk-operations.dto.ts
*.service.tsacross the repository7url.service.ts, category.service.ts, document.service.ts, toc-builder.service.ts

Was this page helpful?

Download as PDF
Document — Atloria (self dogfood)