# vulnerable-apps/juice-shop architecture

> Architecture diagram of the GitHub repository vulnerable-apps/juice-shop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vulnerable-apps/juice-shop
- Repository: https://github.com/vulnerable-apps/juice-shop

## Overview

#### Purpose and Runtime
OWASP Juice Shop is an intentionally vulnerable e-commerce application for security training, CTFs, and security-tool testing. It runs on Node.js (supported 18/20; README lists 20 as primary) and serves on port 3000. The backend is TypeScript/Node; the browser client is Angular. Primary server entry points are `app.ts` and `server.ts`; container deployment starts from `Dockerfile`.

#### Application Bootstrap and Customization
Startup assembles the Express application, validates prerequisites/configuration, applies branding and challenge setup, restores intentional mutable state, and registers WebSocket events. Configuration profiles alter behavior for CTF/tutorial/rebranding modes.
- `app.ts`
- `server.ts`
- `lib/startup/validatePreconditions.ts`
- `lib/startup/customizeApplication.ts`
- `config/default.yml`

#### HTTP/API Boundary
The server exposes a broad REST-style route layer for shop workflows, user identity, uploads, privacy operations, challenge-related endpoints, and intentionally insecure surfaces. Routes are the principal boundary between Angular clients/automation and backend domain/data logic. Static Angular distribution delivery is handled separately.
- `routes/login.ts`
- `routes/basket.ts`
- `routes/order.ts`
- `routes/angular.ts`
- `routes/fileUpload.ts`

#### Persistence and Domain Model
Sequelize-style domain models represent users, products, baskets, orders-related records, challenges, feedback, and privacy data. Data initialization/cache logic seeds the vulnerable shop and challenge catalog; MongoDB support is also present for selected data/runtime modes. Initial content and challenge definitions are versioned static inputs.
- `models/index.ts`
- `models/relations.ts`
- `models/user.ts`
- `data/datacreator.ts`
- `data/mongodb.ts`
- `data/static/challenges.yml`

#### Angular Storefront Client
The Angular SPA is bootstrapped from `main.ts`, composed by the root module and route table, then calls backend APIs through service classes and an HTTP interceptor. It implements storefront/account/checkout experiences alongside score-board, code-fix, and Web3 challenge UIs.
- `frontend/src/main.ts`
- `frontend/src/app/app.module.ts`
- `frontend/src/app/app.routing.ts`
- `frontend/src/app/Services/request.interceptor.ts`
- `frontend/src/app/score-board/score-board.module.ts`

#### Challenge and Training Engine
Challenges are data-driven but coupled to deliberately vulnerable backend/frontend behavior. Challenge utility, anti-cheat, coding-challenge, and instructor modules evaluate or guide progress; challenge status is presented through the SPA score board. Static code-fix alternatives support secure-coding exercises.
- `lib/challengeUtils.ts`
- `lib/antiCheat.ts`
- `lib/codingChallenges.ts`
- `frontend/src/hacking-instructor/index.ts`
- `data/static/codefixes`

#### Stateful/External Integration Surfaces
The app handles JWT/key material and two-factor authentication, Socket.IO-style real-time notifications, file/profile/complaint uploads, chatbot data, and optional blockchain/Web3/NFT flows. These are intentionally material attack boundaries, not merely ancillary integrations.
- `encryptionkeys/jwt.pub`
- `routes/2fa.ts`
- `lib/startup/registerWebsocketEvents.ts`
- `routes/chatbot.ts`
- `routes/web3Wallet.ts`
- `uploads/complaints`

#### Delivery and Operations
The repository supports direct Node execution, Docker, Docker Compose test environments, Vagrant, and GitLab/Heroku-oriented deployment artifacts. Monitoring exposes metrics and supplies a Grafana dashboard; CI/release automation is GitHub Actions-based.
- `Dockerfile`
- `docker-compose.test.yml`
- `vagrant/Vagrantfile`
- `routes/metrics.ts`
- `monitoring/grafana-dashboard.json`

