# zhumagaa/studybuddy architecture

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

- Interactive diagram: https://gitdiagram.com/zhumagaa/studybuddy
- Repository: https://github.com/zhumagaa/studybuddy

## Overview

This is an ESP-IDF/FreeRTOS study timer that guides a user through task sessions, timed work, completion checks, and motivational feedback. The main workflow combines keypad time entry, a switch-controlled countdown, and a study manager that tracks task progress and hearts. Separate tasks drive the seven-segment display and buzzer, while the LCD presents session prompts and results. All implementation is in main/main.c; because the source excerpt is partial, the graph includes only relationships visible there.

Main entry points: [`main/main.c`](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c) (Task startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Session workflow"]
  node_startup["Task startup<br/>[main.c]"]
  node_study["Study manager<br/>[main.c]"]
  node_session_state["Session state<br/>[main.c]"]
end

subgraph group_timer["Timer and input"]
  node_keypad["Keypad input<br/>[main.c]"]
  node_timer_state["Timer state<br/>[main.c]"]
  node_countdown["Countdown task<br/>[main.c]"]
end

subgraph group_feedback["Device feedback"]
  node_seven_segment["Seven-segment display<br/>[main.c]"]
  node_lcd["LCD feedback<br/>[main.c]"]
  node_buzzer["Button buzzer<br/>[main.c]"]
end

node_user(("User"))
node_switch["Start switch"]
node_button["Button"]

node_user -->|"enters time"| node_keypad
node_user -->|"answers prompt"| node_study
node_startup -->|"starts task"| node_keypad
node_startup -->|"starts task"| node_countdown
node_startup -->|"starts task"| node_seven_segment
node_startup -->|"starts task"| node_buzzer
node_startup -->|"starts task"| node_study
node_keypad -->|"sets time"| node_timer_state
node_study -->|"checks time"| node_timer_state
node_study -->|"tracks progress"| node_session_state
node_switch -->|"enables timer"| node_countdown
node_countdown -->|"updates time"| node_timer_state
node_seven_segment -->|"reads time"| node_timer_state
node_study -->|"shows prompts"| node_lcd
node_button -->|"triggers sound"| node_buzzer

click node_startup "https://github.com/zhumagaa/studybuddy/blob/main/main/main.c"
click node_study "https://github.com/zhumagaa/studybuddy/blob/main/main/main.c"
click node_session_state "https://github.com/zhumagaa/studybuddy/blob/main/main/main.c"
click node_keypad "https://github.com/zhumagaa/studybuddy/blob/main/main/main.c"
click node_timer_state "https://github.com/zhumagaa/studybuddy/blob/main/main/main.c"
click node_countdown "https://github.com/zhumagaa/studybuddy/blob/main/main/main.c"
click node_seven_segment "https://github.com/zhumagaa/studybuddy/blob/main/main/main.c"
click node_lcd "https://github.com/zhumagaa/studybuddy/blob/main/main/main.c"
click node_buzzer "https://github.com/zhumagaa/studybuddy/blob/main/main/main.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_startup,node_study,node_session_state,node_user toneBlue
class node_keypad,node_timer_state,node_countdown toneAmber
class node_seven_segment,node_lcd,node_buzzer toneMint
class node_switch,node_button toneIndigo
```

## Components

### Session workflow

- [Task startup](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c): `main/main.c`
- [Study manager](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c): `main/main.c`
- [Session state](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c): `main/main.c`

### Timer and input

- [Keypad input](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c): `main/main.c`
- [Timer state](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c): `main/main.c`
- [Countdown task](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c): `main/main.c`

### Device feedback

- [Seven-segment display](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c): `main/main.c`
- [LCD feedback](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c): `main/main.c`
- [Button buzzer](https://github.com/zhumagaa/studybuddy/blob/main/main/main.c): `main/main.c`

### Other components

- **User**
- **Start switch**
- **Button**

## Connections

- User → Keypad input: enters time (evidence: `main/main.c`)
- User → Study manager: answers prompt (evidence: `main/main.c`)
- Task startup → Keypad input: starts task (evidence: `main/main.c`)
- Task startup → Countdown task: starts task (evidence: `main/main.c`)
- Task startup → Seven-segment display: starts task (evidence: `main/main.c`)
- Task startup → Button buzzer: starts task (evidence: `main/main.c`)
- Task startup → Study manager: starts task (evidence: `main/main.c`)
- Keypad input → Timer state: sets time (evidence: `main/main.c`)
- Study manager → Timer state: checks time (evidence: `main/main.c`)
- Study manager → Session state: tracks progress (evidence: `main/main.c`)
- Start switch → Countdown task: enables timer (evidence: `main/main.c`)
- Countdown task → Timer state: updates time (evidence: `main/main.c`)
- Seven-segment display → Timer state: reads time (evidence: `main/main.c`)
- Study manager → LCD feedback: shows prompts (evidence: `main/main.c`)
- Button → Button buzzer: triggers sound (evidence: `main/main.c`)
