# alejandrotejero/gamerank architecture

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

- Interactive diagram: https://gitdiagram.com/alejandrotejero/gamerank
- Repository: https://github.com/alejandrotejero/gamerank

## Overview

#### Purpose and Runtime
GameRank is a server-rendered Django 5.1 web application for aggregating game catalog data and supporting authenticated user interactions: ratings, comments, comment reactions, follows, profile settings, and JSON game export. It runs via Django’s development/WSGI/ASGI entry points: `project/manage.py`, `project/project/wsgi.py`, and `project/project/asgi.py`. Persistence is SQLite (`project/db.sqlite3`); remote catalog ingestion uses `requests`.

#### Request Routing and Presentation
Project-level routing delegates application URLs through `project/project/urls.py` and `project/gamerank/urls.py`. Request handlers in `project/gamerank/views.py` render Django templates, primarily using shared layout/navigation plus catalog, detail, account, and interaction screens:
- `project/gamerank/templates/gamerank/base.html`
- `project/gamerank/templates/gamerank/detalles_juego.html`
- `project/gamerank/templates/gamerank/detalles_juego_dinamico.html`

Django’s registration/login templates under `project/gamerank/templates/registration` integrate with the authentication flow.

#### Domain and Persistence Model
The core domain is defined in `project/gamerank/models.py` and evolved through `project/gamerank/migrations/`. It centers on games with source-prefixed stable IDs, stored rating aggregate fields and vote counts; user-to-game ratings; comments; per-user comment votes; game follows; and user profile data. The migrations show the key schema evolution for ratings, followers, profiles, and comment likes/dislikes:
- `project/gamerank/migrations/0002_game_rating_game_votes.py`
- `project/gamerank/migrations/0005_perfilusuario.py`
- `project/gamerank/migrations/0008_votocomentario.py`

#### Catalog Ingestion Boundary
Catalog synchronization is separated from request views in `project/gamerank/manageData.py`. This boundary consumes a remote XML feed and the FreeToGame and MMOBomb APIs, normalizes source records, and persists them as games under `LIS1-`, `FTP-`, and `MMO-` ID namespaces. Remote network/API variability is therefore isolated from the local database-backed browsing experience.

#### Game Interaction Flows
Catalog requests list games ordered by stored aggregate rating and can filter by source prefix. Detail requests combine game metadata with ratings and comments. Authenticated actions update relational state: one rating per user/game is created or revised, then the game’s average and vote count are recalculated; comments are attached to games; comment reactions toggle or switch like/dislike state; and follows create/remove user-game membership. These flows are implemented across `project/gamerank/views.py`, `project/gamerank/forms.py`, and `project/gamerank/models.py`.

#### Dynamic and Export Interfaces
The dynamic game-detail variant supports HTMX-driven comment refreshes, allowing a fragment response rather than a full document reload:
- `project/gamerank/templates/gamerank/detalles_juego_dinamico.html`
- `project/gamerank/templates/gamerank/comments.html`

A separate view path exposes individual game information as JSON for download/API-like consumption. This is a server-generated export over the same persisted game model, not a separate service.

#### User Experience and Shared UI
Shared navigation, footer content, and styling support the server-rendered interface:
- `project/gamerank/templates/gamerank/navbarFuncional.html`
- `project/gamerank/manageFooter.py`
- `project/gamerank/static/css/style.css`

User-facing account pages surface voting metrics, followed/voted games, and profile alias/font preferences through the same Django session/authentication boundary.

