# thamjianhao/auto-attendance-bot architecture

> Architecture diagram of the GitHub repository thamjianhao/auto-attendance-bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thamjianhao/auto-attendance-bot
- Repository: https://github.com/thamjianhao/auto-attendance-bot

## Overview

##### Project Type and Purpose
- This is a lightweight, monolithic web application built with Flask.
- Purpose: Automate the multi-step student class check-in process into a single click via
a. A server-rendered HTML form (templates/index.html)
b. A JSON-based API endpoint (`/icheckin`).

##### File Structure Analysis
- Top-level files:
- `main.py` – the single Flask app entry point, defines both the web UI route (`GET /`) and the API route (`POST /icheckin`).
- `requirements.txt` – Python dependencies (Flask, requests or similar).
- `templates/index.html` – Jinja2 template for the form UI.
- No separate `static`, `frontend`, or `backend` directories: this is a simple two-tier monolith (presentation + application logic).
- No database layer—user credentials and check-in codes are handled in memory and immediately forwarded to the external university system.

##### Key Architecture Details from README
- Two user interaction modes:
- Browser-driven via HTML form → internal Flask logic → external attendance portal
- Programmatic via JSON API → same internal logic → external portal
- Hosted on Render with an auto-sleep/wake cycle; no persistent storage.
- Security note: credentials are transient (in-memory only).

##### Main Components and Interactions
A. Clients
- Web Browser (renders HTML form)
- API Consumer (cURL, Postman, other scripts)
B. Flask Application Server (`main.py`)
1. Presentation Layer: routes and template rendering
2. Business Logic Layer:
- User authentication against external system
- Check-in code submission to external system
3. Response Layer:
- HTML response for browser
- JSON response for API clients
C. External University Attendance System
- The remote site where students normally log in and submit codes
D. Hosting Infrastructure (Render)
- HTTP load balancer/ingress
- Container or server running the Flask process

##### Architectural Patterns and Design Principles
- Monolithic two-tier architecture: Presentation + Application Logic in one codebase
- Single responsibility per route: one endpoint to render UI, one to handle API
- Stateless interactions: each check-in request is independent; no session persistence beyond the request
- “Anti-pattern” avoidance: no local credential storage, no long-running sessions

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Tier"
        BrowserClient["Browser Client"]:::client
        APIClient["API Client"]:::client
    end

    subgraph "Hosting Infrastructure"
        LoadBalancer["HTTP Load Balancer / Ingress"]:::infra
    end

    subgraph "Application Tier"
        subgraph "Flask App Server"
            Presentation["Presentation Layer<br/>(GET /)"]:::app
            APIEndpoint["JSON API Endpoint<br/>(POST /icheckin)"]:::app
            BusinessLogic["Business Logic Layer"]:::app
            Template["Jinja2 Template<br/>index.html"]:::app
        end
        Dependencies["Python Dependencies<br/>(requirements.txt)"]:::docs
        Documentation["Project Documentation<br/>(README.md)"]:::docs
    end

    External["University Attendance Portal"]:::ext

    BrowserClient -->|HTTP GET /| LoadBalancer
    APIClient -->|HTTP POST /icheckin| LoadBalancer

    LoadBalancer --> Presentation
    LoadBalancer --> APIEndpoint

    Presentation --> Template
    Presentation --> BusinessLogic

    APIEndpoint --> BusinessLogic

    BusinessLogic -->|submit credentials & code| External
    External -->|response| BusinessLogic

    BusinessLogic --> Presentation
    BusinessLogic --> APIEndpoint

    FlaskAppServer(("Flask App Server")):::appInvisible
    Presentation --> FlaskAppServer
    APIEndpoint --> FlaskAppServer
    BusinessLogic --> FlaskAppServer
    Template --> FlaskAppServer

    Dependencies --> FlaskAppServer
    Documentation --> FlaskAppServer

    click FlaskAppServer "https://github.com/thamjianhao/auto-attendance-bot/blob/main/main.py"
    click Presentation "https://github.com/thamjianhao/auto-attendance-bot/blob/main/main.py"
    click APIEndpoint "https://github.com/thamjianhao/auto-attendance-bot/blob/main/main.py"
    click BusinessLogic "https://github.com/thamjianhao/auto-attendance-bot/blob/main/main.py"
    click Template "https://github.com/thamjianhao/auto-attendance-bot/blob/main/templates/index.html"
    click Dependencies "https://github.com/thamjianhao/auto-attendance-bot/blob/main/requirements.txt"
    click Documentation "https://github.com/thamjianhao/auto-attendance-bot/blob/main/README.md"

    classDef client fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef infra fill:#B0C4DE,stroke:#000,stroke-width:1px
    classDef app fill:#90EE90,stroke:#000,stroke-width:1px
    classDef ext fill:#FFA500,stroke:#000,stroke-width:1px,stroke-dasharray: 5 5
    classDef docs fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef appInvisible fill:none,stroke:none, color:none
```
