# niklabh/freecodecamp-whoami architecture

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

- Interactive diagram: https://gitdiagram.com/niklabh/freecodecamp-whoami
- Repository: https://github.com/niklabh/freecodecamp-whoami

## Overview

This small Express service exposes `/api/whoami`: a client sends an HTTP request, the app dispatches it to a route handler, and the handler returns the request IP, preferred language, and parsed operating-system details as JSON. It also has a homepage route that renders a Jade view. The sampled source shows these relationships; the user-list route is not registered in the app.

Main entry points: [`app.js`](https://github.com/niklabh/freecodecamp-whoami/blob/master/app.js) (Express app), [`routes/index.js`](https://github.com/niklabh/freecodecamp-whoami/blob/master/routes/index.js) (Whoami handler), [`views/index.jade`](https://github.com/niklabh/freecodecamp-whoami/blob/master/views/index.jade) (Home view)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_client(("HTTP client"))
node_app["Express app<br/>[app.js]"]
node_whoami["Whoami handler<br/>[index.js]"]
node_parser["User-agent parser"]
node_json["JSON response"]
node_home["Home handler<br/>[index.js]"]
node_view["Home view<br/>[index.jade]"]

node_client -->|"sends HTTP"| node_app
node_app -->|"dispatches route"| node_whoami
node_whoami -->|"parses user-agent"| node_parser
node_whoami -->|"returns JSON"| node_json
node_app -->|"dispatches route"| node_home
node_home -->|"renders view"| node_view

click node_app "https://github.com/niklabh/freecodecamp-whoami/blob/master/app.js"
click node_whoami "https://github.com/niklabh/freecodecamp-whoami/blob/master/routes/index.js"
click node_home "https://github.com/niklabh/freecodecamp-whoami/blob/master/routes/index.js"
click node_view "https://github.com/niklabh/freecodecamp-whoami/blob/master/views/index.jade"

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_client,node_parser,node_view toneBlue
class node_app toneTeal
class node_whoami,node_home toneMint
class node_json toneIndigo
```

## Components

### Other components

- **HTTP client**
- [Express app](https://github.com/niklabh/freecodecamp-whoami/blob/master/app.js): `app.js`
- [Whoami handler](https://github.com/niklabh/freecodecamp-whoami/blob/master/routes/index.js): `routes/index.js`
- **User-agent parser**
- **JSON response**
- [Home handler](https://github.com/niklabh/freecodecamp-whoami/blob/master/routes/index.js): `routes/index.js`
- [Home view](https://github.com/niklabh/freecodecamp-whoami/blob/master/views/index.jade): `views/index.jade`

## Connections

- HTTP client → Express app: sends HTTP (evidence: `app.js`)
- Express app → Whoami handler: dispatches route (evidence: `app.js`)
- Whoami handler → User-agent parser: parses user-agent (evidence: `routes/index.js`)
- Whoami handler → JSON response: returns JSON (evidence: `routes/index.js`)
- Express app → Home handler: dispatches route (evidence: `app.js`)
- Home handler → Home view: renders view (evidence: `routes/index.js`)