Main entry points: [`routes/login.ts`](https://github.com/vulnerable-apps/juice-shop/blob/master/routes/login.ts) (REST route layer), [`app.ts`](https://github.com/vulnerable-apps/juice-shop/blob/master/app.ts) (Express application), [`lib/challengeUtils.ts`](https://github.com/vulnerable-apps/juice-shop/blob/master/lib/challengeUtils.ts) (Challenge engine), [`frontend/src/app/app.module.ts`](https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/app/app.module.ts) (Storefront modules & routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Angular Client"]
  node_angular_bootstrap["SPA bootstrap<br/>Angular entry<br/>[main.ts]"]
  node_angular_app["Storefront modules &amp; routes<br/>Angular application<br/>[app.module.ts]"]
  node_http_interceptor["HTTP interceptor<br/>client API boundary"]
  node_scoreboard["Score board<br/>challenge UI"]
  node_hacking_instructor["Hacking instructor<br/>training UI<br/>[index.ts]"]
end

subgraph group_server["Node Application"]
  node_server_entry["Server entry<br/>Node server<br/>[server.ts]"]
  node_express_app["Express application<br/>application bootstrap<br/>[app.ts]"]
  node_startup["Startup customization<br/>startup pipeline"]
  node_config["Runtime profiles<br/>configuration<br/>[default.yml]"]
  node_routes["REST route layer<br/>HTTP boundary<br/>[login.ts]"]
  node_static_delivery["Angular static delivery<br/>static route<br/>[angular.ts]"]
end

subgraph group_data["Data &amp; Challenges"]
  node_domain_models["Domain models &amp; relations<br/>Sequelize model layer<br/>[index.ts]"]
  node_data_initialization["Seed &amp; cache initialization<br/>data initialization<br/>[datacreator.ts]"]
  node_challenge_catalog["Challenge catalog<br/>static challenge data<br/>[challenges.yml]"]
  node_challenge_engine["Challenge engine<br/>progress evaluation<br/>[challengeUtils.ts]"]
  node_codefixes["Secure code-fix content<br/>training content"]
end

subgraph group_surfaces["Attack Surfaces"]
  node_auth_2fa["JWT &amp; two-factor auth<br/>identity surface<br/>[2fa.ts]"]
  node_realtime["WebSocket events<br/>real-time surface"]
  node_uploads["Uploads &amp; chatbot<br/>untrusted input surface<br/>[fileUpload.ts]"]
  node_web3["Web3 wallet flow<br/>blockchain surface<br/>[web3Wallet.ts]"]
end

subgraph group_ops["Delivery &amp; Observability"]
  node_container["Docker runtime<br/>container deployment"]
  node_metrics["Metrics &amp; dashboard<br/>observability<br/>[metrics.ts]"]
end

node_angular_bootstrap -->|"boots"| node_angular_app
node_angular_app -->|"uses"| node_http_interceptor
node_angular_app -->|"includes"| node_scoreboard
node_angular_app -->|"includes"| node_hacking_instructor
node_http_interceptor -->|"API calls"| node_routes
node_server_entry -->|"runs"| node_express_app
node_express_app -->|"initializes"| node_startup
node_startup -->|"reads"| node_config
node_startup -->|"restores and seeds"| node_data_initialization
node_startup -->|"registers"| node_realtime
node_express_app -->|"mounts"| node_routes
node_express_app -->|"serves SPA"| node_static_delivery
node_routes -->|"domain access"| node_domain_models
node_data_initialization -->|"populates"| node_domain_models
node_data_initialization -->|"loads"| node_challenge_catalog
node_routes -->|"checks progress"| node_challenge_engine
node_challenge_engine -->|"uses definitions"| node_challenge_catalog
node_challenge_engine -->|"supports exercises"| node_codefixes
node_scoreboard -->|"shows status"| node_challenge_engine
node_hacking_instructor -->|"guides"| node_challenge_engine
node_routes -->|"identity flows"| node_auth_2fa
node_routes -->|"handles input"| node_uploads
node_routes -->|"wallet endpoints"| node_web3
node_express_app -->|"exposes"| node_metrics
node_container -->|"starts"| node_server_entry

click node_angular_bootstrap "https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/main.ts"
click node_angular_app "https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/app/app.module.ts"
click node_http_interceptor "https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/app/Services/request.interceptor.ts"
click node_scoreboard "https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/app/score-board/score-board.module.ts"
click node_hacking_instructor "https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/hacking-instructor/index.ts"
click node_server_entry "https://github.com/vulnerable-apps/juice-shop/blob/master/server.ts"
click node_express_app "https://github.com/vulnerable-apps/juice-shop/blob/master/app.ts"
click node_startup "https://github.com/vulnerable-apps/juice-shop/blob/master/lib/startup/customizeApplication.ts"
click node_config "https://github.com/vulnerable-apps/juice-shop/blob/master/config/default.yml"
click node_routes "https://github.com/vulnerable-apps/juice-shop/blob/master/routes/login.ts"
click node_static_delivery "https://github.com/vulnerable-apps/juice-shop/blob/master/routes/angular.ts"
click node_domain_models "https://github.com/vulnerable-apps/juice-shop/blob/master/models/index.ts"
click node_data_initialization "https://github.com/vulnerable-apps/juice-shop/blob/master/data/datacreator.ts"
click node_challenge_catalog "https://github.com/vulnerable-apps/juice-shop/blob/master/data/static/challenges.yml"
click node_challenge_engine "https://github.com/vulnerable-apps/juice-shop/blob/master/lib/challengeUtils.ts"
click node_codefixes "https://github.com/vulnerable-apps/juice-shop/tree/master/data/static/codefixes"
click node_auth_2fa "https://github.com/vulnerable-apps/juice-shop/blob/master/routes/2fa.ts"
click node_realtime "https://github.com/vulnerable-apps/juice-shop/blob/master/lib/startup/registerWebsocketEvents.ts"
click node_uploads "https://github.com/vulnerable-apps/juice-shop/blob/master/routes/fileUpload.ts"
click node_web3 "https://github.com/vulnerable-apps/juice-shop/blob/master/routes/web3Wallet.ts"
click node_container "https://github.com/vulnerable-apps/juice-shop/blob/master/Dockerfile"
click node_metrics "https://github.com/vulnerable-apps/juice-shop/blob/master/routes/metrics.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_angular_bootstrap,node_angular_app,node_http_interceptor,node_scoreboard,node_hacking_instructor toneBlue
class node_server_entry,node_express_app,node_startup,node_config,node_routes,node_static_delivery toneAmber
class node_domain_models,node_data_initialization,node_challenge_catalog,node_challenge_engine,node_codefixes toneMint
class node_auth_2fa,node_realtime,node_uploads,node_web3 toneRose
class node_container,node_metrics toneIndigo
```

## Components

### Angular Client

- [SPA bootstrap](https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/main.ts): Angular entry · `frontend/src/main.ts`
- [Storefront modules & routes](https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/app/app.module.ts): Angular application · `frontend/src/app/app.module.ts`
- [HTTP interceptor](https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/app/Services/request.interceptor.ts): client API boundary · `frontend/src/app/Services/request.interceptor.ts`
- [Score board](https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/app/score-board/score-board.module.ts): challenge UI · `frontend/src/app/score-board/score-board.module.ts`
- [Hacking instructor](https://github.com/vulnerable-apps/juice-shop/blob/master/frontend/src/hacking-instructor/index.ts): training UI · `frontend/src/hacking-instructor/index.ts`

### Node Application

- [Server entry](https://github.com/vulnerable-apps/juice-shop/blob/master/server.ts): Node server · Starts the application on the HTTP runtime. · `server.ts`
- [Express application](https://github.com/vulnerable-apps/juice-shop/blob/master/app.ts): application bootstrap · `app.ts`
- [Startup customization](https://github.com/vulnerable-apps/juice-shop/blob/master/lib/startup/customizeApplication.ts): startup pipeline · Validates setup, applies branding, and restores mutable state. · `lib/startup/customizeApplication.ts`
- [Runtime profiles](https://github.com/vulnerable-apps/juice-shop/blob/master/config/default.yml): configuration · Controls CTF, tutorial, and rebranding modes. · `config/default.yml`
- [REST route layer](https://github.com/vulnerable-apps/juice-shop/blob/master/routes/login.ts): HTTP boundary · Shop, identity, upload, privacy, and challenge endpoints. · `routes/login.ts`
- [Angular static delivery](https://github.com/vulnerable-apps/juice-shop/blob/master/routes/angular.ts): static route · `routes/angular.ts`

### Data & Challenges

- [Domain models & relations](https://github.com/vulnerable-apps/juice-shop/blob/master/models/index.ts): Sequelize model layer · `models/index.ts`
- [Seed & cache initialization](https://github.com/vulnerable-apps/juice-shop/blob/master/data/datacreator.ts): data initialization · `data/datacreator.ts`
- [Challenge catalog](https://github.com/vulnerable-apps/juice-shop/blob/master/data/static/challenges.yml): static challenge data · `data/static/challenges.yml`
- [Challenge engine](https://github.com/vulnerable-apps/juice-shop/blob/master/lib/challengeUtils.ts): progress evaluation · Evaluates challenge status and anti-cheat behavior. · `lib/challengeUtils.ts`
- [Secure code-fix content](https://github.com/vulnerable-apps/juice-shop/tree/master/data/static/codefixes): training content · `data/static/codefixes`

### Attack Surfaces

Material stateful and external-facing boundaries.

- [JWT & two-factor auth](https://github.com/vulnerable-apps/juice-shop/blob/master/routes/2fa.ts): identity surface · `routes/2fa.ts`
- [WebSocket events](https://github.com/vulnerable-apps/juice-shop/blob/master/lib/startup/registerWebsocketEvents.ts): real-time surface · `lib/startup/registerWebsocketEvents.ts`
- [Uploads & chatbot](https://github.com/vulnerable-apps/juice-shop/blob/master/routes/fileUpload.ts): untrusted input surface · `routes/fileUpload.ts`
- [Web3 wallet flow](https://github.com/vulnerable-apps/juice-shop/blob/master/routes/web3Wallet.ts): blockchain surface · `routes/web3Wallet.ts`

### Delivery & Observability

- [Docker runtime](https://github.com/vulnerable-apps/juice-shop/blob/master/Dockerfile): container deployment · `Dockerfile`
- [Metrics & dashboard](https://github.com/vulnerable-apps/juice-shop/blob/master/routes/metrics.ts): observability · `routes/metrics.ts`

## Connections

- SPA bootstrap → Storefront modules & routes: boots
- Storefront modules & routes → HTTP interceptor: uses
- Storefront modules & routes → Score board: includes
- Storefront modules & routes → Hacking instructor: includes
- HTTP interceptor → REST route layer: API calls
- Server entry → Express application: runs
- Express application → Startup customization: initializes
- Startup customization → Runtime profiles: reads
- Startup customization → Seed & cache initialization: restores and seeds
- Startup customization → WebSocket events: registers
- Express application → REST route layer: mounts
- Express application → Angular static delivery: serves SPA
- REST route layer → Domain models & relations: domain access
- Seed & cache initialization → Domain models & relations: populates
- Seed & cache initialization → Challenge catalog: loads
- REST route layer → Challenge engine: checks progress
- Challenge engine → Challenge catalog: uses definitions
- Challenge engine → Secure code-fix content: supports exercises
- Score board → Challenge engine: shows status
- Hacking instructor → Challenge engine: guides
- REST route layer → JWT & two-factor auth: identity flows
- REST route layer → Uploads & chatbot: handles input
- REST route layer → Web3 wallet flow: wallet endpoints
- Express application → Metrics & dashboard: exposes
- Docker runtime → Server entry: starts
