# alex-jitbit/freesshd architecture

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

- Interactive diagram: https://gitdiagram.com/alex-jitbit/freesshd
- Repository: https://github.com/alex-jitbit/freesshd

## Overview

##### Main Components
- Service Layer:
- FreeSSHdService: This is the main Windows Service component. Files like FreeSSHDService.idl, FreeSSHDService.rc, FreeSSHDService.rgs, and the manifest indicate COM integration and service configuration.
- Service Core & SSH Handler: Modules such as freeSSHdHandler.cpp/h and freeSSHdUser.cpp/h indicate handling SSH sessions and user authentications.
- UI / Configuration Layer:
- Main Dialog and Property Sheets: Files such as maindlg.cpp/h, MessageDlg.cpp/h, ResizablePropertySheet.h, pages.cpp/h, and userpages.cpp/h show that there is a GUI for configuration and status display.
- Core Utility Modules:
- Buffer and Data Management: Files like Buffer.h/cpp and buffer.cpp indicate management of data buffers.
- Cryptography and Matching: sha1.cpp/h for cryptographic routines and wildmat for pattern matching.
- Logging and Event Handling: log.cpp/h, events.cpp/h, wodAppUpdateEvents.cpp/h support logging and update events.
- Auxiliary/Support Utilities:
- GDI utilities (gdiu.cpp/h) which are likely used for custom UI drawing.
- Other supporting files such as images provide resources for the UI.

##### Relationships and Interactions
- The SSH Service (FreeSSHdService) works as the backend heart of the system:
- It communicates with the underlying Windows OS as a service.
- It listens to and processes incoming SSH connections.
- It delegates authentication and session handling to components in freeSSHdHandler and freeSSHdUser.
- The UI Layer:
- Offers an interface for configuration and possibly status monitoring.
- Interacts with the service layer via configuration settings and update events.
- Utility Modules:
- Provide shared functionality; for example, the buffer and sha1 modules will be called by both service and UI components.
- Resource and COM Components:
- The COM definitions and resource files indicate that inter-module communication (even for possible remote management or event propagation) follows COM conventions.

##### Architectural Patterns and Design Principles
- Modularization: The system is clearly segmented into UI, service core, and utilities, promoting separation of concerns.
- Event-driven Architecture: The presence of events and update events modules suggests that the service and UI communicate via event notifications.
- Windows-Specific and COM-based Integration: The service uses COM interfaces (as indicated by the .idl and .rgs files) to interact with other parts of the system or external tools.
- Use of Windows service infrastructure for background, persistent operations and a separate configuration GUI for user interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD

    subgraph "UI / Configuration Layer"
        UI_Main["Main Dialog & Message Dialog (UI)"]
        UI_Prop["Property Sheets & Pages (UI)"]
    end

    subgraph "Service Layer"
        SSH_Service["SSH Service (FreeSSHdService)"]
        SSH_Handler["SSH Session Handler"]
        Auth_Module["User Authentication Module"]
    end

    subgraph "Utility Modules"
        Buffer_Management["Buffer & Data Management"]
        SHA1["Cryptography (SHA1)"]
        Wildmat["Pattern Matching (wildmat)"]
        Logging["Logging & Event Handling"]
        GDI["GDI & UI Drawing Utilities"]
        UI_Resources["UI Resources (Images)"]
    end

    %% Relationships
    UI_Main -->|"configures"| SSH_Service
    UI_Prop -->|"configures"| SSH_Service

    SSH_Service -->|"handles_sessions"| SSH_Handler
    SSH_Service -->|"authenticates"| Auth_Module

    SSH_Service -->|"uses"| Buffer_Management
    SSH_Service -->|"uses"| SHA1
    SSH_Service -->|"uses"| Wildmat
    SSH_Service -->|"logs"| Logging

    UI_Main -->|"displays"| Logging
    UI_Prop -->|"renders"| GDI
    UI_Prop -->|"accesses"| UI_Resources

    %% Click Events
    click SSH_Service "https://github.com/alex-jitbit/freesshd/blob/master/FreeSSHDService.idl"
    click SSH_Handler "https://github.com/alex-jitbit/freesshd/blob/master/freeSSHdHandler.cpp"
    click Auth_Module "https://github.com/alex-jitbit/freesshd/blob/master/freeSSHdUser.cpp"
    click UI_Main "https://github.com/alex-jitbit/freesshd/blob/master/maindlg.cpp"
    click UI_Prop "https://github.com/alex-jitbit/freesshd/blob/master/ResizablePropertySheet.h"
    click Buffer_Management "https://github.com/alex-jitbit/freesshd/blob/master/Buffer.h"
    click SHA1 "https://github.com/alex-jitbit/freesshd/blob/master/sha1.cpp"
    click Wildmat "https://github.com/alex-jitbit/freesshd/blob/master/wildmat.cpp"
    click Logging "https://github.com/alex-jitbit/freesshd/blob/master/log.cpp"
    click GDI "https://github.com/alex-jitbit/freesshd/blob/master/gdiu.cpp"
    click UI_Resources "https://github.com/alex-jitbit/freesshd/tree/master/images"

    %% Styles
    classDef ui fill:#E8F9FD,stroke:#1A8FE3,stroke-width:2px,fill-opacity:0.8;
    classDef service fill:#FFF5BA,stroke:#E6AE2E,stroke-width:2px,fill-opacity:0.8;
    classDef utility fill:#D5F5E3,stroke:#27AE60,stroke-width:2px,fill-opacity:0.8;

    class UI_Main,UI_Prop ui;
    class SSH_Service,SSH_Handler,Auth_Module service;
    class Buffer_Management,SHA1,Wildmat,Logging,GDI,UI_Resources utility;
```
