# vietnguyen2358/rankrealm architecture

> Architecture diagram of the GitHub repository vietnguyen2358/rankrealm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vietnguyen2358/rankrealm
- Repository: https://github.com/vietnguyen2358/rankrealm

## Overview

##### Project type and purpose
- This is a monolithic, full-stack web application built with Flask (Python).
- It provides user authentication, event and leaderboard management, and user profiles (as seen in templates and models).

##### File structure
- main.py: the Flask app entry point.
- website/
- auth.py – authentication logic (Flask-Login + bcrypt)
- models.py – data schema definitions via SQLAlchemy
- views.py – HTTP route handlers (controllers)
- static/ – CSS, JavaScript, images (client assets)
- templates/ – Jinja2 templates (HTML views)

##### README
- Confirms Flask, Flask-SQLAlchemy, Flask-Login, bcrypt are core dependencies.
- Instructs how to launch the site via `flask --app main run`.

##### Main components
a. Client / Browser (front-end user interface)
b. Flask Application Server (main.py + website package)
- Controllers (views.py)
- Business logic (auth.py, any service modules)
- ORM layer (models.py)
c. Database (e.g., SQLite or other DB used via SQLAlchemy)
d. Static asset store (served by Flask’s static route)
e. External libraries/services
- Flask, Flask-SQLAlchemy, Flask-Login, bcrypt

##### Relationships & interactions
- Browser → HTTP(S) requests → Flask server
- Flask server routes requests to controllers (views.py)
- Controllers invoke authentication modules (auth.py) and ORM models (models.py)
- ORM communicates with the Database
- Controllers render Jinja templates, injecting data from models
- Static assets (CSS, JS, images) are served directly by Flask’s static endpoint

##### Architectural patterns & design principles
- Monolith with MVC-like separation:
- Models = website/models.py
- Views = website/templates + static
- Controllers = website/views.py + auth.py
- Dependency inversion: external libraries abstracted (SQLAlchemy for DB, Flask-Login for sessions)
- Single process for all components (no microservices)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Browser
    Browser["User's Browser"]:::frontend

    %% Frontend Assets
    subgraph "Frontend Assets"
        Templates["Jinja2 Templates"]:::frontend
        Static["Static Assets"]:::frontend
        Static --> CSS["CSS Files"]:::frontend
        Static --> JS["index.js"]:::frontend
        Static --> Images["Images"]:::frontend
    end

    %% Application Server
    subgraph "Flask Application Server"
        Init["__init__.py"]:::backend
        Main["main.py"]:::backend
        Views["website/views.py: HTTP Routes"]:::backend
        Auth["website/auth.py: Auth & Sessions"]:::backend
        Models["website/models.py: ORM Models"]:::backend
    end

    %% Database
    Database[(SQLite via SQLAlchemy)]:::database

    %% External Libraries
    subgraph "External Libraries"
        Flask["Flask"]:::external
        SQLAlchemy["Flask-SQLAlchemy"]:::external
        Login["Flask-Login"]:::external
        Bcrypt["bcrypt"]:::external
    end

    %% Connections
    Browser -->|"HTTP GET/POST"| Main
    Main --> Views
    Views -->|"invoke auth"| Auth
    Views -->|"query models"| Models
    Models -->|"SQL queries"| Database
    Views -->|"render templates"| Templates
    Views -->|"serve assets"| Static

    Main --> Flask
    Models --> SQLAlchemy
    Views --> Login
    Auth --> Bcrypt

    %% Click Events
    click Templates "https://github.com/vietnguyen2358/rankrealm/tree/main/website/templates/"
    click Static "https://github.com/vietnguyen2358/rankrealm/tree/main/website/static/"
    click CSS "https://github.com/vietnguyen2358/rankrealm/blob/main/website/static/css/*.css"
    click JS "https://github.com/vietnguyen2358/rankrealm/blob/main/website/static/index.js"
    click Images "https://github.com/vietnguyen2358/rankrealm/tree/main/website/static/images/"
    click Main "https://github.com/vietnguyen2358/rankrealm/blob/main/main.py"
    click Init "https://github.com/vietnguyen2358/rankrealm/blob/main/website/__init__.py"
    click Views "https://github.com/vietnguyen2358/rankrealm/blob/main/website/views.py"
    click Auth "https://github.com/vietnguyen2358/rankrealm/blob/main/website/auth.py"
    click Models "https://github.com/vietnguyen2358/rankrealm/blob/main/website/models.py"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef database fill:#F5DEB3,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
