# jyotraval/contest_unify architecture

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

- Interactive diagram: https://gitdiagram.com/jyotraval/contest_unify
- Repository: https://github.com/jyotraval/contest_unify

## Overview

##### Project type and purpose
- From the file tree and minimal README, this is a backend‐only “contest unifier” service. Its goal is to fetch programming contest data from multiple external platforms (AtCoder, CodeChef, Codeforces, HackEarth, LeetCode), normalize that data, and store it in a local SQLite database (`contest.db`).
- There is no frontend—this is essentially a data‐ingestion and consolidation microservice or scheduled job suite.

##### File structure
- Top‐level:
- README.md
- `backend_contest_unify/` (all Python modules and data files)
- Inside `backend_contest_unify/`:
- `backend_index.py` – likely the entry point / orchestrator
- `*_api_data.py` modules – each handles one platform’s API or web scraping
- `atcoder_web_scrap.py` – AtCoder requires HTML parsing
- `database_CRUD.py` – general database operations (insert, update, query)
- `contest.db` – the SQLite database file
- `contest_fetcher.log` – log output for fetch operations

##### README
- Only a title (`# contest_unify`). No extra sections. All context must come from file names and conventions.

a. Main components
- External Contest Platforms: AtCoder, CodeChef, Codeforces, HackEarth, LeetCode
- Contest Unifier Service:
– Orchestrator (`backend_index.py`)
– Platform Fetchers (`codechef_api_data.py`, `codeforce_api_data.py`, etc.)
– Database Access Layer (`database_CRUD.py`)
– Logging subsystem (`contest_fetcher.log`)
- Local Database: `contest.db` (SQLite)
b. Relationships & interactions
– Orchestrator triggers each Platform Fetcher on a schedule or via CLI
– Each Fetcher calls external REST APIs or scrapes HTML, returns raw contest info
– Database Access Layer receives normalized data objects and writes/updates `contest.db`
– Logging subsystem records successes, failures, and fetch metrics
c. Architectural patterns & design principles
– Modular design: one module per platform
– Single responsibility: each fetcher handles exactly one source
– Layered approach: orchestration layer → fetch layer → persistence layer
d. Key technologies
– Python 3.x
– Requests / BeautifulSoup (implied for web scraping)
– SQLite via `sqlite3` or an ORM in `database_CRUD.py`
– Standard logging module for `contest_fetcher.log`

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "External Contest Platforms"
        AC["AtCoder"]:::external
        CC["CodeChef"]:::external
        CF["Codeforces"]:::external
        HE["HackEarth"]:::external
        LC["LeetCode"]:::external
    end

    Orchestrator["Orchestrator\n(backend_index.py)"]:::internal
    ACFetcher["AtCoder Fetcher\n(atcoder_web_scrap.py)"]:::internal
    CCFetcher["CodeChef Fetcher\n(codechef_api_data.py)"]:::internal
    CFFetcher["Codeforces Fetcher\n(codeforce_api_data.py)"]:::internal
    HEFetcher["HackEarth Fetcher\n(hackearth_api_data.py)"]:::internal
    LCFetcher["LeetCode Fetcher\n(leetcode_api_data.py)"]:::internal

    DBLayer["Database CRUD Layer\n(database_CRUD.py)"]:::internal
    SQLiteDB["SQLite Database\n(contest.db)"]:::db
    Logs["Logging Output\n(contest_fetcher.log)"]:::log
    README["Project README\n(README.md)"]:::doc

    %% Orchestration flow
    Orchestrator -->|triggers| ACFetcher
    Orchestrator -->|triggers| CCFetcher
    Orchestrator -->|triggers| CFFetcher
    Orchestrator -->|triggers| HEFetcher
    Orchestrator -->|triggers| LCFetcher

    %% Fetchers call external platforms
    ACFetcher -->|GET contests| AC
    CCFetcher -->|GET contests| CC
    CFFetcher -->|GET contests| CF
    HEFetcher -->|GET contests| HE
    LCFetcher -->|GET contests| LC

    %% Persistence and logging
    ACFetcher -->|normalized data| DBLayer
    CCFetcher -->|normalized data| DBLayer
    CFFetcher -->|normalized data| DBLayer
    HEFetcher -->|normalized data| DBLayer
    LCFetcher -->|normalized data| DBLayer

    ACFetcher -->|WRITE log entry| Logs
    CCFetcher -->|WRITE log entry| Logs
    CFFetcher -->|WRITE log entry| Logs
    HEFetcher -->|WRITE log entry| Logs
    LCFetcher -->|WRITE log entry| Logs

    DBLayer -->|INSERT/UPDATE records| SQLiteDB

    README -.-> Orchestrator

    %% Click events
    click Orchestrator "https://github.com/jyotraval/contest_unify/blob/main/backend_contest_unify/backend_index.py"
    click ACFetcher "https://github.com/jyotraval/contest_unify/blob/main/backend_contest_unify/atcoder_web_scrap.py"
    click CCFetcher "https://github.com/jyotraval/contest_unify/blob/main/backend_contest_unify/codechef_api_data.py"
    click CFFetcher "https://github.com/jyotraval/contest_unify/blob/main/backend_contest_unify/codeforce_api_data.py"
    click HEFetcher "https://github.com/jyotraval/contest_unify/blob/main/backend_contest_unify/hackearth_api_data.py"
    click LCFetcher "https://github.com/jyotraval/contest_unify/blob/main/backend_contest_unify/leetcode_api_data.py"
    click DBLayer "https://github.com/jyotraval/contest_unify/blob/main/backend_contest_unify/database_CRUD.py"
    click SQLiteDB "https://github.com/jyotraval/contest_unify/blob/main/backend_contest_unify/contest.db"
    click Logs "https://github.com/jyotraval/contest_unify/blob/main/backend_contest_unify/contest_fetcher.log"
    click README "https://github.com/jyotraval/contest_unify/blob/main/README.md"

    %% Styles
    classDef internal fill:#cfe2f3,stroke:#0366d6,color:#0366d6,stroke-width:1px;
    classDef external fill:#fde2b4,stroke:#f4a460,color:#a45a52,stroke-width:1px;
    classDef db fill:#d4edda,stroke:#28a745,color:#155724,stroke-width:1px,stroke-dasharray: 5 5;
    classDef log fill:#eeeeee,stroke:#888888,color:#333333,stroke-width:1px;
    classDef doc fill:#f0f0f0,stroke:#999999,color:#444444,stroke-width:1px,stroke-dasharray: 2 2;
```
