mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 16:46:08 +02:00
175 lines
9.6 KiB
HTML
175 lines
9.6 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Architecture | EchoHub Documentation </title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="title" content="Architecture | EchoHub Documentation ">
|
|
|
|
|
|
<link rel="icon" href="../images/hue_icon.svg">
|
|
<link rel="stylesheet" href="../public/docfx.min.css">
|
|
<link rel="stylesheet" href="../public/main.css">
|
|
<meta name="docfx:navrel" content="../toc.html">
|
|
<meta name="docfx:tocrel" content="toc.html">
|
|
|
|
<meta name="docfx:rel" content="../">
|
|
|
|
|
|
<meta name="docfx:docurl" content="https://github.com/HueByte/EchoHub/blob/master/docs/#L1">
|
|
<meta name="loc:inThisArticle" content="In this article">
|
|
<meta name="loc:searchResultsCount" content="{count} results for "{query}"">
|
|
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
|
<meta name="loc:tocFilter" content="Filter by title">
|
|
<meta name="loc:nextArticle" content="Next">
|
|
<meta name="loc:prevArticle" content="Previous">
|
|
<meta name="loc:themeLight" content="Light">
|
|
<meta name="loc:themeDark" content="Dark">
|
|
<meta name="loc:themeAuto" content="Auto">
|
|
<meta name="loc:changeTheme" content="Change theme">
|
|
<meta name="loc:copy" content="Copy">
|
|
<meta name="loc:downloadPdf" content="Download PDF">
|
|
|
|
<script type="module" src="./../public/docfx.min.js"></script>
|
|
|
|
<script>
|
|
const theme = localStorage.getItem('theme') || 'auto'
|
|
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
|
|
<header class="bg-body border-bottom">
|
|
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
|
|
<div class="container-xxl flex-nowrap">
|
|
<a class="navbar-brand" href="../index.html">
|
|
<img id="logo" class="svg" src="../images/hue_icon.svg" alt="EchoHub">
|
|
EchoHub
|
|
</a>
|
|
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
|
|
<i class="bi bi-three-dots"></i>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navpanel">
|
|
<div id="navbar">
|
|
<form class="search" role="search" id="search">
|
|
<i class="bi bi-search"></i>
|
|
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
</header>
|
|
|
|
<main class="container-xxl">
|
|
<div class="toc-offcanvas">
|
|
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
|
|
<div class="offcanvas-header">
|
|
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
|
|
</div>
|
|
<div class="offcanvas-body">
|
|
<nav class="toc" id="toc"></nav>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="content">
|
|
<div class="actionbar">
|
|
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
|
|
<i class="bi bi-list"></i>
|
|
</button>
|
|
|
|
<nav id="breadcrumb"></nav>
|
|
</div>
|
|
|
|
<article data-uid="">
|
|
<h1 id="architecture">Architecture</h1>
|
|
|
|
<h2 id="overview">Overview</h2>
|
|
<p>EchoHub follows a decentralized model where each server is fully independent. There is no central authority or account federation. Users create one account per server.</p>
|
|
<p>The server exposes two protocol interfaces to the same chat backend:</p>
|
|
<pre><code class="lang-text">IRC Client ──► TCP :6667 ──► IrcGateway ──┐
|
|
├──► ChatService ──► DB + PresenceTracker
|
|
TUI Client ──► WebSocket ──► ChatHub ─────┘
|
|
</code></pre>
|
|
<p>Both protocols call into a shared <code>IChatService</code> for business logic. Events fan out to all registered <code>IChatBroadcaster</code> implementations (SignalR and IRC).</p>
|
|
<h2 id="components">Components</h2>
|
|
<h3 id="echohubcore">EchoHub.Core</h3>
|
|
<p>Shared library containing:</p>
|
|
<ul>
|
|
<li><strong>Models</strong>: <code>User</code>, <code>Channel</code>, <code>Message</code>, <code>RefreshToken</code></li>
|
|
<li><strong>DTOs</strong>: Record types for API requests/responses</li>
|
|
<li><strong>Contracts</strong>: <code>IChatService</code> (protocol-agnostic chat operations), <code>IChatBroadcaster</code> (event fan-out interface), <code>IEchoHubClient</code> (SignalR client interface)</li>
|
|
<li><strong>Constants</strong>: <code>ValidationConstants</code> (shared regex patterns), <code>HubConstants</code></li>
|
|
</ul>
|
|
<h3 id="echohubserver">EchoHub.Server</h3>
|
|
<p>ASP.NET Core web application:</p>
|
|
<ul>
|
|
<li><strong>Controllers</strong>: REST API endpoints for auth, channels, users, files, server info</li>
|
|
<li><strong>Hubs</strong>: SignalR <code>ChatHub</code> -- thin adapter delegating to <code>IChatService</code></li>
|
|
<li><strong>Auth</strong>: JWT token service (15-min access tokens, 30-day refresh tokens)</li>
|
|
<li><strong>Data</strong>: EF Core with SQLite</li>
|
|
<li><strong>Services</strong>: <code>ChatService</code> (core business logic), <code>SignalRBroadcaster</code>, presence tracking, file storage, image-to-ASCII conversion</li>
|
|
</ul>
|
|
<h3 id="echohubserverirc">EchoHub.Server.Irc</h3>
|
|
<p>IRC protocol gateway (separate project for clean separation of concerns):</p>
|
|
<ul>
|
|
<li><strong>IrcGatewayService</strong>: <code>BackgroundService</code> with TCP listener on configured port(s), optional TLS</li>
|
|
<li><strong>IrcCommandHandler</strong>: Per-client IRC command dispatch -- handles <code>CAP</code>/<code>SASL</code>, <code>NICK</code>/<code>USER</code>/<code>PASS</code>, <code>JOIN</code>/<code>PART</code>/<code>PRIVMSG</code>/<code>QUIT</code>, <code>NAMES</code>/<code>TOPIC</code>/<code>WHO</code>/<code>WHOIS</code>/<code>AWAY</code>/<code>LIST</code>/<code>MODE</code>/<code>MOTD</code></li>
|
|
<li><strong>IrcBroadcaster</strong>: <code>IChatBroadcaster</code> implementation that formats chat events as IRC protocol lines, with echo suppression (IRC convention)</li>
|
|
<li><strong>IrcMessageFormatter</strong>: Converts <code>MessageDto</code> to IRC <code>PRIVMSG</code> lines -- splits long text at word boundaries (~400 byte chunks), sends images as ASCII art line-by-line</li>
|
|
</ul>
|
|
<p>IRC users authenticate with existing EchoHub accounts via <code>PASS</code>/<code>NICK</code>/<code>USER</code> or SASL PLAIN (BCrypt verification against the database).</p>
|
|
<h3 id="echohubclient">EchoHub.Client</h3>
|
|
<p>Terminal.Gui v2 TUI application:</p>
|
|
<ul>
|
|
<li><strong>UI</strong>: Main window, dialogs, chat renderer with ANSI color support</li>
|
|
<li><strong>Services</strong>: API client with automatic token refresh, SignalR connection wrapper</li>
|
|
<li><strong>Themes</strong>: 13 built-in color themes</li>
|
|
<li><strong>Config</strong>: Client configuration management</li>
|
|
</ul>
|
|
<h2 id="communication">Communication</h2>
|
|
<ul>
|
|
<li><strong>REST API</strong> for authentication, profile management, channel CRUD, file uploads</li>
|
|
<li><strong>SignalR WebSocket</strong> for real-time messaging and presence updates (TUI client)</li>
|
|
<li><strong>IRC TCP</strong> for real-time messaging via standard IRC protocol (IRC clients)</li>
|
|
<li>JWT tokens passed via query string for SignalR authentication</li>
|
|
<li>IRC authentication via PASS/SASL PLAIN against BCrypt password hashes</li>
|
|
</ul>
|
|
<h2 id="broadcaster-pattern">Broadcaster Pattern</h2>
|
|
<p>The <code>IChatBroadcaster</code> interface allows multiple protocols to receive chat events:</p>
|
|
<ul>
|
|
<li><strong>SignalRBroadcaster</strong>: Wraps <code>IHubContext<ChatHub></code>, filters out IRC connections</li>
|
|
<li><strong>IrcBroadcaster</strong>: Iterates live IRC connections in a channel, formats events as IRC protocol lines</li>
|
|
</ul>
|
|
<p>Both are registered in DI and called by <code>ChatService</code> when events occur. This means a message sent from an IRC client appears in the TUI client, and vice versa.</p>
|
|
|
|
</article>
|
|
|
|
<div class="contribution d-print-none">
|
|
<a href="https://github.com/HueByte/EchoHub/blob/master/docs/#L1" class="edit-link">Edit this page</a>
|
|
</div>
|
|
|
|
<div class="next-article d-print-none border-top" id="nextArticle"></div>
|
|
|
|
</div>
|
|
|
|
<div class="affix">
|
|
<nav id="affix"></nav>
|
|
</div>
|
|
</main>
|
|
|
|
<div class="container-xxl search-results" id="search-results"></div>
|
|
|
|
<footer class="border-top text-secondary">
|
|
<div class="container-xxl">
|
|
<div class="flex-fill">
|
|
<div class='footer-custom'><div class='footer-inner'><span class='footer-brand'>EchoHub</span><span class='footer-sep'>·</span><a href='https://github.com/HueByte/EchoHub'>GitHub</a><span class='footer-sep'>·</span><a href='https://echohub.voidcube.cloud'>Website</a><span class='footer-sep'>·</span><span class='footer-credit'>Built with <a href='https://dotnet.github.io/docfx'>DocFX</a></span></div></div>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html>
|