# mraghaei/jobgraph-backend architecture

> Architecture diagram of the GitHub repository mraghaei/jobgraph-backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mraghaei/jobgraph-backend
- Repository: https://github.com/mraghaei/jobgraph-backend

## Overview

#### Purpose and workspace shape
This is a pnpm/Turborepo TypeScript monorepo containing two NestJS backend applications and shared database/configuration packages. The root README is stale starter text (it references absent Next.js apps); the file tree is authoritative. Workspace orchestration is defined by `pnpm-workspace.yaml`, `turbo.json`, and `package.json`.

#### Service entry points
Two independently runnable NestJS HTTP services exist:
- Core API bootstraps from `apps/core-api/src/main.ts`, composes its application in `apps/core-api/src/app.module.ts`, and exposes the initial controller/service layer in `apps/core-api/src/app.controller.ts` and `apps/core-api/src/app.service.ts`.
- Scraper is a separate NestJS process, bootstrapped via `apps/scraper/src/main.ts`, with its own module boundary at `apps/scraper/src/app.module.ts` and initial controller/service layer under `apps/scraper/src/`.

Their separate `package.json` files and Nest CLI configurations indicate independently buildable/deployable service units.

#### Core API boundary
`apps/core-api` is the primary API-facing service boundary. Nest module composition should be rooted in `apps/core-api/src/app.module.ts`; inbound HTTP handling belongs in `apps/core-api/src/app.controller.ts`; application behavior is currently represented by `apps/core-api/src/app.service.ts`. This is the natural integration point for consumers, authentication, request validation, and database-backed domain APIs as the system expands.

#### Scraping boundary
`apps/scraper` isolates scraping/collection work from the public API runtime. Its control flow is Nest bootstrap → module registration → controller-triggered service logic:
`apps/scraper/src/main.ts` → `apps/scraper/src/app.module.ts` → `apps/scraper/src/app.controller.ts` / `apps/scraper/src/app.service.ts`.
No job queue, scheduler, browser runtime, or external target integration is visible in the repository tree yet; those would need explicit implementation rather than assumed infrastructure.

#### Shared persistence layer
`packages/database` is the repository’s persistence contract and Prisma integration boundary. The data model is defined in `packages/database/prisma/schema.prisma`; Prisma configuration is in `packages/database/prisma.config.ts`; the consumable TypeScript database export/client boundary is `packages/database/src/index.ts`. Both services can depend on this package rather than owning divergent database clients or schemas. The actual database vendor and deployment topology cannot be established from the provided files.

#### Build and runtime infrastructure
Node.js/TypeScript is the material runtime; NestJS is used by both applications, as indicated by their `nest-cli.json` and source layout. pnpm manages workspace dependencies and Turbo coordinates cross-workspace build/dev tasks and caching through `pnpm-workspace.yaml` and `turbo.json`. Vercel remote cache is mentioned only as optional Turborepo infrastructure, not as an application-hosting dependency.

#### Shared engineering contracts
Repository-wide TypeScript and linting policy are centralized rather than copied into apps: `packages/typescript-config/base.json` and `packages/eslint-config/base.js` provide shared baselines. App-local `tsconfig.json` and ESLint configs adapt those standards to Nest services. This creates a clear boundary: shared packages define build/persistence contracts, while each app owns its process bootstrap and transport behavior.

