# us2ahmad/firstappwith-threetierarchitecture architecture

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

- Interactive diagram: https://gitdiagram.com/us2ahmad/firstappwith-threetierarchitecture
- Repository: https://github.com/us2ahmad/firstappwith-threetierarchitecture

## Overview

This is a C# contacts-and-countries CRUD application demonstrating a three-tier architecture, with both a Windows Forms interface and a console entry point. In the Windows Forms workflow, the add/edit form loads country choices and contact data, edits contact fields, and saves through the business layer to SQL persistence. The business classes also expose find, list, delete, and existence operations; the console program exercises these APIs. The README documents the layer separation, but the main form’s event wiring was not shown, so its interactions are not inferred here.

Main entry points: [`DataAccessLayer/clsContactDataAccess.cs`](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/DataAccessLayer/clsContactDataAccess.cs) (Contact Persistence), [`DataAccessLayer/clsCountryDataAccess.cs`](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/DataAccessLayer/clsCountryDataAccess.cs) (Country Persistence), [`BusinessLayer/clsContact.cs`](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/BusinessLayer/clsContact.cs) (Contact Logic), [`BusinessLayer/clsCountry.cs`](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/BusinessLayer/clsCountry.cs) (Country Logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_forms["Main Form<br/>[frmMain.cs]"]
  node_edit_form["Contact Editor<br/>[frmAddEdit.cs]"]
  node_forms_start["Forms Startup<br/>[Program.cs]"]
  node_console["Console Demo<br/>[Program.cs]"]
end

subgraph group_business["Business Logic"]
  node_contact_logic["Contact Logic<br/>[clsContact.cs]"]
  node_country_logic["Country Logic<br/>[clsCountry.cs]"]
end

subgraph group_data["Data Access"]
  node_contact_dal["Contact Persistence"]
  node_country_dal["Country Persistence"]
  node_db_helpers["Reader Converters<br/>[Types.cs]"]
end

node_user(("User"))
node_sql[("SQL Database")]

node_forms_start -->|"launches"| node_forms
node_edit_form -->|"loads and saves"| node_contact_logic
node_edit_form -->|"loads and finds"| node_country_logic
node_console -->|"calls"| node_contact_logic
node_console -->|"calls"| node_country_logic
node_contact_logic -->|"delegates CRUD"| node_contact_dal
node_country_logic -->|"delegates CRUD"| node_country_dal
node_contact_dal -->|"converts reader values"| node_db_helpers
node_country_dal -->|"converts reader values"| node_db_helpers
node_contact_dal -->|"queries"| node_sql
node_country_dal -->|"queries"| node_sql
node_user -.->|"uses"| node_forms

click node_forms "https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/WindowsFormApp-PresentationLayer/frmMain.cs"
click node_edit_form "https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/WindowsFormApp-PresentationLayer/frmAddEdit.cs"
click node_forms_start "https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/WindowsFormApp-PresentationLayer/Program.cs"
click node_console "https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/Program.cs"
click node_contact_logic "https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/BusinessLayer/clsContact.cs"
click node_country_logic "https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/BusinessLayer/clsCountry.cs"
click node_contact_dal "https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/DataAccessLayer/clsContactDataAccess.cs"
click node_country_dal "https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/DataAccessLayer/clsCountryDataAccess.cs"
click node_db_helpers "https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/DataAccessLayer/Types.cs"

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_forms,node_edit_form,node_forms_start,node_console,node_user toneBlue
class node_contact_logic,node_country_logic,node_sql toneAmber
class node_contact_dal,node_country_dal,node_db_helpers toneMint
```

## Components

### Presentation

- [Main Form](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/WindowsFormApp-PresentationLayer/frmMain.cs): `WindowsFormApp-PresentationLayer/frmMain.cs`
- [Contact Editor](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/WindowsFormApp-PresentationLayer/frmAddEdit.cs): `WindowsFormApp-PresentationLayer/frmAddEdit.cs`
- [Forms Startup](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/WindowsFormApp-PresentationLayer/Program.cs): `WindowsFormApp-PresentationLayer/Program.cs`
- [Console Demo](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/Program.cs): `Program.cs`

### Business Logic

- [Contact Logic](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/BusinessLayer/clsContact.cs): `BusinessLayer/clsContact.cs`
- [Country Logic](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/BusinessLayer/clsCountry.cs): `BusinessLayer/clsCountry.cs`

### Data Access

- [Contact Persistence](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/DataAccessLayer/clsContactDataAccess.cs): `DataAccessLayer/clsContactDataAccess.cs`
- [Country Persistence](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/DataAccessLayer/clsCountryDataAccess.cs): `DataAccessLayer/clsCountryDataAccess.cs`
- [Reader Converters](https://github.com/us2ahmad/firstappwith-threetierarchitecture/blob/master/DataAccessLayer/Types.cs): `DataAccessLayer/Types.cs`

### Other components

- **User**
- **SQL Database**

## Connections

- Forms Startup → Main Form: launches (evidence: `WindowsFormApp-PresentationLayer/Program.cs`)
- Contact Editor → Contact Logic: loads and saves (evidence: `WindowsFormApp-PresentationLayer/frmAddEdit.cs`)
- Contact Editor → Country Logic: loads and finds (evidence: `WindowsFormApp-PresentationLayer/frmAddEdit.cs`)
- Console Demo → Contact Logic: calls (evidence: `Program.cs`)
- Console Demo → Country Logic: calls (evidence: `Program.cs`)
- Contact Logic → Contact Persistence: delegates CRUD (evidence: `BusinessLayer/clsContact.cs`)
- Country Logic → Country Persistence: delegates CRUD (evidence: `BusinessLayer/clsCountry.cs`)
- Contact Persistence → Reader Converters: converts reader values (evidence: `DataAccessLayer/clsContactDataAccess.cs`)
- Country Persistence → Reader Converters: converts reader values (evidence: `DataAccessLayer/clsCountryDataAccess.cs`)
- Contact Persistence → SQL Database: queries (evidence: `DataAccessLayer/clsContactDataAccess.cs`)
- Country Persistence → SQL Database: queries (evidence: `DataAccessLayer/clsCountryDataAccess.cs`)
- User → Main Form: uses (evidence: `README.md`)
