# kushal6245/addressbook-c architecture

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

- Interactive diagram: https://gitdiagram.com/kushal6245/addressbook-c
- Repository: https://github.com/kushal6245/addressbook-c

## Overview

This is a terminal address book in which a user chooses menu actions to create, find, update, remove, or display contacts. The program loads contacts at startup, keeps them in an in-memory address book, and writes changes from add, edit, and delete operations to CSV; the menu’s save-and-exit branch does not itself call the save routine. Search supports name, phone, and email matching and supplies selected contact indices to edit and delete. The README documents validation and CSV persistence; the graph reflects the sampled implementation.

Main entry points: [`main.c`](https://github.com/kushal6245/addressbook-c/blob/main/main.c) (Menu Controller), [`searchcontact.c`](https://github.com/kushal6245/addressbook-c/blob/main/searchcontact.c) (Search Contacts), [`editcontact.c`](https://github.com/kushal6245/addressbook-c/blob/main/editcontact.c) (Edit Contact), [`deletecontact.c`](https://github.com/kushal6245/addressbook-c/blob/main/deletecontact.c) (Delete Contact)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Menu and Model"]
  node_main["Menu Controller<br/>[main.c]"]
  node_model["Address Book State<br/>[addressbook.h]"]
end

subgraph group_operations["Contact Operations"]
  node_add["Add Contact<br/>[addcontact.c]"]
  node_search["Search Contacts<br/>[searchcontact.c]"]
  node_results["Search Results<br/>[searchcontact.c]"]
  node_edit["Edit Contact<br/>[editcontact.c]"]
  node_delete["Delete Contact<br/>[deletecontact.c]"]
  node_list["List Contacts<br/>[listcontact.c]"]
end

subgraph group_persistence["CSV Persistence"]
  node_loader["Load Contacts<br/>[todatabase.c]"]
  node_saver["Save Contacts<br/>[todatabase.c]"]
  node_csv[("Contact CSV<br/>[database.csv]")]
end

node_user(("Terminal User"))

node_user -->|"selects actions"| node_main
node_main -->|"loads at startup"| node_loader
node_main -->|"refreshes"| node_loader
node_main -->|"dispatches"| node_add
node_main -->|"dispatches"| node_search
node_main -->|"dispatches"| node_edit
node_main -->|"dispatches"| node_delete
node_main -->|"dispatches"| node_list
node_edit -->|"selects contact"| node_search
node_search -->|"returns index"| node_edit
node_delete -->|"selects contact"| node_search
node_search -->|"returns index"| node_delete
node_search -->|"displays matches"| node_results
node_add -->|"persists contact"| node_saver
node_edit -->|"persists changes"| node_saver
node_delete -->|"persists removal"| node_saver
node_loader -->|"reads"| node_csv
node_saver -->|"writes"| node_csv

click node_main "https://github.com/kushal6245/addressbook-c/blob/main/main.c"
click node_model "https://github.com/kushal6245/addressbook-c/blob/main/addressbook.h"
click node_add "https://github.com/kushal6245/addressbook-c/blob/main/addcontact.c"
click node_search "https://github.com/kushal6245/addressbook-c/blob/main/searchcontact.c"
click node_results "https://github.com/kushal6245/addressbook-c/blob/main/searchcontact.c"
click node_edit "https://github.com/kushal6245/addressbook-c/blob/main/editcontact.c"
click node_delete "https://github.com/kushal6245/addressbook-c/blob/main/deletecontact.c"
click node_list "https://github.com/kushal6245/addressbook-c/blob/main/listcontact.c"
click node_loader "https://github.com/kushal6245/addressbook-c/blob/main/todatabase.c"
click node_saver "https://github.com/kushal6245/addressbook-c/blob/main/todatabase.c"
click node_csv "https://github.com/kushal6245/addressbook-c/blob/main/database.csv"

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_main,node_model,node_user toneBlue
class node_add,node_search,node_results,node_edit,node_delete,node_list toneAmber
class node_loader,node_saver,node_csv toneMint
```

## Components

### Menu and Model

- [Menu Controller](https://github.com/kushal6245/addressbook-c/blob/main/main.c): `main.c`
- [Address Book State](https://github.com/kushal6245/addressbook-c/blob/main/addressbook.h): `addressbook.h`

### Contact Operations

- [Add Contact](https://github.com/kushal6245/addressbook-c/blob/main/addcontact.c): `addcontact.c`
- [Search Contacts](https://github.com/kushal6245/addressbook-c/blob/main/searchcontact.c): `searchcontact.c`
- [Search Results](https://github.com/kushal6245/addressbook-c/blob/main/searchcontact.c): `searchcontact.c`
- [Edit Contact](https://github.com/kushal6245/addressbook-c/blob/main/editcontact.c): `editcontact.c`
- [Delete Contact](https://github.com/kushal6245/addressbook-c/blob/main/deletecontact.c): `deletecontact.c`
- [List Contacts](https://github.com/kushal6245/addressbook-c/blob/main/listcontact.c): `listcontact.c`

### CSV Persistence

- [Load Contacts](https://github.com/kushal6245/addressbook-c/blob/main/todatabase.c): `todatabase.c`
- [Save Contacts](https://github.com/kushal6245/addressbook-c/blob/main/todatabase.c): `todatabase.c`
- [Contact CSV](https://github.com/kushal6245/addressbook-c/blob/main/database.csv): `database.csv`

### Other components

- **Terminal User**

## Connections

- Terminal User → Menu Controller: selects actions
- Menu Controller → Load Contacts: loads at startup
- Menu Controller → Load Contacts: refreshes
- Menu Controller → Add Contact: dispatches
- Menu Controller → Search Contacts: dispatches
- Menu Controller → Edit Contact: dispatches
- Menu Controller → Delete Contact: dispatches
- Menu Controller → List Contacts: dispatches
- Edit Contact → Search Contacts: selects contact
- Search Contacts → Edit Contact: returns index
- Delete Contact → Search Contacts: selects contact
- Search Contacts → Delete Contact: returns index
- Search Contacts → Search Results: displays matches
- Add Contact → Save Contacts: persists contact
- Edit Contact → Save Contacts: persists changes
- Delete Contact → Save Contacts: persists removal
- Load Contacts → Contact CSV: reads
- Save Contacts → Contact CSV: writes
