# mehrasmeydani/i-guess-42 architecture

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

- Interactive diagram: https://gitdiagram.com/mehrasmeydani/i-guess-42
- Repository: https://github.com/mehrasmeydani/i-guess-42

## Overview

i guess low is a server-rendered daily lowest-unique-number game. Players sign in through 42, submit one irreversible guess with a confirmation step, and compete in rounds closing at 12:42 Europe/Vienna. Closed-round results, per-day detail, and trends are separate browsing stages; test-instance administration adds clock controls, demo players, ghost guesses, round clearing, and synthetic history. A points worker can settle winners through an optional external API. The graph reflects documented capabilities; handler internals are only partially sampled, so uncertain wiring is omitted.

Main entry points: [`src/handlers.rs`](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/handlers.rs) (HTTP handlers), [`src/db.rs`](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/db.rs) (Database access), [`src/points.rs`](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/points.rs) (Points settlement), [`src/auth.rs`](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/auth.rs) (Auth and sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Game web flow"]
  node_handlers["HTTP handlers<br/>[handlers.rs]"]
  node_auth["Auth and sessions<br/>[auth.rs]"]
  node_templates["Page rendering<br/>[templates.rs]"]
  node_state["App state<br/>[app.rs]"]
end

subgraph group_domain["Game domain"]
  node_round["Round clock<br/>[round.rs]"]
  node_stats["Results and trends<br/>[stats.rs]"]
end

subgraph group_data["Persistence"]
  node_db_code["Database access<br/>[db.rs]"]
  node_game_db[("SQLite game store")]
  node_schema["Database schema"]
end

subgraph group_operations["Admin and payouts"]
  node_demo["Demo history<br/>[demo.rs]"]
  node_points["Points settlement<br/>[points.rs]"]
end

node_players(("Players"))
node_admins(("Test admins"))
node_intra["42 Intra OAuth"]
node_points_api["Points API"]

node_players -->|"submit requests"| node_handlers
node_admins -->|"manage test game"| node_handlers
node_handlers -->|"resolve sessions"| node_auth
node_handlers -->|"request OAuth"| node_intra
node_handlers -->|"derive current round"| node_round
node_handlers -->|"read and write game data"| node_db_code
node_handlers -->|"build statistics"| node_stats
node_handlers -->|"generate history"| node_demo
node_handlers -->|"render pages"| node_templates
node_handlers -->|"use shared state"| node_state
node_auth -->|"exchange code and fetch profile"| node_intra
node_db_code -->|"query and persist"| node_game_db
node_schema -->|"defines tables"| node_game_db
node_demo -->|"supply generated guesses"| node_db_code
node_points -->|"read winners and record payouts"| node_db_code
node_points -.->|"send winner payout"| node_points_api
node_state -->|"apply test clock offset"| node_round

click node_handlers "https://github.com/mehrasmeydani/i-guess-42/blob/main/src/handlers.rs"
click node_auth "https://github.com/mehrasmeydani/i-guess-42/blob/main/src/auth.rs"
click node_templates "https://github.com/mehrasmeydani/i-guess-42/blob/main/src/templates.rs"
click node_round "https://github.com/mehrasmeydani/i-guess-42/blob/main/src/round.rs"
click node_stats "https://github.com/mehrasmeydani/i-guess-42/blob/main/src/stats.rs"
click node_demo "https://github.com/mehrasmeydani/i-guess-42/blob/main/src/demo.rs"
click node_points "https://github.com/mehrasmeydani/i-guess-42/blob/main/src/points.rs"
click node_state "https://github.com/mehrasmeydani/i-guess-42/blob/main/src/app.rs"
click node_db_code "https://github.com/mehrasmeydani/i-guess-42/blob/main/src/db.rs"
click node_schema "https://github.com/mehrasmeydani/i-guess-42/tree/main/migrations"

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_handlers,node_auth,node_templates,node_state toneBlue
class node_round,node_stats toneAmber
class node_db_code,node_game_db,node_schema,node_points_api toneMint
class node_demo,node_points toneRose
class node_players,node_admins,node_intra toneIndigo
```

## Components

### Game web flow

- [HTTP handlers](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/handlers.rs): `src/handlers.rs`
- [Auth and sessions](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/auth.rs): `src/auth.rs`
- [Page rendering](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/templates.rs): `src/templates.rs`
- [App state](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/app.rs): `src/app.rs`

### Game domain

- [Round clock](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/round.rs): `src/round.rs`
- [Results and trends](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/stats.rs): `src/stats.rs`

### Persistence

- [Database access](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/db.rs): `src/db.rs`
- **SQLite game store**
- [Database schema](https://github.com/mehrasmeydani/i-guess-42/tree/main/migrations): `migrations`

### Admin and payouts

- [Demo history](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/demo.rs): `src/demo.rs`
- [Points settlement](https://github.com/mehrasmeydani/i-guess-42/blob/main/src/points.rs): `src/points.rs`

### Other components

- **Players**
- **Test admins**
- **42 Intra OAuth**
- **Points API**

## Connections

- Players → HTTP handlers: submit requests
- Test admins → HTTP handlers: manage test game
- HTTP handlers → Auth and sessions: resolve sessions
- HTTP handlers → 42 Intra OAuth: request OAuth
- HTTP handlers → Round clock: derive current round
- HTTP handlers → Database access: read and write game data
- HTTP handlers → Results and trends: build statistics
- HTTP handlers → Demo history: generate history
- HTTP handlers → Page rendering: render pages
- HTTP handlers → App state: use shared state
- Auth and sessions → 42 Intra OAuth: exchange code and fetch profile
- Database access → SQLite game store: query and persist
- Database schema → SQLite game store: defines tables
- Demo history → Database access: supply generated guesses
- Points settlement → Database access: read winners and record payouts
- Points settlement → Points API: send winner payout
- App state → Round clock: apply test clock offset