Main entry points: [`apps/core-api/src/main.ts`](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/main.ts) (Core bootstrap), [`apps/scraper/src/main.ts`](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/scraper/src/main.ts) (Scraper bootstrap), [`turbo.json`](https://github.com/mraghaei/jobgraph-backend/blob/main/turbo.json) (Turborepo tasks), [`apps/core-api/src/app.module.ts`](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/app.module.ts) (Core module)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace"]
  node_pnpm["pnpm workspace<br/>workspace manager"]
  node_turbo["Turborepo tasks<br/>build orchestrator<br/>[turbo.json]"]
  node_ts_policy["TypeScript baseline<br/>shared compiler policy<br/>[base.json]"]
  node_lint_policy["ESLint baseline<br/>shared lint policy<br/>[base.js]"]
end

subgraph group_core["Core API"]
  node_core_main{{"Core bootstrap<br/>NestJS entry point<br/>[main.ts]"}}
  node_core_module["Core module<br/>NestJS module<br/>[app.module.ts]"]
  node_core_controller["Core HTTP controller<br/>HTTP transport<br/>[app.controller.ts]"]
  node_core_service["Core application service<br/>application logic<br/>[app.service.ts]"]
end

subgraph group_scraper["Scraper"]
  node_scraper_main{{"Scraper bootstrap<br/>NestJS entry point<br/>[main.ts]"}}
  node_scraper_module["Scraper module<br/>NestJS module<br/>[app.module.ts]"]
  node_scraper_controller["Scraper controller<br/>HTTP transport<br/>[app.controller.ts]"]
  node_scraper_service["Scraper application service<br/>collection logic<br/>[app.service.ts]"]
end

subgraph group_persistence["Persistence"]
  node_prisma_schema["Prisma schema<br/>data model<br/>[schema.prisma]"]
  node_prisma_config["Prisma config<br/>[prisma.config.ts]"]
  node_database_package[("Database client export<br/>shared database package<br/>[index.ts]")]
end

node_pnpm -->|"coordinates workspace tasks"| node_turbo
node_turbo -->|"builds and runs"| node_core_main
node_turbo -->|"builds and runs"| node_scraper_main
node_ts_policy -.->|"shared TypeScript policy"| node_core_main
node_ts_policy -.->|"shared TypeScript policy"| node_scraper_main
node_lint_policy -.->|"shared lint policy"| node_core_main
node_lint_policy -.->|"shared lint policy"| node_scraper_main
node_core_main -->|"boots"| node_core_module
node_core_module -->|"registers"| node_core_controller
node_core_module -->|"provides"| node_core_service
node_core_controller -->|"invokes"| node_core_service
node_scraper_main -->|"boots"| node_scraper_module
node_scraper_module -->|"registers"| node_scraper_controller
node_scraper_module -->|"provides"| node_scraper_service
node_scraper_controller -->|"invokes"| node_scraper_service
node_prisma_config -->|"configures"| node_prisma_schema
node_prisma_schema -->|"defines client model"| node_database_package
node_core_service -.->|"may use persistence contract"| node_database_package
node_scraper_service -.->|"may use persistence contract"| node_database_package

click node_pnpm "https://github.com/mraghaei/jobgraph-backend/blob/main/pnpm-workspace.yaml"
click node_turbo "https://github.com/mraghaei/jobgraph-backend/blob/main/turbo.json"
click node_ts_policy "https://github.com/mraghaei/jobgraph-backend/blob/main/packages/typescript-config/base.json"
click node_lint_policy "https://github.com/mraghaei/jobgraph-backend/blob/main/packages/eslint-config/base.js"
click node_core_main "https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/main.ts"
click node_core_module "https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/app.module.ts"
click node_core_controller "https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/app.controller.ts"
click node_core_service "https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/app.service.ts"
click node_scraper_main "https://github.com/mraghaei/jobgraph-backend/blob/main/apps/scraper/src/main.ts"
click node_scraper_module "https://github.com/mraghaei/jobgraph-backend/blob/main/apps/scraper/src/app.module.ts"
click node_scraper_controller "https://github.com/mraghaei/jobgraph-backend/blob/main/apps/scraper/src/app.controller.ts"
click node_scraper_service "https://github.com/mraghaei/jobgraph-backend/blob/main/apps/scraper/src/app.service.ts"
click node_prisma_schema "https://github.com/mraghaei/jobgraph-backend/blob/main/packages/database/prisma/schema.prisma"
click node_prisma_config "https://github.com/mraghaei/jobgraph-backend/blob/main/packages/database/prisma.config.ts"
click node_database_package "https://github.com/mraghaei/jobgraph-backend/blob/main/packages/database/src/index.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_pnpm,node_turbo,node_ts_policy,node_lint_policy toneBlue
class node_core_main,node_core_module,node_core_controller,node_core_service toneAmber
class node_scraper_main,node_scraper_module,node_scraper_controller,node_scraper_service toneMint
class node_prisma_schema,node_prisma_config,node_database_package toneRose
```

## Components

### Workspace

Monorepo orchestration and shared engineering policy.

- [pnpm workspace](https://github.com/mraghaei/jobgraph-backend/blob/main/pnpm-workspace.yaml): workspace manager · `pnpm-workspace.yaml`
- [Turborepo tasks](https://github.com/mraghaei/jobgraph-backend/blob/main/turbo.json): build orchestrator · `turbo.json`
- [TypeScript baseline](https://github.com/mraghaei/jobgraph-backend/blob/main/packages/typescript-config/base.json): shared compiler policy · `packages/typescript-config/base.json`
- [ESLint baseline](https://github.com/mraghaei/jobgraph-backend/blob/main/packages/eslint-config/base.js): shared lint policy · `packages/eslint-config/base.js`

### Core API

Primary independently deployable NestJS HTTP service.

- [Core bootstrap](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/main.ts): NestJS entry point · `apps/core-api/src/main.ts`
- [Core module](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/app.module.ts): NestJS module · Composes the Core API application. · `apps/core-api/src/app.module.ts`
- [Core HTTP controller](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/app.controller.ts): HTTP transport · `apps/core-api/src/app.controller.ts`
- [Core application service](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/core-api/src/app.service.ts): application logic · `apps/core-api/src/app.service.ts`

### Scraper

Separate NestJS collection-service runtime.

- [Scraper bootstrap](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/scraper/src/main.ts): NestJS entry point · `apps/scraper/src/main.ts`
- [Scraper module](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/scraper/src/app.module.ts): NestJS module · Composes the scraper process. · `apps/scraper/src/app.module.ts`
- [Scraper controller](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/scraper/src/app.controller.ts): HTTP transport · `apps/scraper/src/app.controller.ts`
- [Scraper application service](https://github.com/mraghaei/jobgraph-backend/blob/main/apps/scraper/src/app.service.ts): collection logic · `apps/scraper/src/app.service.ts`

### Persistence

Shared Prisma persistence contract.

- [Prisma schema](https://github.com/mraghaei/jobgraph-backend/blob/main/packages/database/prisma/schema.prisma): data model · `packages/database/prisma/schema.prisma`
- [Prisma config](https://github.com/mraghaei/jobgraph-backend/blob/main/packages/database/prisma.config.ts): Prisma configuration · `packages/database/prisma.config.ts`
- [Database client export](https://github.com/mraghaei/jobgraph-backend/blob/main/packages/database/src/index.ts): shared database package · Consumable TypeScript persistence boundary for both services. · `packages/database/src/index.ts`

## Connections

- pnpm workspace → Turborepo tasks: coordinates workspace tasks
- Turborepo tasks → Core bootstrap: builds and runs
- Turborepo tasks → Scraper bootstrap: builds and runs
- TypeScript baseline → Core bootstrap: shared TypeScript policy
- TypeScript baseline → Scraper bootstrap: shared TypeScript policy
- ESLint baseline → Core bootstrap: shared lint policy
- ESLint baseline → Scraper bootstrap: shared lint policy
- Core bootstrap → Core module: boots
- Core module → Core HTTP controller: registers
- Core module → Core application service: provides
- Core HTTP controller → Core application service: invokes
- Scraper bootstrap → Scraper module: boots
- Scraper module → Scraper controller: registers
- Scraper module → Scraper application service: provides
- Scraper controller → Scraper application service: invokes
- Prisma config → Prisma schema: configures
- Prisma schema → Database client export: defines client model
- Core application service → Database client export: may use persistence contract
- Scraper application service → Database client export: may use persistence contract
