How lemalcs/khernet works
Main Components
• Database Layer:
– There are two main database folders (CONFIG and KH) that contain scripts for creating the database, generators, stored procedures, tables, and triggers. This clearly represents the persistence and configuration aspects of the application.
• Core Engine (Khernet.Core):
– Sub–modules here include:
▪ Common: Contains configuration files, constants, and basic utilities.
▪ Container: Likely implements an IoC (dependency injection) container to manage dependencies.
▪ Data: Manages database interaction using data models and possibly the account/communication data.
▪ Entity: Represents core business entities such as messages, peers, and processing results.
▪ Host: Manages the application’s hosting environment and services like authentication and peer watching.
▪ Processor: Implements the main business logic for handling messaging, file transfers, notifications, and uses various manager classes.
▪ Utility: Provides helper functions for encryption, compression, file handling, logging, etc.
• Services Layer:
– Found in Khernet.Core/Services; it’s broken down into several projects:
▪ A client component which manages outbound communications (e.g., CertificateValidator, CommunicatorClient, GatewayClient).
▪ Common, Contracts, Messages, and a WCF–based service layer indicate how remote calls and inter–peer messaging are handled (likely using WCF and custom service inspectors).
• User Interface (Khernet.UI):
– Contains both container and presentation projects.
– The presentation layer includes a host of XAML pages, dialog controls, converters, view models, and other components to deliver a rich WPF user interface.
– There’s evidence of MVVM structure (ViewModels, Views, and IoC for dependency management), which segregates UI concerns from business logic.
• Installer:
– The Khernet.Installer folder with NSIS or Inno Setup configurations indicates the mechanism to deploy and install the application in “installed mode.”
• Resources/Dependencies:
– Bundled packages like nuget executables, Firebird database client, and other libraries are provided in the Resources folder and represent third–party or packaging dependencies.
Relationships and Interactions
• The UI Layer interacts with the Core Engine via ViewModels and IoC interfaces (see the IoC folders) – using patterns such as dependency injection and observer patterns.
• The Core Engine (especially the Processor and Host modules) works closely with the Services Layer to handle communication between peers, manage encryption, and process messages.
• The Core Engine also communicates with the Database Layer by executing SQL scripts stored in the CONFIG and KH folders, managing data persistence (like saving messages, peer identities, notifications, etc.).
• The Services Layer (for example, WCF services) facilitates communication for file transfers, notifications, and other multi–peer interactions, acting as the glue between the UI and underlying messaging infrastructure.
• The Installer component packages and deploys the overall system for end users and distinguishes between portable and installed modes.
Architectural Patterns and Design Principles
• Layered Architecture: Clearly differentiate between the Data/Database layer, Business Logic/Core Engine, Service Communication, and the UI.
• Modular/Component–Based Design: Each sub–module (Common, Container, Data, Host, Processor, Utility) encapsulates specific responsibilities.
• IoC/Dependency Injection: Evident from the “Container” and IoC folders that help decouple components for easier testing and enhanced scalability.
• MVVM Pattern: The UI project follows MVVM, separating UI presentation (XAML) from business logic (ViewModels).
• Peer–to–Peer Communication: Built to operate without a centralized server by using decentralized service components.