# muhammadtalha15/ctf_platform architecture

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

- Interactive diagram: https://gitdiagram.com/muhammadtalha15/ctf_platform
- Repository: https://github.com/muhammadtalha15/ctf_platform

## Overview

This is a web-based CTF learning platform. Users register or sign in, browse challenges, submit flags, and track their profile, points, and leaderboard standing; administrators manage challenges, users, and announcements. Express mounts the domain routers, which query PostgreSQL and render EJS pages. The excerpts establish challenge submission transactions and several user/admin database operations; unsampled route details are represented only at the router level, without inferred internal links.

Main entry points: [`app.js`](https://github.com/muhammadtalha15/ctf_platform/blob/main/app.js) (Express application), [`config/db.js`](https://github.com/muhammadtalha15/ctf_platform/blob/main/config/db.js) (PostgreSQL pool), [`routes/auth.js`](https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/auth.js) (Authentication routes), [`routes/challenges.js`](https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/challenges.js) (Challenge routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web runtime"]
  node_server["HTTP server<br/>[server.js]"]
  node_app["Express application<br/>[app.js]"]
  node_client["Browser interactions<br/>[app.js]"]
  node_views["EJS pages"]
end

subgraph group_identity["Identity and access"]
  node_auth["Authentication routes<br/>[auth.js]"]
  node_access["Access middleware<br/>[auth.js]"]
end

subgraph group_ctf["CTF experience"]
  node_challenges["Challenge routes<br/>[challenges.js]"]
  node_user["User routes<br/>[user.js]"]
end

subgraph group_admin["Administration"]
  node_admin["Admin routes<br/>[admin.js]"]
end

subgraph group_state["Persistent state"]
  node_pgpool["PostgreSQL pool<br/>[db.js]"]
  node_postgres[("PostgreSQL database")]
  node_jsondata["JSON data files"]
end

node_visitor(("Visitor"))

node_visitor -->|"uses"| node_client
node_client -->|"HTTP requests"| node_server
node_server -->|"starts and seeds"| node_app
node_app -->|"mounts routes"| node_auth
node_app -->|"mounts routes"| node_challenges
node_app -->|"mounts routes"| node_user
node_app -->|"mounts routes"| node_admin
node_app -->|"reads home data"| node_jsondata
node_auth -->|"checks forward auth"| node_access
node_challenges -->|"checks authentication"| node_access
node_user -->|"checks authentication"| node_access
node_admin -->|"checks admin role"| node_access
node_auth -->|"queries users"| node_pgpool
node_challenges -->|"reads and records solves"| node_pgpool
node_user -->|"queries user data"| node_pgpool
node_admin -->|"manages platform data"| node_pgpool
node_pgpool -->|"queries"| node_postgres
node_auth -->|"renders auth pages"| node_views
node_challenges -->|"renders challenge pages"| node_views
node_user -->|"renders user pages"| node_views
node_admin -->|"renders admin pages"| node_views

click node_server "https://github.com/muhammadtalha15/ctf_platform/blob/main/server.js"
click node_app "https://github.com/muhammadtalha15/ctf_platform/blob/main/app.js"
click node_client "https://github.com/muhammadtalha15/ctf_platform/blob/main/public/js/app.js"
click node_auth "https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/auth.js"
click node_access "https://github.com/muhammadtalha15/ctf_platform/blob/main/midleware/auth.js"
click node_challenges "https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/challenges.js"
click node_user "https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/user.js"
click node_admin "https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/admin.js"
click node_views "https://github.com/muhammadtalha15/ctf_platform/tree/main/views"
click node_pgpool "https://github.com/muhammadtalha15/ctf_platform/blob/main/config/db.js"
click node_jsondata "https://github.com/muhammadtalha15/ctf_platform/tree/main/data"

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_app,node_client,node_views toneBlue
class node_auth,node_access toneAmber
class node_challenges,node_user toneMint
class node_admin toneRose
class node_pgpool,node_postgres,node_jsondata,node_visitor toneIndigo
```

## Components

### Web runtime

- [HTTP server](https://github.com/muhammadtalha15/ctf_platform/blob/main/server.js): `server.js`
- [Express application](https://github.com/muhammadtalha15/ctf_platform/blob/main/app.js): `app.js`
- [Browser interactions](https://github.com/muhammadtalha15/ctf_platform/blob/main/public/js/app.js): `public/js/app.js`
- [EJS pages](https://github.com/muhammadtalha15/ctf_platform/tree/main/views): `views`

### Identity and access

- [Authentication routes](https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/auth.js): `routes/auth.js`
- [Access middleware](https://github.com/muhammadtalha15/ctf_platform/blob/main/midleware/auth.js): `midleware/auth.js`

### CTF experience

- [Challenge routes](https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/challenges.js): `routes/challenges.js`
- [User routes](https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/user.js): `routes/user.js`

### Administration

- [Admin routes](https://github.com/muhammadtalha15/ctf_platform/blob/main/routes/admin.js): `routes/admin.js`

### Persistent state

- [PostgreSQL pool](https://github.com/muhammadtalha15/ctf_platform/blob/main/config/db.js): `config/db.js`
- **PostgreSQL database**
- [JSON data files](https://github.com/muhammadtalha15/ctf_platform/tree/main/data): `data`

### Other components

- **Visitor**

## Connections

- Visitor → Browser interactions: uses
- Browser interactions → HTTP server: HTTP requests
- HTTP server → Express application: starts and seeds
- Express application → Authentication routes: mounts routes
- Express application → Challenge routes: mounts routes
- Express application → User routes: mounts routes
- Express application → Admin routes: mounts routes
- Express application → JSON data files: reads home data
- Authentication routes → Access middleware: checks forward auth
- Challenge routes → Access middleware: checks authentication
- User routes → Access middleware: checks authentication
- Admin routes → Access middleware: checks admin role
- Authentication routes → PostgreSQL pool: queries users
- Challenge routes → PostgreSQL pool: reads and records solves
- User routes → PostgreSQL pool: queries user data
- Admin routes → PostgreSQL pool: manages platform data
- PostgreSQL pool → PostgreSQL database: queries
- Authentication routes → EJS pages: renders auth pages
- Challenge routes → EJS pages: renders challenge pages
- User routes → EJS pages: renders user pages
- Admin routes → EJS pages: renders admin pages
