# owasp/nodegoat architecture

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

- Interactive diagram: https://gitdiagram.com/owasp/nodegoat
- Repository: https://github.com/owasp/nodegoat

## Overview

NodeGoat is an intentionally vulnerable Node.js web application for learning OWASP Top 10 risks. A user enters through the Express web server, signs in or creates an account, then uses authenticated dashboard features such as profile, contributions, benefits, allocations, memos, and research; the tutorial is a separate learning route. Route handlers own feature actions and use data-access objects to persist or retrieve MongoDB records. The graph preserves those documented feature branches and the tutorial. Some DAO-to-route links are supported by the source index; unsampled view wiring and storage details are not expanded beyond explicit evidence.

Main entry points: [`app/routes/index.js`](https://github.com/owasp/nodegoat/blob/master/app/routes/index.js) (Route registration), [`app/routes/session.js`](https://github.com/owasp/nodegoat/blob/master/app/routes/session.js) (Account sessions), [`server.js`](https://github.com/owasp/nodegoat/blob/master/server.js) (Express server), [`app/routes/profile.js`](https://github.com/owasp/nodegoat/blob/master/app/routes/profile.js) (Profile handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web runtime"]
  node_server["Express server<br/>[server.js]"]
  node_routes["Route registration<br/>[index.js]"]
  node_views["HTML views"]
end

subgraph group_identity["Accounts and sessions"]
  node_session["Account sessions<br/>[session.js]"]
  node_profile["Profile handler<br/>[profile.js]"]
end

subgraph group_finance["Financial features"]
  node_contributions["Contributions handler<br/>[contributions.js]"]
  node_benefits["Benefits handler<br/>[benefits.js]"]
  node_allocations["Allocations handler<br/>[allocations.js]"]
  node_memos["Memos handler<br/>[memos.js]"]
end

subgraph group_learning["Learning and research"]
  node_research["Research handler<br/>[research.js]"]
  node_tutorial["OWASP tutorial<br/>[tutorial.js]"]
end

subgraph group_data["Data access"]
  node_userdao["User records<br/>[user-dao.js]"]
  node_profiledao["Profile records<br/>[profile-dao.js]"]
  node_contributionsdao["Contribution records"]
  node_benefitsdao["Benefits records<br/>[benefits-dao.js]"]
  node_allocationsdao["Allocation records<br/>[allocations-dao.js]"]
  node_memosdao["Memo records<br/>[memos-dao.js]"]
  node_researchdao["Research data<br/>[research-dao.js]"]
end

node_visitor(("Web user"))
node_mongo[("MongoDB")]
node_stockservice(("Stock information service"))

node_visitor -->|"requests pages"| node_server
node_server -->|"connects to"| node_mongo
node_server -->|"registers routes"| node_routes
node_routes -->|"routes account actions"| node_session
node_routes -->|"routes profile actions"| node_profile
node_routes -->|"routes contribution actions"| node_contributions
node_routes -->|"routes benefit actions"| node_benefits
node_routes -->|"routes allocation pages"| node_allocations
node_routes -->|"routes memo actions"| node_memos
node_routes -->|"routes research pages"| node_research
node_routes -->|"mounts tutorial"| node_tutorial
node_session -->|"authenticates users"| node_userdao
node_session -->|"prepares allocations"| node_allocationsdao
node_profile -->|"reads and updates"| node_profiledao
node_contributions -->|"reads and updates"| node_contributionsdao
node_benefits -->|"accesses records"| node_benefitsdao
node_allocations -->|"accesses records"| node_allocationsdao
node_memos -->|"accesses records"| node_memosdao
node_research -->|"constructs data access"| node_researchdao
node_research -->|"fetches stock data"| node_stockservice
node_userdao -->|"reads and writes"| node_mongo
node_profiledao -->|"reads and writes"| node_mongo
node_allocationsdao -->|"looks up users"| node_userdao
node_session -->|"renders account pages"| node_views
node_profile -->|"renders profile page"| node_views
node_contributions -->|"renders contribution page"| node_views

click node_server "https://github.com/owasp/nodegoat/blob/master/server.js"
click node_routes "https://github.com/owasp/nodegoat/blob/master/app/routes/index.js"
click node_views "https://github.com/owasp/nodegoat/tree/master/app/views"
click node_session "https://github.com/owasp/nodegoat/blob/master/app/routes/session.js"
click node_userdao "https://github.com/owasp/nodegoat/blob/master/app/data/user-dao.js"
click node_profile "https://github.com/owasp/nodegoat/blob/master/app/routes/profile.js"
click node_profiledao "https://github.com/owasp/nodegoat/blob/master/app/data/profile-dao.js"
click node_contributions "https://github.com/owasp/nodegoat/blob/master/app/routes/contributions.js"
click node_contributionsdao "https://github.com/owasp/nodegoat/blob/master/app/data/contributions-dao.js"
click node_benefits "https://github.com/owasp/nodegoat/blob/master/app/routes/benefits.js"
click node_benefitsdao "https://github.com/owasp/nodegoat/blob/master/app/data/benefits-dao.js"
click node_allocations "https://github.com/owasp/nodegoat/blob/master/app/routes/allocations.js"
click node_allocationsdao "https://github.com/owasp/nodegoat/blob/master/app/data/allocations-dao.js"
click node_memos "https://github.com/owasp/nodegoat/blob/master/app/routes/memos.js"
click node_memosdao "https://github.com/owasp/nodegoat/blob/master/app/data/memos-dao.js"
click node_research "https://github.com/owasp/nodegoat/blob/master/app/routes/research.js"
click node_researchdao "https://github.com/owasp/nodegoat/blob/master/app/data/research-dao.js"
click node_tutorial "https://github.com/owasp/nodegoat/blob/master/app/routes/tutorial.js"

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_server,node_routes,node_views,node_visitor toneBlue
class node_session,node_profile,node_mongo toneAmber
class node_contributions,node_benefits,node_allocations,node_memos toneMint
class node_research,node_tutorial toneRose
class node_userdao,node_profiledao,node_contributionsdao,node_benefitsdao,node_allocationsdao,node_memosdao,node_researchdao,node_stockservice toneIndigo
```

## Components

### Web runtime

- [Express server](https://github.com/owasp/nodegoat/blob/master/server.js): `server.js`
- [Route registration](https://github.com/owasp/nodegoat/blob/master/app/routes/index.js): `app/routes/index.js`
- [HTML views](https://github.com/owasp/nodegoat/tree/master/app/views): `app/views`

### Accounts and sessions

- [Account sessions](https://github.com/owasp/nodegoat/blob/master/app/routes/session.js): `app/routes/session.js`
- [Profile handler](https://github.com/owasp/nodegoat/blob/master/app/routes/profile.js): `app/routes/profile.js`

### Financial features

- [Contributions handler](https://github.com/owasp/nodegoat/blob/master/app/routes/contributions.js): `app/routes/contributions.js`
- [Benefits handler](https://github.com/owasp/nodegoat/blob/master/app/routes/benefits.js): `app/routes/benefits.js`
- [Allocations handler](https://github.com/owasp/nodegoat/blob/master/app/routes/allocations.js): `app/routes/allocations.js`
- [Memos handler](https://github.com/owasp/nodegoat/blob/master/app/routes/memos.js): `app/routes/memos.js`

### Learning and research

- [Research handler](https://github.com/owasp/nodegoat/blob/master/app/routes/research.js): `app/routes/research.js`
- [OWASP tutorial](https://github.com/owasp/nodegoat/blob/master/app/routes/tutorial.js): `app/routes/tutorial.js`

### Data access

- [User records](https://github.com/owasp/nodegoat/blob/master/app/data/user-dao.js): `app/data/user-dao.js`
- [Profile records](https://github.com/owasp/nodegoat/blob/master/app/data/profile-dao.js): `app/data/profile-dao.js`
- [Contribution records](https://github.com/owasp/nodegoat/blob/master/app/data/contributions-dao.js): `app/data/contributions-dao.js`
- [Benefits records](https://github.com/owasp/nodegoat/blob/master/app/data/benefits-dao.js): `app/data/benefits-dao.js`
- [Allocation records](https://github.com/owasp/nodegoat/blob/master/app/data/allocations-dao.js): `app/data/allocations-dao.js`
- [Memo records](https://github.com/owasp/nodegoat/blob/master/app/data/memos-dao.js): `app/data/memos-dao.js`
- [Research data](https://github.com/owasp/nodegoat/blob/master/app/data/research-dao.js): `app/data/research-dao.js`

### Other components

- **Web user**
- **MongoDB**
- **Stock information service**

## Connections

- Web user → Express server: requests pages (evidence: `README.md`)
- Express server → MongoDB: connects to (evidence: `server.js`)
- Express server → Route registration: registers routes (evidence: `server.js`)
- Route registration → Account sessions: routes account actions (evidence: `app/routes/index.js`)
- Route registration → Profile handler: routes profile actions (evidence: `app/routes/index.js`)
- Route registration → Contributions handler: routes contribution actions (evidence: `app/routes/index.js`)
- Route registration → Benefits handler: routes benefit actions (evidence: `app/routes/index.js`)
- Route registration → Allocations handler: routes allocation pages (evidence: `app/routes/index.js`)
- Route registration → Memos handler: routes memo actions (evidence: `app/routes/index.js`)
- Route registration → Research handler: routes research pages (evidence: `app/routes/index.js`)
- Route registration → OWASP tutorial: mounts tutorial (evidence: `app/routes/index.js`)
- Account sessions → User records: authenticates users (evidence: `app/routes/session.js`)
- Account sessions → Allocation records: prepares allocations (evidence: `app/routes/session.js`)
- Profile handler → Profile records: reads and updates (evidence: `app/routes/profile.js`)
- Contributions handler → Contribution records: reads and updates (evidence: `app/routes/contributions.js`)
- Benefits handler → Benefits records: accesses records (evidence: `app/routes/benefits.js`)
- Allocations handler → Allocation records: accesses records (evidence: `app/routes/allocations.js`)
- Memos handler → Memo records: accesses records (evidence: `app/routes/memos.js`)
- Research handler → Research data: constructs data access (evidence: `app/routes/research.js`)
- Research handler → Stock information service: fetches stock data (evidence: `app/routes/research.js`)
- User records → MongoDB: reads and writes (evidence: `app/data/user-dao.js`)
- Profile records → MongoDB: reads and writes (evidence: `app/data/profile-dao.js`)
- Allocation records → User records: looks up users (evidence: `app/data/allocations-dao.js`)
- Account sessions → HTML views: renders account pages (evidence: `app/routes/session.js`)
- Profile handler → HTML views: renders profile page (evidence: `app/routes/profile.js`)
- Contributions handler → HTML views: renders contribution page (evidence: `app/routes/contributions.js`)
