# opendental/opendental architecture

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

- Interactive diagram: https://gitdiagram.com/opendental/opendental
- Repository: https://github.com/opendental/opendental

## Overview

##### Project Type and Purpose
- Open Dental is a full-stack, on-premises dental practice management application written in .NET/C# (WinForms or WPF) with a relational database back-end (typically MySQL or Microsoft SQL Server).
- It ships as a desktop client with an installer that creates and seeds the initial database, then runs the application against that local or networked database.

##### File Structure
- `OpenDentalUI` (Windows forms or WPF views)
- `OpenDentalCore` (business logic, domain objects)
- `DataAccess` or `DAL` (repository classes, SQL scripts)
- `Reporting` (Crystal Reports or similar)
- `Services` (background services, schedulers)
- `Utilities` or `Helpers`
- `Installer` files (WiX, MSI project)
- `Config` (app.config, connection strings, scripts)
- Build scripts or solution files (`.sln`, `.csproj`) and test projects will also appear.

##### README for Additional Insights
- It emphasizes installing the Trial Version first to provision the database schema.
- It references a central SVN repository for historical source and a programming resources page for DB documentation.

##### Main Components and Their Relationships
a. Client Application (UI)
- Windows Forms or WPF layers
- Entry points, menus, data grids, dialogs
b. Business Logic Layer (BLL)
- Domain services (e.g., patient management, appointment scheduling)
- Validation logic, business rules
c. Data Access Layer (DAL)
- Repository or TableGateway patterns
- SQL scripts and stored‐procedure calls
- Connection management
d. Database
- RDBMS (MySQL or SQL Server)
- Tables: Patients, Appointments, Claims, etc.
- Initial schema installed by the MSI installer
e. Reporting Engine
- Crystal Reports or built-in reporting module
- Report definition files (.rpt)
f. External/Infrastructure
- File system (for attachments, images)
- Network share (optional)
- Installer service (MSI/WiX)
- Version control (SVN server)

##### Architectural Patterns & Design Principles
- Layered Architecture (UI → BLL → DAL → Database)
- Repository pattern in DAL for DB interactions
- Dependency Injection for swappable components (configurable via app.config)
- MVVM or MVP if WPF is used
- Separation of concerns: keep UI, business rules, and data access decoupled

##### Versioning & Deployment Aspects
- Build process: source code → build server → MSI installer → Client + DB.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer and Deployment
    subgraph "Developer Environment"
        SVN["SVN/Git Server"]:::external
        BuildServer["Build Server"]:::service
        SVN -->|"checkout"| BuildServer
        BuildServer -->|"builds .sln/.csproj"| Installer
    end

    Installer["MSI Installer (WiX)"]:::service
    Installer -->|"provisions schema"| Database
    Installer -->|"deploys client"| DesktopClient

    %% Desktop Client Layer
    subgraph "Desktop Client"
        direction TB
        subgraph "UI Layer" 
            UI["WinForms/WPF Views"]:::ui
        end
        subgraph "Business Logic Layer"
            BLL["OpenDentalCore (Domain Services)"]:::bll
        end
        UI -->|"calls BLL methods"| BLL
        BLL -->|"invokes repositories"| DAL
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        DAL["DataAccess/DAL (Repositories)"]:::dal
        DAL -->|"ADO.NET/SQL calls"| Database
    end

    %% Database
    Database["Relational Database\n(MySQL or SQL Server)"]:::db

    %% Supporting Components
    FileSystem["File System (attachments)"]:::external
    EmailServer["Email Server\n(reminders)"]:::external
    Config["Config Files\n(app.config, scripts)"]:::config
    Reporting["Reporting Engine\n(Crystal Reports)"]:::reporting
    Services["Background Services\n(schedulers)"]:::service

    DAL -->|reads/writes| FileSystem
    BLL -->|schedules jobs| Services
    BLL -->|generates reports| Reporting
    BLL -->|reads config| Config

    %% Legend
    subgraph "Legend"
        direction LR
        RectUI["UI Layer"]:::ui
        RectBLL["Business Logic"]:::bll
        RectDAL["Data Access"]:::dal
        CylDB["Database"]:::db
        HexService["Service"]:::service
        ParExternal["External"]:::external
        DocConfig["Config/Script"]:::config
        DocReport["Reporting"]:::reporting
    end

    %% Classes
    classDef ui fill:#B3D1FF,stroke:#0366D6,color:#0366D6;
    classDef bll fill:#D1F3B3,stroke:#228C22,color:#228C22;
    classDef dal fill:#FFD8B3,stroke:#D2691E,color:#D2691E;
    classDef db fill:#E0E0E0,stroke:#666666,color:#333333;
    classDef service fill:#F2E0FF,stroke:#800080,color:#660066;
    classDef external fill:#FFEFE0,stroke:#FF8C00,color:#FF4500;
    classDef config fill:#FFF5B3,stroke:#B8860B,color:#8B4500;
    classDef reporting fill:#E0FFFF,stroke:#20B2AA,color:#008B8B;
```
