# ke1thli/ctf-web-idor architecture

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

- Interactive diagram: https://gitdiagram.com/ke1thli/ctf-web-idor
- Repository: https://github.com/ke1thli/ctf-web-idor

## Overview

This is a Flask employee-management CTF challenge demonstrating IDOR. A user registers or logs in, can inspect profiles, obtains an administrator’s internal ID from a profile, requests that employee’s API token, then presents the token to access the flag. The route handlers and persistence helpers are excerpted; template rendering and database initialization are visible there too. The README documents the exploit workflow. The graph omits deployment machinery and does not infer unshown template or database behavior.

Main entry points: [`app/database.py`](https://github.com/ke1thli/ctf-web-idor/blob/main/app/database.py) (User data access), [`app/app.py`](https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py) (Profile access), [`app/templates`](https://github.com/ke1thli/ctf-web-idor/tree/main/app/templates) (Page templates), [`app/init_db.py`](https://github.com/ke1thli/ctf-web-idor/blob/main/app/init_db.py) (Schema and admin seed)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_accounts["Register and login<br/>[app.py]"]
  node_dashboard["Dashboard<br/>[app.py]"]
  node_profiles["Profile access<br/>[app.py]"]
  node_profile_edit["Profile editing<br/>[app.py]"]
  node_token_api["Token API<br/>[app.py]"]
  node_admin_gate["Admin flag gate<br/>[app.py]"]
end

subgraph group_data["Persistence"]
  node_db_helpers["User data access<br/>[database.py]"]
  node_db_init["Schema and admin seed<br/>[init_db.py]"]
  node_users_db[("SQLite user store<br/>[database.py]")]
end

subgraph group_ui["User interface"]
  node_templates["Page templates"]
end

node_user(("User"))

node_user -->|"registers or logs in"| node_accounts
node_accounts -->|"checks or creates user"| node_db_helpers
node_user -->|"opens dashboard"| node_dashboard
node_dashboard -->|"renders dashboard"| node_templates
node_user -->|"opens profile"| node_profiles
node_profiles -->|"looks up user ID"| node_db_helpers
node_profiles -->|"renders profile"| node_templates
node_profiles -->|"supplies employee ID"| node_token_api
node_user -->|"edits own profile"| node_profile_edit
node_profile_edit -->|"updates user"| node_db_helpers
node_profile_edit -->|"renders edit form"| node_templates
node_user -->|"requests token"| node_token_api
node_token_api -->|"looks up employee ID"| node_db_helpers
node_user -->|"presents admin token"| node_admin_gate
node_admin_gate -->|"checks admin token"| node_db_helpers
node_admin_gate -->|"renders flag page"| node_templates
node_db_helpers -->|"reads and writes"| node_users_db
node_db_init -->|"creates and seeds"| node_users_db
node_db_init -->|"runs at startup"| node_db_init

click node_accounts "https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py"
click node_dashboard "https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py"
click node_profiles "https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py"
click node_profile_edit "https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py"
click node_token_api "https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py"
click node_admin_gate "https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py"
click node_db_helpers "https://github.com/ke1thli/ctf-web-idor/blob/main/app/database.py"
click node_db_init "https://github.com/ke1thli/ctf-web-idor/blob/main/app/init_db.py"
click node_users_db "https://github.com/ke1thli/ctf-web-idor/blob/main/app/database.py"
click node_templates "https://github.com/ke1thli/ctf-web-idor/tree/main/app/templates"

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_accounts,node_dashboard,node_profiles,node_profile_edit,node_token_api,node_admin_gate,node_user toneBlue
class node_db_helpers,node_db_init,node_users_db toneAmber
class node_templates toneMint
```

## Components

### Web application

- [Register and login](https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py): `app/app.py`
- [Dashboard](https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py): `app/app.py`
- [Profile access](https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py): `app/app.py`
- [Profile editing](https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py): `app/app.py`
- [Token API](https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py): `app/app.py`
- [Admin flag gate](https://github.com/ke1thli/ctf-web-idor/blob/main/app/app.py): `app/app.py`

### Persistence

- [User data access](https://github.com/ke1thli/ctf-web-idor/blob/main/app/database.py): `app/database.py`
- [Schema and admin seed](https://github.com/ke1thli/ctf-web-idor/blob/main/app/init_db.py): `app/init_db.py`
- [SQLite user store](https://github.com/ke1thli/ctf-web-idor/blob/main/app/database.py): `app/database.py`

### User interface

- [Page templates](https://github.com/ke1thli/ctf-web-idor/tree/main/app/templates): `app/templates`

### Other components

- **User**

## Connections

- User → Register and login: registers or logs in (evidence: `app/app.py`)
- Register and login → User data access: checks or creates user (evidence: `app/app.py`)
- User → Dashboard: opens dashboard (evidence: `app/app.py`)
- Dashboard → Page templates: renders dashboard (evidence: `app/app.py`)
- User → Profile access: opens profile (evidence: `app/app.py`)
- Profile access → User data access: looks up user ID (evidence: `app/app.py`)
- Profile access → Page templates: renders profile (evidence: `app/app.py`)
- Profile access → Token API: supplies employee ID (evidence: `README.md`)
- User → Profile editing: edits own profile (evidence: `app/app.py`)
- Profile editing → User data access: updates user (evidence: `app/app.py`)
- Profile editing → Page templates: renders edit form (evidence: `app/app.py`)
- User → Token API: requests token (evidence: `app/app.py`)
- Token API → User data access: looks up employee ID (evidence: `app/app.py`)
- User → Admin flag gate: presents admin token (evidence: `app/app.py`)
- Admin flag gate → User data access: checks admin token (evidence: `app/app.py`)
- Admin flag gate → Page templates: renders flag page (evidence: `app/app.py`)
- User data access → SQLite user store: reads and writes (evidence: `app/database.py`)
- Schema and admin seed → SQLite user store: creates and seeds (evidence: `app/init_db.py`)
- Schema and admin seed → Schema and admin seed: runs at startup (evidence: `app/app.py`)
