# sunnysavita10/automated-mcq-generator-using-langchain-openai-api architecture

> Architecture diagram of the GitHub repository sunnysavita10/automated-mcq-generator-using-langchain-openai-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api
- Repository: https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api

## Overview

##### Project type and purpose
- This is a Python-based MCQ (Multiple Choice Question) Generator project that ships both as a library/package (`mcqgenrator`) and a lightweight web interface via Streamlit (`StreamlitAPP.py`).
- Purpose: ingest raw data, generate MCQs, log operations, and optionally serve results via a browser UI or save to JSON.

##### File structure
Top-level:
- setup.py, requirements.txt – packaging and dependencies
- StreamlitAPP.py – entry point for the web UI
- test.py – simple script or smoke test for CLI usage
- data.txt, Response.json – sample input/output artifacts
- logs/ – runtime logs
- experiment/ – exploratory notebooks and sample CSVs

src/mcqgenrator:
- MCQGenerator.py – core service class implementing MCQ generation
- utils.py – helper routines (parsing, data shaping)
- logger.py – centralized logging setup

##### README for additional insights
- README is empty; we infer architecture purely from structure and naming.

a. Main components
1. Presentation Layer
– Streamlit Web UI (StreamlitAPP.py)
– CLI/Test Script (test.py)
2. Core Service
– MCQGenerator class
3. Utilities
– utils.py (data parsing, formatting)
– logger.py (logging adapter)
4. Data Stores
– Raw data (data.txt, experiment/*.csv)
– Generated output (Response.json)
– Logs (logs/*.log)
5. Packaging/Deployment
– setup.py / requirements.txt

b. Relationships & data flows
– User triggers via Web UI or CLI → UI/CLI calls MCQGenerator
– MCQGenerator uses utils to parse raw data
– Core logic applies NLP or templating to produce MCQs
– Results written to Response.json and returned to UI/CLI
– logger captures events at each step and writes to logs/

c. Architectural patterns / design principles
– Layered architecture: Presentation → Service → Utilities → Data
– Separation of concerns: UI code is entirely separate from generation logic
– Single responsibility: MCQGenerator focuses solely on question generation

d. Key technologies
– Python 3.x
– Streamlit for UI
– Standard logging module (wrapped in logger.py)
– Packaging via setuptools (setup.py)

– Capture all essential pieces: input data sources, the core algorithm, utility modules, logging, and output sinks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        StreamlitUI["Streamlit Web UI\n(StreamlitAPP.py)"]:::presentation
        CLI["CLI/Test Script\n(test.py)"]:::presentation
    end

    %% Core Service
    subgraph "Core Service"
        direction TB
        MCQGen["MCQGenerator Service\n(MCQGenerator.py)"]:::core
    end

    %% Utilities
    subgraph "Utilities"
        direction TB
        Utils["Data Parsing & Formatting\n(utils.py)"]:::util
        Logger["Logging Adapter\n(logger.py)"]:::util
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        RawData["Raw Input Data\n(data.txt)"]:::storage
        ExpCSV["Experimental CSV Data\n(machinelearning.csv)"]:::storage
        MCQOutput["Generated MCQ Output\n(Response.json)"]:::storage
        LogsFile["Runtime Logs\n(12_12_2023_15_47_13.log)"]:::storage
    end

    %% Packaging/Deployment
    subgraph "Packaging/Deployment"
        direction TB
        Setup["Package Setup Script\n(setup.py)"]:::packaging
        Requirements["Dependencies List\n(requirements.txt)"]:::packaging
    end

    %% Connections
    StreamlitUI -->|"invoke(generate)"| MCQGen
    CLI -->|"invoke(generate)"| MCQGen
    MCQGen -->|"uses parse routines"| Utils
    MCQGen -->|"logs events"| Logger
    Utils -->|"reads raw text"| RawData
    Utils -->|"reads CSV data"| ExpCSV
    MCQGen -->|"writes MCQ JSON"| MCQOutput
    Logger -->|"writes logs"| LogsFile

    %% Click Events
    click StreamlitUI "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/StreamlitAPP.py"
    click CLI "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/test.py"
    click MCQGen "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/src/mcqgenrator/MCQGenerator.py"
    click Utils "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/src/mcqgenrator/utils.py"
    click Logger "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/src/mcqgenrator/logger.py"
    click RawData "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/data.txt"
    click ExpCSV "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/experiment/machinelearning.csv"
    click MCQOutput "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/Response.json"
    click LogsFile "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/logs/12_12_2023_15_47_13.log"
    click Setup "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/setup.py"
    click Requirements "https://github.com/sunnysavita10/automated-mcq-generator-using-langchain-openai-api/blob/main/requirements.txt"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef core fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef util fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef storage fill:#f2d7d5,stroke:#333,stroke-width:1px
    classDef packaging fill:#e6ccff,stroke:#333,stroke-width:1px
```
