# lujakob/nestjs-realworld-example-app architecture

> Architecture diagram of the GitHub repository lujakob/nestjs-realworld-example-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lujakob/nestjs-realworld-example-app
- Repository: https://github.com/lujakob/nestjs-realworld-example-app

## Overview

This NestJS application implements the RealWorld API: clients authenticate or register, then use article, comment, favorite, profile/follow, and tag endpoints. Controllers delegate domain work to services, which use TypeORM repositories backed by MySQL. JWT authentication and Swagger API documentation are documented capabilities. The README describes Prisma as an alternate branch; this tree and sampled source support the TypeORM runtime map. Service internals are sampled unevenly, so only evidenced service-to-service and persistence links are shown.

Main entry points: [`src/article/article.service.ts`](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/article/article.service.ts) (Article service), [`src/app.module.ts`](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/app.module.ts) (Application module), [`src/profile/profile.service.ts`](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/profile/profile.service.ts) (Profile service), [`src/user/user.entity.ts`](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/user.entity.ts) (User entity)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and auth"]
  node_runtime["Nest runtime<br/>[main.ts]"]
  node_app["Application module<br/>[app.module.ts]"]
  node_auth["JWT middleware<br/>[auth.middleware.ts]"]
  node_userapi["User API<br/>[user.controller.ts]"]
  node_swagger["Swagger docs<br/>[main.ts]"]
end

subgraph group_content["Article content"]
  node_articleapi["Article API"]
  node_articlesvc["Article service<br/>[article.service.ts]"]
  node_articledata["Articles and comments<br/>[article.entity.ts]"]
  node_commentdata["Comment entity<br/>[comment.entity.ts]"]
  node_tagapi["Tag API<br/>[tag.controller.ts]"]
  node_tagsvc["Tag service<br/>[tag.service.ts]"]
end

subgraph group_social["Users and social"]
  node_profileapi["Profile API"]
  node_profilesvc["Profile service<br/>[profile.service.ts]"]
  node_followdata["Follow entity<br/>[follows.entity.ts]"]
  node_usersvc["User service<br/>[user.service.ts]"]
  node_userdata["User entity<br/>[user.entity.ts]"]
end

subgraph group_storage["Persistence"]
  node_database[("MySQL database")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_userapi
node_client -->|"sends requests"| node_articleapi
node_client -->|"sends requests"| node_profileapi
node_client -->|"sends requests"| node_tagapi
node_runtime -->|"creates app"| node_app
node_runtime -->|"serves docs"| node_swagger
node_app -->|"registers feature"| node_articlesvc
node_app -->|"registers feature"| node_usersvc
node_app -->|"registers feature"| node_profilesvc
node_app -->|"registers feature"| node_tagsvc
node_userapi -->|"delegates"| node_usersvc
node_articleapi -->|"delegates"| node_articlesvc
node_profileapi -->|"delegates"| node_profilesvc
node_tagapi -->|"delegates"| node_tagsvc
node_articlesvc -->|"queries and saves"| node_userdata
node_articlesvc -->|"reads follows"| node_followdata
node_articlesvc -->|"queries and saves"| node_articledata
node_articlesvc -->|"queries and saves"| node_commentdata
node_profilesvc -->|"queries users"| node_userdata
node_profilesvc -->|"queries and saves"| node_followdata
node_usersvc -->|"queries and saves"| node_userdata
node_articledata -->|"persists through TypeORM"| node_database
node_commentdata -->|"persists through TypeORM"| node_database
node_userdata -->|"persists through TypeORM"| node_database
node_followdata -->|"persists through TypeORM"| node_database
node_auth -->|"validates JWTs"| node_client

click node_runtime "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/main.ts"
click node_app "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/app.module.ts"
click node_auth "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/auth.middleware.ts"
click node_userapi "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/user.controller.ts"
click node_swagger "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/main.ts"
click node_articleapi "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/article/article.controller.ts"
click node_articlesvc "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/article/article.service.ts"
click node_articledata "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/article/article.entity.ts"
click node_commentdata "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/article/comment.entity.ts"
click node_profileapi "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/profile/profile.controller.ts"
click node_profilesvc "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/profile/profile.service.ts"
click node_followdata "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/profile/follows.entity.ts"
click node_usersvc "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/user.service.ts"
click node_userdata "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/user.entity.ts"
click node_tagapi "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/tag/tag.controller.ts"
click node_tagsvc "https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/tag/tag.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_runtime,node_app,node_auth,node_userapi,node_swagger,node_client toneBlue
class node_articleapi,node_articlesvc,node_articledata,node_commentdata,node_tagapi,node_tagsvc toneAmber
class node_profileapi,node_profilesvc,node_followdata,node_usersvc,node_userdata toneMint
class node_database toneRose
```

## Components

### API and auth

- [Nest runtime](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/main.ts): `src/main.ts`
- [Application module](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/app.module.ts): `src/app.module.ts`
- [JWT middleware](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/auth.middleware.ts): `src/user/auth.middleware.ts`
- [User API](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/user.controller.ts): `src/user/user.controller.ts`
- [Swagger docs](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/main.ts): `src/main.ts`

### Article content

- [Article API](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/article/article.controller.ts): `src/article/article.controller.ts`
- [Article service](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/article/article.service.ts): `src/article/article.service.ts`
- [Articles and comments](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/article/article.entity.ts): `src/article/article.entity.ts`
- [Comment entity](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/article/comment.entity.ts): `src/article/comment.entity.ts`
- [Tag API](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/tag/tag.controller.ts): `src/tag/tag.controller.ts`
- [Tag service](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/tag/tag.service.ts): `src/tag/tag.service.ts`

### Users and social

- [Profile API](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/profile/profile.controller.ts): `src/profile/profile.controller.ts`
- [Profile service](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/profile/profile.service.ts): `src/profile/profile.service.ts`
- [Follow entity](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/profile/follows.entity.ts): `src/profile/follows.entity.ts`
- [User service](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/user.service.ts): `src/user/user.service.ts`
- [User entity](https://github.com/lujakob/nestjs-realworld-example-app/blob/master/src/user/user.entity.ts): `src/user/user.entity.ts`

### Persistence

- **MySQL database**

### Other components

- **API client**

## Connections

- API client → User API: sends requests
- API client → Article API: sends requests
- API client → Profile API: sends requests
- API client → Tag API: sends requests
- Nest runtime → Application module: creates app
- Nest runtime → Swagger docs: serves docs
- Application module → Article service: registers feature
- Application module → User service: registers feature
- Application module → Profile service: registers feature
- Application module → Tag service: registers feature
- User API → User service: delegates
- Article API → Article service: delegates
- Profile API → Profile service: delegates
- Tag API → Tag service: delegates
- Article service → User entity: queries and saves
- Article service → Follow entity: reads follows
- Article service → Articles and comments: queries and saves
- Article service → Comment entity: queries and saves
- Profile service → User entity: queries users
- Profile service → Follow entity: queries and saves
- User service → User entity: queries and saves
- Articles and comments → MySQL database: persists through TypeORM
- Comment entity → MySQL database: persists through TypeORM
- User entity → MySQL database: persists through TypeORM
- Follow entity → MySQL database: persists through TypeORM
- JWT middleware → API client: validates JWTs
