# jayrousjr/backend-with-nestjs architecture

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

- Interactive diagram: https://gitdiagram.com/jayrousjr/backend-with-nestjs
- Repository: https://github.com/jayrousjr/backend-with-nestjs

## Overview

This is a NestJS backend template exposing GraphQL and REST APIs. The main user workflow spans account registration and verification, authentication/session management, then protected user and role operations; additional product branches cover content and SEO, newsletter/campaign delivery, files, notifications, and visitor analytics. Services mediate between API handlers and persistence or integrations. The source excerpts support several service-level calls; other capabilities and connections below are included only where documented by the README or SOURCE INDEX. Some subsystems are represented at their directory path because their implementation was not sampled.

Main entry points: [`src/auth/auth.service.ts`](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/auth/auth.service.ts) (Auth workflows), [`src/users/users.service.ts`](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/users/users.service.ts) (User management), [`src/storage/storage.service.ts`](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/storage/storage.service.ts) (File operations), [`src/mail/mail.service.ts`](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/mail/mail.service.ts) (Mail queueing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity &amp; access"]
  node_auth_api["Auth endpoints<br/>[auth.controller.ts]"]
  node_auth_logic["Auth workflows<br/>[auth.service.ts]"]
  node_oauth["Google OAuth"]
  node_sessions[("Session records")]
end

subgraph group_content["Content &amp; outreach"]
  node_content["Post management<br/>[content.service.ts]"]
  node_posts[("Post records<br/>[post.repository.ts]")]
  node_seo["SEO redirects<br/>[seo.service.ts]"]
  node_newsletter["Newsletter subscriptions"]
  node_campaigns["Campaign management"]
end

subgraph group_accounts["User administration"]
  node_users_api["User management<br/>[users.service.ts]"]
  node_user_records[("User records<br/>[user.repository.ts]")]
  node_roles["Role management<br/>[roles.service.ts]"]
  node_permissions["Permission checks"]
end

subgraph group_platform["Platform services"]
  node_mail["Mail queueing<br/>[mail.service.ts]"]
  node_storage_api["File endpoints"]
  node_storage["File operations<br/>[storage.service.ts]"]
  node_file_records[("File records")]
  node_health["Health endpoint"]
  node_db["Prisma database access<br/>[prisma.service.ts]"]
end

subgraph group_signals["Events &amp; analytics"]
  node_notifications["Notifications"]
  node_live_events["Live event gateway<br/>[events.gateway.ts]"]
  node_visitors["Visitor analytics"]
end

node_client(("API client"))

node_client -->|"registers or logs in"| node_auth_api
node_auth_api -->|"delegates auth"| node_auth_logic
node_auth_api -->|"starts OAuth"| node_oauth
node_auth_logic -->|"looks up users"| node_user_records
node_auth_logic -->|"manages sessions"| node_sessions
node_auth_logic -->|"queues auth mail"| node_mail
node_auth_logic -->|"notifies users"| node_notifications
node_users_api -->|"reads and updates"| node_user_records
node_users_api -->|"resolves permissions"| node_permissions
node_users_api -->|"manages avatars"| node_storage
node_client -->|"manages profiles"| node_users_api
node_client -->|"manages roles"| node_roles
node_client -.->|"manages posts"| node_content
node_content -->|"queries posts"| node_posts
node_content -->|"uses redirects"| node_seo
node_seo -->|"checks post URLs"| node_posts
node_client -.->|"subscribes"| node_newsletter
node_newsletter -->|"queues confirmations"| node_mail
node_client -.->|"administers campaigns"| node_campaigns
node_campaigns -->|"queues campaign mail"| node_mail
node_campaigns -.->|"notifies creator"| node_notifications
node_client -->|"uploads files"| node_storage_api
node_storage_api -->|"delegates uploads"| node_storage
node_storage -->|"stores metadata"| node_file_records
node_storage -.->|"uses Prisma"| node_db
node_notifications -->|"emits notifications"| node_live_events
node_client -.->|"tracks page views"| node_visitors
node_client -->|"checks health"| node_health
node_client -.->|"persists domain data"| node_db
node_mail -.->|"delivers email"| node_client

click node_auth_api "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/auth/auth.controller.ts"
click node_auth_logic "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/auth/auth.service.ts"
click node_oauth "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/auth/google-oauth.service.ts"
click node_sessions "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/auth/session.repository.ts"
click node_users_api "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/users/users.service.ts"
click node_user_records "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/users/user.repository.ts"
click node_roles "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/roles/roles.service.ts"
click node_permissions "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/permissions/permissions.service.ts"
click node_content "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/content/content.service.ts"
click node_posts "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/content/post.repository.ts"
click node_seo "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/seo/seo.service.ts"
click node_newsletter "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/newsletter/newsletter.service.ts"
click node_campaigns "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/campaigns/campaigns.service.ts"
click node_mail "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/mail/mail.service.ts"
click node_storage_api "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/storage/storage.controller.ts"
click node_storage "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/storage/storage.service.ts"
click node_file_records "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/storage/storage.repository.ts"
click node_notifications "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/notifications/notifications.service.ts"
click node_live_events "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/events/events.gateway.ts"
click node_visitors "https://github.com/jayrousjr/backend-with-nestjs/tree/main/src/visitors"
click node_health "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/health/health.controller.ts"
click node_db "https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/prisma/prisma.service.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_auth_api,node_auth_logic,node_oauth,node_sessions,node_client toneBlue
class node_content,node_posts,node_seo,node_newsletter,node_campaigns toneAmber
class node_users_api,node_user_records,node_roles,node_permissions toneMint
class node_mail,node_storage_api,node_storage,node_file_records,node_health,node_db toneRose
class node_notifications,node_live_events,node_visitors toneIndigo
```

## Components

### Identity & access

- [Auth endpoints](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/auth/auth.controller.ts): `src/auth/auth.controller.ts`
- [Auth workflows](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/auth/auth.service.ts): `src/auth/auth.service.ts`
- [Google OAuth](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/auth/google-oauth.service.ts): `src/auth/google-oauth.service.ts`
- [Session records](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/auth/session.repository.ts): `src/auth/session.repository.ts`

### Content & outreach

- [Post management](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/content/content.service.ts): `src/content/content.service.ts`
- [Post records](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/content/post.repository.ts): `src/content/post.repository.ts`
- [SEO redirects](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/seo/seo.service.ts): `src/seo/seo.service.ts`
- [Newsletter subscriptions](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/newsletter/newsletter.service.ts): `src/newsletter/newsletter.service.ts`
- [Campaign management](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/campaigns/campaigns.service.ts): `src/campaigns/campaigns.service.ts`

### User administration

- [User management](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/users/users.service.ts): `src/users/users.service.ts`
- [User records](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/users/user.repository.ts): `src/users/user.repository.ts`
- [Role management](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/roles/roles.service.ts): `src/roles/roles.service.ts`
- [Permission checks](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/permissions/permissions.service.ts): `src/permissions/permissions.service.ts`

### Platform services

- [Mail queueing](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/mail/mail.service.ts): `src/mail/mail.service.ts`
- [File endpoints](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/storage/storage.controller.ts): `src/storage/storage.controller.ts`
- [File operations](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/storage/storage.service.ts): `src/storage/storage.service.ts`
- [File records](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/storage/storage.repository.ts): `src/storage/storage.repository.ts`
- [Health endpoint](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/health/health.controller.ts): `src/health/health.controller.ts`
- [Prisma database access](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/prisma/prisma.service.ts): `src/prisma/prisma.service.ts`

### Events & analytics

- [Notifications](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/notifications/notifications.service.ts): `src/notifications/notifications.service.ts`
- [Live event gateway](https://github.com/jayrousjr/backend-with-nestjs/blob/main/src/events/events.gateway.ts): `src/events/events.gateway.ts`
- [Visitor analytics](https://github.com/jayrousjr/backend-with-nestjs/tree/main/src/visitors): `src/visitors`

### Other components

- **API client**

## Connections

- API client → Auth endpoints: registers or logs in
- Auth endpoints → Auth workflows: delegates auth (evidence: `src/auth/auth.controller.ts`)
- Auth endpoints → Google OAuth: starts OAuth (evidence: `src/auth/auth.controller.ts`)
- Auth workflows → User records: looks up users (evidence: `src/auth/auth.service.ts`)
- Auth workflows → Session records: manages sessions (evidence: `src/auth/auth.service.ts`)
- Auth workflows → Mail queueing: queues auth mail (evidence: `src/auth/auth.service.ts`)
- Auth workflows → Notifications: notifies users (evidence: `src/auth/auth.service.ts`)
- User management → User records: reads and updates (evidence: `src/users/users.service.ts`)
- User management → Permission checks: resolves permissions (evidence: `src/users/users.service.ts`)
- User management → File operations: manages avatars (evidence: `src/users/users.service.ts`)
- API client → User management: manages profiles
- API client → Role management: manages roles
- API client → Post management: manages posts
- Post management → Post records: queries posts (evidence: `src/content/content.service.ts`)
- Post management → SEO redirects: uses redirects (evidence: `src/content/content.service.ts`)
- SEO redirects → Post records: checks post URLs (evidence: `src/seo/seo.service.ts`)
- API client → Newsletter subscriptions: subscribes
- Newsletter subscriptions → Mail queueing: queues confirmations (evidence: `src/newsletter/newsletter.service.ts`)
- API client → Campaign management: administers campaigns
- Campaign management → Mail queueing: queues campaign mail (evidence: `src/campaigns/campaigns.service.ts`)
- Campaign management → Notifications: notifies creator (evidence: `src/campaigns/campaigns.service.ts`)
- API client → File endpoints: uploads files (evidence: `src/storage/storage.controller.ts`)
- File endpoints → File operations: delegates uploads (evidence: `src/storage/storage.controller.ts`)
- File operations → File records: stores metadata (evidence: `src/storage/storage.service.ts`)
- File operations → Prisma database access: uses Prisma
- Notifications → Live event gateway: emits notifications (evidence: `src/notifications/notifications.service.ts`)
- API client → Visitor analytics: tracks page views
- API client → Health endpoint: checks health
- API client → Prisma database access: persists domain data
- Mail queueing → API client: delivers email