Main entry points: [`project/gamerank/views.py`](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/views.py) (Request handlers), [`project/gamerank/models.py`](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/models.py) (GameRank models), [`project/gamerank/manageData.py`](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/manageData.py) (Catalog synchronization), [`project/project/urls.py`](https://github.com/alejandrotejero/gamerank/blob/main/project/project/urls.py) (Project routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Django Runtime"]
  node_entrypoints{{"Django entry points<br/>runtime<br/>[manage.py]"}}
  node_project_urls["Project routing<br/>Django URLs<br/>[urls.py]"]
end

subgraph group_web["Web UI"]
  node_app_urls["GameRank routes<br/>Django URLs<br/>[urls.py]"]
  node_views["Request handlers<br/>Django views<br/>[views.py]"]
  node_forms["Interaction forms<br/>Django forms<br/>[forms.py]"]
  node_auth["Session authentication<br/>Django auth"]
  node_templates["Server-rendered screens<br/>Django templates<br/>[base.html]"]
  node_dynamic_detail["HTMX game detail<br/>template fragment flow"]
  node_comments_fragment["Comments fragment<br/>template fragment<br/>[comments.html]"]
  node_styles["Shared styling<br/>CSS<br/>[style.css]"]
  node_json_export["Game JSON export<br/>server-generated JSON<br/>[views.py]"]
end

subgraph group_domain["Domain &amp; Data"]
  node_models["GameRank models<br/>Django ORM<br/>[models.py]"]
  node_migrations["Schema evolution<br/>Django migrations"]
  node_sqlite[("GameRank database<br/>SQLite<br/>[db.sqlite3]")]
  node_rating_aggregate["Rating aggregation<br/>domain workflow<br/>[views.py]"]
end

subgraph group_catalog["Catalog Sync"]
  node_catalog_sync["Catalog synchronization<br/>ingestion module<br/>[manageData.py]"]
  node_remote_catalogs{{"Remote catalog sources<br/>XML and REST APIs"}}
end

node_entrypoints -->|"starts Django routing"| node_project_urls
node_project_urls -->|"includes app URLs"| node_app_urls
node_app_urls -->|"dispatches requests"| node_views
node_views -->|"validates writes"| node_forms
node_views -->|"uses authenticated sessions"| node_auth
node_views -->|"renders full pages"| node_templates
node_views -->|"serves dynamic detail"| node_dynamic_detail
node_dynamic_detail -.->|"HTMX refresh"| node_comments_fragment
node_templates -.->|"applies shared CSS"| node_styles
node_views -->|"queries and updates"| node_models
node_forms -->|"maps interaction input"| node_models
node_models -->|"persists relational state"| node_sqlite
node_migrations -->|"defines schema"| node_sqlite
node_views -->|"rating create or revision"| node_rating_aggregate
node_rating_aggregate -->|"updates rating fields"| node_models
node_catalog_sync -->|"fetches with requests"| node_remote_catalogs
node_catalog_sync -->|"normalizes and persists games"| node_models
node_views -->|"serializes game detail"| node_json_export
node_json_export -->|"reads persisted game"| node_models

click node_entrypoints "https://github.com/alejandrotejero/gamerank/blob/main/project/manage.py"
click node_project_urls "https://github.com/alejandrotejero/gamerank/blob/main/project/project/urls.py"
click node_app_urls "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/urls.py"
click node_views "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/views.py"
click node_forms "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/forms.py"
click node_auth "https://github.com/alejandrotejero/gamerank/tree/main/project/gamerank/templates/registration"
click node_templates "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/templates/gamerank/base.html"
click node_dynamic_detail "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/templates/gamerank/detalles_juego_dinamico.html"
click node_comments_fragment "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/templates/gamerank/comments.html"
click node_styles "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/static/css/style.css"
click node_models "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/models.py"
click node_migrations "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/migrations/0008_votocomentario.py"
click node_sqlite "https://github.com/alejandrotejero/gamerank/blob/main/project/db.sqlite3"
click node_rating_aggregate "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/views.py"
click node_catalog_sync "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/manageData.py"
click node_json_export "https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/views.py"

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_entrypoints,node_project_urls toneBlue
class node_app_urls,node_views,node_forms,node_auth,node_templates,node_dynamic_detail,node_comments_fragment,node_styles,node_json_export toneAmber
class node_models,node_migrations,node_sqlite,node_rating_aggregate toneMint
class node_catalog_sync,node_remote_catalogs toneRose
```

## Components

### Django Runtime

- [Django entry points](https://github.com/alejandrotejero/gamerank/blob/main/project/manage.py): runtime · Development, WSGI, and ASGI startup. · `project/manage.py`
- [Project routing](https://github.com/alejandrotejero/gamerank/blob/main/project/project/urls.py): Django URLs · `project/project/urls.py`

### Web UI

- [GameRank routes](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/urls.py): Django URLs · `project/gamerank/urls.py`
- [Request handlers](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/views.py): Django views · Catalog, detail, account, interaction, and JSON export handlers. · `project/gamerank/views.py`
- [Interaction forms](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/forms.py): Django forms · `project/gamerank/forms.py`
- [Session authentication](https://github.com/alejandrotejero/gamerank/tree/main/project/gamerank/templates/registration): Django auth · Registration and login use Django authentication templates. · `project/gamerank/templates/registration`
- [Server-rendered screens](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/templates/gamerank/base.html): Django templates · Shared layout, catalog, game details, and account pages. · `project/gamerank/templates/gamerank/base.html`
- [HTMX game detail](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/templates/gamerank/detalles_juego_dinamico.html): template fragment flow · Refreshes comments without a full document reload. · `project/gamerank/templates/gamerank/detalles_juego_dinamico.html`
- [Comments fragment](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/templates/gamerank/comments.html): template fragment · `project/gamerank/templates/gamerank/comments.html`
- [Shared styling](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/static/css/style.css): CSS · `project/gamerank/static/css/style.css`
- [Game JSON export](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/views.py): server-generated JSON · Exports an individual persisted game; not a separate service. · `project/gamerank/views.py`

### Domain & Data

- [GameRank models](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/models.py): Django ORM · Games, ratings, comments, reactions, follows, and user profiles. · `project/gamerank/models.py`
- [Schema evolution](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/migrations/0008_votocomentario.py): Django migrations · Adds rating aggregates, profiles, and comment reactions. · `project/gamerank/migrations/0008_votocomentario.py`
- [GameRank database](https://github.com/alejandrotejero/gamerank/blob/main/project/db.sqlite3): SQLite · Local persisted catalog and user interaction state. · `project/db.sqlite3`
- [Rating aggregation](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/views.py): domain workflow · One rating per user/game; game average and vote count are recalculated. · `project/gamerank/views.py`

### Catalog Sync

- [Catalog synchronization](https://github.com/alejandrotejero/gamerank/blob/main/project/gamerank/manageData.py): ingestion module · Normalizes remote records into stable source-prefixed game IDs. · `project/gamerank/manageData.py`
- **Remote catalog sources**: XML and REST APIs · XML feed, FreeToGame, and MMOBomb supply catalog records.

## Connections

- Django entry points → Project routing: starts Django routing
- Project routing → GameRank routes: includes app URLs
- GameRank routes → Request handlers: dispatches requests
- Request handlers → Interaction forms: validates writes
- Request handlers → Session authentication: uses authenticated sessions
- Request handlers → Server-rendered screens: renders full pages
- Request handlers → HTMX game detail: serves dynamic detail
- HTMX game detail → Comments fragment: HTMX refresh
- Server-rendered screens → Shared styling: applies shared CSS
- Request handlers → GameRank models: queries and updates
- Interaction forms → GameRank models: maps interaction input
- GameRank models → GameRank database: persists relational state
- Schema evolution → GameRank database: defines schema
- Request handlers → Rating aggregation: rating create or revision
- Rating aggregation → GameRank models: updates rating fields
- Catalog synchronization → Remote catalog sources: fetches with requests
- Catalog synchronization → GameRank models: normalizes and persists games
- Request handlers → Game JSON export: serializes game detail
- Game JSON export → GameRank models: reads persisted game
