# sofyc/conquer architecture

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

- Interactive diagram: https://gitdiagram.com/sofyc/conquer
- Repository: https://github.com/sofyc/conquer

## Overview

##### Project type and purpose
- ConQuer is a stand-alone Python framework (CLI tool) whose sole purpose is to generate, assemble, and evaluate concept-based quizzes.
- It consists of four independent “mini-applications” (question generator, concept generator, full-quiz generator, and evaluator) that can be run separately or chained together.

##### File structure
Top-level files and directories:
- `.gitignore`, `requirements.txt` – typical Python project files.
- `generate_concept.py` – drive script for concept generation.
- `generate_question.py` – drive script for question generation.
- `wiki.py` – orchestrator that uses concepts + questions to build a quiz.
- `evaluation.py` – drive script for evaluating quiz quality.
- `*.json` files (`concepts.json`, `questions.json`, `wiki.json`, `quiz_concept_wiki.json`, `areas.txt`) – on-disk data store for intermediate inputs/outputs.

##### README for additional insights
- Dependencies: OpenAI and Gemini APIs accessed via environment variables.
- Usage: each step is invoked via its own Python entry point.
- No external database; data flows through flat JSON files.

a. Main components
1. CLI Entry Points
– generate_concept.py
– generate_question.py
– wiki.py (full-pipeline orchestrator)
– evaluation.py
2. Local JSON Data Store
– concepts.json, questions.json, wiki.json, quiz_concept_wiki.json, areas.txt
3. External Services
– OpenAI API
– Gemini API
4. Environment Variables
– OPENAI_API_KEY
– GEMINI_API_KEY

b. Relationships and interactions
– Each CLI script reads from and writes to specific JSON files.
– Scripts call out to external APIs (OpenAI, Gemini) to perform NLP tasks.
– The orchestrator (`wiki.py`) ties together the output of `generate_concept.py` and `generate_question.py` to produce final quiz JSON.
– `evaluation.py` reads the generated quiz JSON and may call APIs or local heuristics to score the quiz.

c. Architectural patterns/design principles
– Pipeline pattern: each stage is decoupled and can be run independently.
– Separation of concerns: concept generation, question generation, quiz assembly, and evaluation are separate modules.
– Data-driven: JSON files act as both input and output, making the system extensible and easy to debug.

d. Key technologies/frameworks/libraries
– Python 3.x
– OpenAI Python SDK (for GPT calls)
– Gemini API client
– JSON for serialization

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Config"
        Env["Config: Env Variables"]:::config
    end

    subgraph "External Services"
        OpenAI["OpenAI API"]:::external
        Gemini["Gemini API"]:::external
    end

    subgraph "CLI Entry Points"
        GenC["generate_concept.py"]:::cli
        GenQ["generate_question.py"]:::cli
        Wiki["wiki.py"]:::cli
        Eval["evaluation.py"]:::cli
    end

    subgraph "Local JSON Data Store"
        Concepts(("concepts.json")):::data
        Questions(("questions.json")):::data
        WikiData(("wiki.json")):::data
        Quiz(("quiz_concept_wiki.json")):::data
        Areas(("areas.txt")):::data
    end

    subgraph "Project Metadata"
        Req["requirements.txt"]:::metadata
        GitIgnore[".gitignore"]:::metadata
        Readme["README.md"]:::metadata
    end

    Env --> GenC
    Areas --> GenC
    GenC -->|"concept list JSON"| Concepts
    GenC -->|calls API| OpenAI
    GenC -->|calls API| Gemini

    Env --> GenQ
    Concepts --> GenQ
    GenQ -->|"question list JSON"| Questions
    GenQ -->|calls API| OpenAI
    GenQ -->|calls API| Gemini

    Env --> Wiki
    Concepts --> Wiki
    Questions --> Wiki
    Wiki -->|"wiki intermediate JSON"| WikiData
    Wiki -->|"final quiz JSON"| Quiz
    Wiki -->|calls API| OpenAI
    Wiki -->|calls API| Gemini

    Env --> Eval
    Quiz --> Eval
    Eval -->|evaluation results| Quiz
    Eval -->|calls API| OpenAI
    Eval -->|calls API| Gemini

    click GenC "https://github.com/sofyc/conquer/blob/main/generate_concept.py"
    click GenQ "https://github.com/sofyc/conquer/blob/main/generate_question.py"
    click Wiki "https://github.com/sofyc/conquer/blob/main/wiki.py"
    click Eval "https://github.com/sofyc/conquer/blob/main/evaluation.py"
    click Concepts "https://github.com/sofyc/conquer/blob/main/concepts.json"
    click Questions "https://github.com/sofyc/conquer/blob/main/questions.json"
    click WikiData "https://github.com/sofyc/conquer/blob/main/wiki.json"
    click Quiz "https://github.com/sofyc/conquer/blob/main/quiz_concept_wiki.json"
    click Areas "https://github.com/sofyc/conquer/blob/main/areas.txt"
    click Req "https://github.com/sofyc/conquer/blob/main/requirements.txt"
    click GitIgnore "https://github.com/sofyc/conquer/blob/main/.gitignore"
    click Readme "https://github.com/sofyc/conquer/blob/main/README.md"

    classDef cli fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef data fill:#FFD700,stroke:#333,stroke-width:1px
    classDef external fill:#90EE90,stroke:#333,stroke-width:1px
    classDef config fill:#FFB6C1,stroke:#333,stroke-width:1px
    classDef metadata fill:#D3D3D3,stroke:#333,stroke-width:1px
```
