# alexhysel/42-call-me-maybe architecture

> Architecture diagram of the GitHub repository alexhysel/42-call-me-maybe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alexhysel/42-call-me-maybe
- Repository: https://github.com/alexhysel/42-call-me-maybe

## Overview

Call Me Maybe converts prompt records and function schemas into constrained, schema-shaped tool-call JSON, using a local Qwen model and custom tokenizer. A companion Moulinette CLI prepares exercise inputs and correction files, then grades submitted calls against the exercise functions. The graph separates request orchestration, decoding internals, and exercise authoring/grading. Relationships in Moulinette follow the sampled CLI and source-index references; implementation details of several CLI operations were not fully excerpted.

Main entry points: [`src/__main__.py`](https://github.com/alexhysel/42-call-me-maybe/blob/main/src/__main__.py) (Generation CLI), [`src/callmemaybe.py`](https://github.com/alexhysel/42-call-me-maybe/blob/main/src/callmemaybe.py) (CallMeMaybe), [`moulinette/moulinette/__main__.py`](https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/__main__.py) (Exercise CLI), [`src/llm.py`](https://github.com/alexhysel/42-call-me-maybe/blob/main/src/llm.py) (Constrained inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_request["Call generation"]
  node_cli["Generation CLI<br/>[__main__.py]"]
  node_requests["Prompt records"]
  node_schemas["Function schemas"]
  node_generator["CallMeMaybe<br/>[callmemaybe.py]"]
  node_results["Call JSON results"]
end

subgraph group_decode["Decoding engine"]
  node_model["Qwen model wrapper<br/>[__init__.py]"]
  node_encoder["BPE encoder<br/>[encoder.py]"]
  node_inference["Constrained inference<br/>[llm.py]"]
  node_function["Tool schema model<br/>[function.py]"]
end

subgraph group_exercise["Exercise authoring"]
  node_moulinette["Exercise CLI<br/>[__main__.py]"]
  node_definitions["Exercise functions"]
  node_metadata["Schema extraction"]
  node_testgen["Test and correction generation"]
end

subgraph group_grade["Grading"]
  node_grading["Submission grading<br/>[__main__.py]"]
  node_formatter["Terminal formatting"]
end

node_user(("Prompt requester"))

node_user -->|"submits prompts"| node_cli
node_requests -->|"loads prompts"| node_cli
node_schemas -->|"loads schemas"| node_generator
node_cli -->|"creates model"| node_model
node_cli -->|"builds tokenizer"| node_encoder
node_cli -->|"creates inference"| node_inference
node_cli -->|"processes prompts"| node_generator
node_cli -->|"writes results"| node_results
node_generator -->|"encodes schemas"| node_encoder
node_generator -->|"builds tools"| node_function
node_generator -->|"selects tokens"| node_inference
node_inference -->|"uses tokenizer"| node_encoder
node_inference -->|"requests logits"| node_model
node_moulinette -->|"extracts schemas"| node_metadata
node_moulinette -->|"generates exercises"| node_testgen
node_moulinette -->|"selects exercises"| node_definitions
node_testgen -->|"uses exercise data"| node_definitions
node_metadata -->|"reads functions"| node_definitions
node_moulinette -->|"grades submissions"| node_grading
node_grading -->|"calls expected functions"| node_definitions
node_grading -->|"prints feedback"| node_formatter

click node_cli "https://github.com/alexhysel/42-call-me-maybe/blob/main/src/__main__.py"
click node_requests "https://github.com/alexhysel/42-call-me-maybe/blob/main/data/input/function_calling_tests.json"
click node_schemas "https://github.com/alexhysel/42-call-me-maybe/blob/main/data/input/functions_definition.json"
click node_generator "https://github.com/alexhysel/42-call-me-maybe/blob/main/src/callmemaybe.py"
click node_model "https://github.com/alexhysel/42-call-me-maybe/blob/main/llm_sdk/__init__.py"
click node_encoder "https://github.com/alexhysel/42-call-me-maybe/blob/main/src/encoder.py"
click node_inference "https://github.com/alexhysel/42-call-me-maybe/blob/main/src/llm.py"
click node_function "https://github.com/alexhysel/42-call-me-maybe/blob/main/src/function.py"
click node_moulinette "https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/__main__.py"
click node_definitions "https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/functions_definition.py"
click node_metadata "https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/extract_functions_infos.py"
click node_testgen "https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/generate_tests_and_corrections.py"
click node_grading "https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/__main__.py"
click node_formatter "https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/output_formatter.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_requests,node_schemas,node_generator,node_results toneBlue
class node_model,node_encoder,node_inference,node_function toneAmber
class node_moulinette,node_definitions,node_metadata,node_testgen,node_user toneMint
class node_grading,node_formatter toneRose
```

## Components

### Call generation

- [Generation CLI](https://github.com/alexhysel/42-call-me-maybe/blob/main/src/__main__.py): `src/__main__.py`
- [Prompt records](https://github.com/alexhysel/42-call-me-maybe/blob/main/data/input/function_calling_tests.json): `data/input/function_calling_tests.json`
- [Function schemas](https://github.com/alexhysel/42-call-me-maybe/blob/main/data/input/functions_definition.json): `data/input/functions_definition.json`
- [CallMeMaybe](https://github.com/alexhysel/42-call-me-maybe/blob/main/src/callmemaybe.py): `src/callmemaybe.py`
- **Call JSON results**

### Decoding engine

- [Qwen model wrapper](https://github.com/alexhysel/42-call-me-maybe/blob/main/llm_sdk/__init__.py): `llm_sdk/__init__.py`
- [BPE encoder](https://github.com/alexhysel/42-call-me-maybe/blob/main/src/encoder.py): `src/encoder.py`
- [Constrained inference](https://github.com/alexhysel/42-call-me-maybe/blob/main/src/llm.py): `src/llm.py`
- [Tool schema model](https://github.com/alexhysel/42-call-me-maybe/blob/main/src/function.py): `src/function.py`

### Exercise authoring

- [Exercise CLI](https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/__main__.py): `moulinette/moulinette/__main__.py`
- [Exercise functions](https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/functions_definition.py): `moulinette/moulinette/functions_definition.py`
- [Schema extraction](https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/extract_functions_infos.py): `moulinette/moulinette/extract_functions_infos.py`
- [Test and correction generation](https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/generate_tests_and_corrections.py): `moulinette/moulinette/generate_tests_and_corrections.py`

### Grading

- [Submission grading](https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/__main__.py): `moulinette/moulinette/__main__.py`
- [Terminal formatting](https://github.com/alexhysel/42-call-me-maybe/blob/main/moulinette/moulinette/output_formatter.py): `moulinette/moulinette/output_formatter.py`

### Other components

- **Prompt requester**

## Connections

- Prompt requester → Generation CLI: submits prompts (evidence: `README.md`)
- Prompt records → Generation CLI: loads prompts (evidence: `src/__main__.py`)
- Function schemas → CallMeMaybe: loads schemas (evidence: `src/callmemaybe.py`)
- Generation CLI → Qwen model wrapper: creates model (evidence: `src/__main__.py`)
- Generation CLI → BPE encoder: builds tokenizer (evidence: `src/__main__.py`)
- Generation CLI → Constrained inference: creates inference (evidence: `src/__main__.py`)
- Generation CLI → CallMeMaybe: processes prompts (evidence: `src/__main__.py`)
- Generation CLI → Call JSON results: writes results (evidence: `src/__main__.py`)
- CallMeMaybe → BPE encoder: encodes schemas (evidence: `src/callmemaybe.py`)
- CallMeMaybe → Tool schema model: builds tools (evidence: `src/callmemaybe.py`)
- CallMeMaybe → Constrained inference: selects tokens (evidence: `src/callmemaybe.py`)
- Constrained inference → BPE encoder: uses tokenizer (evidence: `src/llm.py`)
- Constrained inference → Qwen model wrapper: requests logits (evidence: `src/llm.py`)
- Exercise CLI → Schema extraction: extracts schemas (evidence: `moulinette/moulinette/__main__.py`)
- Exercise CLI → Test and correction generation: generates exercises (evidence: `moulinette/moulinette/__main__.py`)
- Exercise CLI → Exercise functions: selects exercises (evidence: `moulinette/moulinette/__main__.py`)
- Test and correction generation → Exercise functions: uses exercise data (evidence: `moulinette/moulinette/generate_tests_and_corrections.py`)
- Schema extraction → Exercise functions: reads functions (evidence: `moulinette/moulinette/extract_functions_infos.py`)
- Exercise CLI → Submission grading: grades submissions (evidence: `moulinette/moulinette/__main__.py`)
- Submission grading → Exercise functions: calls expected functions (evidence: `moulinette/moulinette/__main__.py`)
- Submission grading → Terminal formatting: prints feedback (evidence: `moulinette/moulinette/__main__.py`)
