NestJS RealWorld example architecture.
NestJS RealWorld example is a RealWorld backend API built with NestJS and TypeORM. Nodeway mapped the lujakob/nestjs-realworld-example-app repository at commit c1c2cc4, from 18 January 2021, and found 35 source files, 83 functions, classes and components, 21 routes and 5 database tables. This page is drawn from that map.
- Source files
- 35
- Functions and classes
- 83
- Confirmed calls
- 42
- Routes
- 21
- Tables
- 5
How the code is laid out
Most of it is TypeScript: 34 files of 35, followed by JavaScript (1).
These are its top-level folders by number of source files, with 1 more file at the root. The biggest ones show their own largest folders underneath.
- src/34 files21 routes · 5 tables
- user/11 files5 routes · 1 table
- article/9 files11 routes · 2 tables
- profile/5 files3 routes · 1 table
- tag/4 files1 route · 1 table
- shared/2 files
Where the code starts
Nodeway looked for files that define a main function, and for files named like a starting point (main, server, app, cli and similar) that at most one other file imports, then for index files that nothing imports. Ranked that way, then by how many files each one reaches through its imports:
| File | Reaches |
|---|---|
| src/main.ts | 27 files |
Routes
Nodeway found 21 routes and linked 21 to the function that handles them. They by HTTP method: GET 8, POST 6, DELETE 5, PUT 2. Most are under src/article (11), src/user (5) and src/profile (3).
Some of them
| Route | Method |
|---|---|
| /root · src/app.controller.ts | GET |
| /tagsfindAll · src/tag/tag.controller.ts | GET |
| /userfindMe · src/user/user.controller.ts | GET |
| /articlesfindAll · src/article/article.controller.ts | GET |
| /profiles/:usernamegetProfile · src/profile/profile.controller.ts | GET |
| /userupdate · src/user/user.controller.ts | PUT |
| /userscreate · src/user/user.controller.ts | POST |
| /articlescreate · src/article/article.controller.ts | POST |
Data model
Nodeway found 5 database tables, defined with TypeORM. Code in the repository reads or writes 5 of them. The most used:
| Table | Used by |
|---|---|
| user6 columns · links to article · src/user/user.entity.ts | 15 read6 write |
| article11 columns · links to comment and user · src/article/article.entity.ts | 9 read7 write |
| follows3 columns · src/profile/follows.entity.ts | 3 read2 write |
| comment3 columns · links to article · src/article/comment.entity.ts | 1 read2 write |
| tag2 columns · src/tag/tag.entity.ts | 1 read0 write |
One request, traced
Nodeway followed DELETE /articles/:slug/favorite from its route to the code that handles it, then along confirmed calls until it reached the user table.
- DELETE /articles/:slug/favoriteroute · src/article/article.controller.ts
- unFavoritemethod · src/article/article.controller.ts:98
- unFavoritemethod · src/article/article.service.ts:147
- usertable · written here
The most-called code
Ranked by how many different functions call each one, counting only calls the analyzer could confirm from the code. These are often the helpers worth reading first.
| Function | Callers |
|---|---|
| Userfunction · src/user/user.decorator.ts | 9 |
| buildUserROmethod · src/user/user.service.ts | 3 |
| generateJWTmethod · src/user/user.service.ts | 2 |
| addCommentmethod · src/article/article.service.ts | 1 |
| createmethod · src/article/article.service.ts | 1 |
| deletemethod · src/article/article.service.ts | 1 |
| deleteCommentmethod · src/article/article.service.ts | 1 |
| favoritemethod · src/article/article.service.ts | 1 |
Open this repo in Nodeway
Nodeway is a desktop app that draws this map on your own computer, so you can click into any folder, read the code beside the map and trace a request yourself. Clone the repository:
git clone https://github.com/lujakob/nestjs-realworld-example-app.git- Install Nodeway for macOS, Windows or Linux: the getting started guide has every installer.
- Open the cloned folder. The first map is drawn on your machine and nothing is uploaded.
- Search for
Userand trace what it calls, or pick a route and follow it to the database.
New to reading a codebase this size? See how to understand a large codebase and how to read a call graph.
Questions
What language is NestJS RealWorld example written in?
Mostly TypeScript: 34 of its 35 source files at commit c1c2cc4, then JavaScript with 1.
Where does the NestJS RealWorld example code start?
The entry point that reaches the most code is src/main.ts, which leads to 27 files through its imports.
How many routes does NestJS RealWorld example have?
Nodeway found 21 routes, 21 of them linked to a handler. The most are under src/article.
What database tables does NestJS RealWorld example use?
5 tables, defined with TypeORM. The most used are user, article and follows.
How this page was made
Generated from a map Nodeway's analyzer (version 18) made of lujakob/nestjs-realworld-example-app at commit c1c2cc4, committed on 18 January 2021. Tests, dependencies and build output are mostly left out. A call counts only when the analyzer could confirm its target from the code, so real totals are higher. The project will have changed since.