# cs50/libcs50 architecture

> Architecture diagram of the GitHub repository cs50/libcs50, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cs50/libcs50
- Repository: https://github.com/cs50/libcs50

## Overview

CS50 Library for C provides prompted, line-oriented input and typed conversion helpers. A program calls the public API; string input reads and allocates a line, while numeric and character helpers validate that line and retry until valid or EOF. The excerpts show those helpers delegating to get_string and startup configuring stdout buffering. The implementation excerpt is partial, so the graph omits unshown internal details; README usage documents the public entry point.

Main entry points: [`src/cs50.h`](https://github.com/cs50/libcs50/blob/main/src/cs50.h) (Input declarations), [`src/cs50.c`](https://github.com/cs50/libcs50/blob/main/src/cs50.c) (Line reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_header["Input declarations<br/>[cs50.h]"]
end

subgraph group_input["Input and Conversion"]
  node_line["Line reader<br/>[cs50.c]"]
  node_typed["Typed readers<br/>[cs50.c]"]
end

subgraph group_runtime["Runtime Setup"]
  node_setup["I/O setup<br/>[cs50.c]"]
end

node_program(("C program"))

node_program -->|"calls API"| node_header
node_header -->|"implemented in"| node_line
node_typed -->|"reads lines"| node_line

click node_header "https://github.com/cs50/libcs50/blob/main/src/cs50.h"
click node_line "https://github.com/cs50/libcs50/blob/main/src/cs50.c"
click node_typed "https://github.com/cs50/libcs50/blob/main/src/cs50.c"
click node_setup "https://github.com/cs50/libcs50/blob/main/src/cs50.c"

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_header toneBlue
class node_line,node_typed toneAmber
class node_setup toneMint
class node_program toneIndigo
```

## Components

### Public API

- [Input declarations](https://github.com/cs50/libcs50/blob/main/src/cs50.h): `src/cs50.h`

### Input and Conversion

- [Line reader](https://github.com/cs50/libcs50/blob/main/src/cs50.c): `src/cs50.c`
- [Typed readers](https://github.com/cs50/libcs50/blob/main/src/cs50.c): `src/cs50.c`

### Runtime Setup

- [I/O setup](https://github.com/cs50/libcs50/blob/main/src/cs50.c): `src/cs50.c`

### Other components

- **C program**

## Connections

- C program → Input declarations: calls API (evidence: `README.md`)
- Input declarations → Line reader: implemented in (evidence: `src/cs50.c`)
- Typed readers → Line reader: reads lines (evidence: `src/cs50.c`)
