# salem-5/studysync architecture

> Architecture diagram of the GitHub repository salem-5/studysync, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/salem-5/studysync
- Repository: https://github.com/salem-5/studysync

## Overview

1. **Top-level shape**
   StudySync is a two-process desktop system: a **Qt client** and a **local C++ TCP server**. They are built from the same CMake workspace, with a small **shared** library for common data structures.

2. **Client subsystem**
   The client is a Qt GUI application under `client/`. Its entrypoint is `client/src/main.cpp`, which launches the main window and UI state. The client is responsible for all user interaction: login, dashboard, groups, chat, tasks, focus timer, and the AI Tutor placeholder.

3. **Client UI architecture**
   The UI is organized into reusable pages and dialogs:
   - `ui/MainWindow` is the shell that hosts navigation and page switching.
   - Pages such as `DashboardPage`, `GroupsPage`, `GroupChatPage`, `TasksPage`, `FocusPage`, and `AiTutorPage` represent major screens.
   - Widgets/dialogs like `LoginWindow`, `CreateGroupDialog`, `CreateTaskDialog`, `EditTaskDialog`, `ManageMembersDialog`, and `NotificationsDialog` handle focused workflows.
   This structure is important for a diagram because the UI is not a single monolith; it is composed of multiple feature screens around a shared application state.

4. **Client-side application state and language/theme**
   `ClientState` appears to hold UI/session state, while `LanguageManager` loads localized strings from `client/resources/lang/*.json`. The client also bundles theme styling and icons via Qt resources. This means presentation concerns are mostly local to the client and are separated from networking and domain logic.

5. **Client networking boundary**
   Networking is isolated behind `TcpClient`, `ServerAPI`, and `ClientNetworkManager`.
   - `TcpClient` is the transport layer for raw TCP communication.
   - `ServerAPI` is the higher-level request/response interface used by the UI.
   - `ClientNetworkManager` likely coordinates network calls and updates UI state.
   This separation is the main client-side boundary between GUI code and backend communication.

6. **Server subsystem**
   The server is in `server/` and runs as a standalone process started locally alongside the client. Its entrypoint is `server/src/main.cpp`. The server owns authentication/session handling, routing of messages, and persistence.

7. **Server networking and routing**
   `TcpServer` accepts client connections and feeds incoming payloads to `MessageRouter`. `ServerRoutes.cpp` defines the application-level handlers for requests such as group operations, chat messages, and task actions. The server is therefore structured as:
   transport in → route/message dispatch → domain/database operations → response out.

8. **Persistence layer**
   `Database` wraps SQLite access. The repo includes the SQLite amalgamation directly under `server/src/sqlite` and exposes the SQLite header under `server/include/sqlite`. This makes the server self-contained and explains why the README requires a local server: the persistent state lives in the server process and its SQLite database, not in the client.

9. **Shared domain model**
   The `shared/` directory contains `DataStructures`, which is the contract layer between client and server. These types likely define the request/response payloads, entities, and message formats both sides need to understand. In an architecture diagram, this is the key cross-cutting boundary: both processes depend on the same serialized data model.

10. **Primary data flows**
   The main flow is:
   user action in Qt UI → client page/dialog → `ServerAPI`/`ClientNetworkManager` → `TcpClient` → server `TcpServer` → `MessageRouter`/routes → `Database` → response back to client UI.
   Most app features follow this pattern, especially groups, tasks, chat, and notifications.

11. **Feature boundaries**
   The repo’s product features map cleanly to server-backed domains:
   - **Groups**: create/manage groups and members
   - **Chat**: live group messaging
   - **Tasks**: task creation, assignment, editing
   - **Dashboard**: aggregated view of active tasks and pinned groups
   - **Focus Timer**: likely local/UI-driven, with less backend dependence
   - **AI Tutor**: explicitly a placeholder, so it is a UI stub rather than an integrated backend feature
   This distinction matters because not every screen has the same backend dependency.

12. **Build and deployment**
   The whole project is CMake-based and builds both executables from the workspace root. There is no separate cloud deployment in the repo; the current architecture assumes a **desktop client + locally running server** model. For diagrams, depict the server as a required peer process rather than a remote SaaS dependency.

13. **What to draw as the main architecture boxes**
   The most accurate high-level diagram would show:
   - Qt desktop client
   - TCP network boundary
   - C++ server process
   - SQLite database embedded in the server
   - shared data model library used by both client and server
   That captures the actual separation of responsibilities in this repository.

Main entry points: [`client/include/ui/MainWindow.h`](https://github.com/salem-5/studysync/blob/main/client/include/ui/MainWindow.h) (Main Window), [`client/include/ClientNetworkManager.h`](https://github.com/salem-5/studysync/blob/main/client/include/ClientNetworkManager.h) (Network Manager), [`shared/include/DataStructures.h`](https://github.com/salem-5/studysync/blob/main/shared/include/DataStructures.h) (Data Structures), [`client/include/ServerAPI.h`](https://github.com/salem-5/studysync/blob/main/client/include/ServerAPI.h) (Server API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["CMake Workspace"]
end

subgraph group_client["Qt Client"]
  node_client_entry["Client App<br/>qt entrypoint<br/>[main.cpp]"]
  node_main_window["Main Window<br/>ui shell<br/>[MainWindow.h]"]
  node_client_state["Client State<br/>ui state<br/>[ClientState.h]"]
  node_login_window["Login<br/>auth dialog<br/>[LoginWindow.h]"]
  node_dashboard_page["Dashboard<br/>feature page<br/>[DashboardPage.h]"]
  node_groups_page["Groups<br/>feature page<br/>[GroupsPage.h]"]
  node_group_chat_page["Chat<br/>feature page<br/>[GroupChatPage.h]"]
  node_tasks_page["Tasks<br/>feature page<br/>[TasksPage.h]"]
  node_focus_page["Focus Timer<br/>feature page<br/>[FocusPage.h]"]
  node_ai_tutor_page["AI Tutor<br/>stub page<br/>[AiTutorPage.h]"]
  node_network_mgr["Network Manager<br/>client coordinator"]
  node_server_api["Server API<br/>request layer<br/>[ServerAPI.h]"]
  node_tcp_client["TCP Client<br/>transport<br/>[TcpClient.h]"]
  node_language_mgr["Language Manager<br/>localization<br/>[LanguageManager.h]"]
end

subgraph group_server["Local Server"]
  node_server_entry["Server App<br/>server entrypoint<br/>[main.cpp]"]
  node_tcp_server["TCP Server<br/>transport<br/>[TcpServer.h]"]
  node_message_router["Message Router<br/>dispatcher<br/>[MessageRouter.h]"]
  node_server_routes["Server Routes<br/>handlers<br/>[ServerRoutes.cpp]"]
  node_database[("Database<br/>sqlite wrapper<br/>[Database.h]")]
end

subgraph group_shared["Shared Model"]
  node_data_structures["Data Structures<br/>shared contract<br/>[DataStructures.h]"]
end

node_client_entry -->|"launches"| node_main_window
node_main_window -->|"uses"| node_client_state
node_main_window -->|"opens"| node_login_window
node_main_window -->|"navigates"| node_dashboard_page
node_main_window -->|"navigates"| node_groups_page
node_main_window -->|"navigates"| node_group_chat_page
node_main_window -->|"navigates"| node_tasks_page
node_main_window -->|"navigates"| node_focus_page
node_main_window -->|"navigates"| node_ai_tutor_page
node_groups_page -->|"requests"| node_network_mgr
node_group_chat_page -->|"requests"| node_network_mgr
node_tasks_page -->|"requests"| node_network_mgr
node_dashboard_page -->|"loads"| node_network_mgr
node_network_mgr -->|"delegates"| node_server_api
node_server_api -->|"sends"| node_tcp_client
node_language_mgr -->|"localizes"| node_main_window
node_server_entry -->|"starts"| node_tcp_server
node_tcp_server -->|"forwards"| node_message_router
node_message_router -->|"dispatches"| node_server_routes
node_server_routes -->|"persists"| node_database
node_server_routes -->|"uses"| node_data_structures
node_server_api -->|"uses"| node_data_structures
node_tcp_client -->|"connects"| node_tcp_server
node_client_entry -->|"uses"| node_data_structures
node_server_entry -->|"uses"| node_data_structures

click node_client_entry "https://github.com/salem-5/studysync/blob/main/client/src/main.cpp"
click node_main_window "https://github.com/salem-5/studysync/blob/main/client/include/ui/MainWindow.h"
click node_client_state "https://github.com/salem-5/studysync/blob/main/client/include/ui/ClientState.h"
click node_login_window "https://github.com/salem-5/studysync/blob/main/client/include/ui/widget/LoginWindow.h"
click node_dashboard_page "https://github.com/salem-5/studysync/blob/main/client/include/ui/page/DashboardPage.h"
click node_groups_page "https://github.com/salem-5/studysync/blob/main/client/include/ui/page/GroupsPage.h"
click node_group_chat_page "https://github.com/salem-5/studysync/blob/main/client/include/ui/page/GroupChatPage.h"
click node_tasks_page "https://github.com/salem-5/studysync/blob/main/client/include/ui/page/TasksPage.h"
click node_focus_page "https://github.com/salem-5/studysync/blob/main/client/include/ui/page/FocusPage.h"
click node_ai_tutor_page "https://github.com/salem-5/studysync/blob/main/client/include/ui/page/AiTutorPage.h"
click node_network_mgr "https://github.com/salem-5/studysync/blob/main/client/include/ClientNetworkManager.h"
click node_server_api "https://github.com/salem-5/studysync/blob/main/client/include/ServerAPI.h"
click node_tcp_client "https://github.com/salem-5/studysync/blob/main/client/include/TcpClient.h"
click node_language_mgr "https://github.com/salem-5/studysync/blob/main/client/include/LanguageManager.h"
click node_server_entry "https://github.com/salem-5/studysync/blob/main/server/src/main.cpp"
click node_tcp_server "https://github.com/salem-5/studysync/blob/main/server/include/TcpServer.h"
click node_message_router "https://github.com/salem-5/studysync/blob/main/server/include/MessageRouter.h"
click node_server_routes "https://github.com/salem-5/studysync/blob/main/server/src/ServerRoutes.cpp"
click node_database "https://github.com/salem-5/studysync/blob/main/server/include/Database.h"
click node_data_structures "https://github.com/salem-5/studysync/blob/main/shared/include/DataStructures.h"

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_client_entry,node_main_window,node_client_state,node_login_window,node_dashboard_page,node_groups_page,node_group_chat_page,node_tasks_page,node_focus_page,node_ai_tutor_page,node_network_mgr,node_server_api,node_tcp_client,node_language_mgr toneAmber
class node_server_entry,node_tcp_server,node_message_router,node_server_routes,node_database toneMint
class node_data_structures toneRose
```

## Components

### Qt Client

Desktop GUI process with navigation, feature pages, and network bridge.

- [Client App](https://github.com/salem-5/studysync/blob/main/client/src/main.cpp): qt entrypoint · Starts the desktop client and initializes UI flow. · `client/src/main.cpp`
- [Main Window](https://github.com/salem-5/studysync/blob/main/client/include/ui/MainWindow.h): ui shell · Hosts navigation and page switching for the client. · `client/include/ui/MainWindow.h`
- [Client State](https://github.com/salem-5/studysync/blob/main/client/include/ui/ClientState.h): ui state · Holds session and application UI state. · `client/include/ui/ClientState.h`
- [Login](https://github.com/salem-5/studysync/blob/main/client/include/ui/widget/LoginWindow.h): auth dialog · Initial login workflow for the client. · `client/include/ui/widget/LoginWindow.h`
- [Dashboard](https://github.com/salem-5/studysync/blob/main/client/include/ui/page/DashboardPage.h): feature page · Aggregated overview of active work and pinned groups. · `client/include/ui/page/DashboardPage.h`
- [Groups](https://github.com/salem-5/studysync/blob/main/client/include/ui/page/GroupsPage.h): feature page · Group browsing and management screen. · `client/include/ui/page/GroupsPage.h`
- [Chat](https://github.com/salem-5/studysync/blob/main/client/include/ui/page/GroupChatPage.h): feature page · Group messaging and chat interactions. · `client/include/ui/page/GroupChatPage.h`
- [Tasks](https://github.com/salem-5/studysync/blob/main/client/include/ui/page/TasksPage.h): feature page · Task list and task workflows. · `client/include/ui/page/TasksPage.h`
- [Focus Timer](https://github.com/salem-5/studysync/blob/main/client/include/ui/page/FocusPage.h): feature page · Local focus timer and productivity screen. · `client/include/ui/page/FocusPage.h`
- [AI Tutor](https://github.com/salem-5/studysync/blob/main/client/include/ui/page/AiTutorPage.h): stub page · Placeholder feature screen without backend integration. · `client/include/ui/page/AiTutorPage.h`
- [Network Manager](https://github.com/salem-5/studysync/blob/main/client/include/ClientNetworkManager.h): client coordinator · Coordinates client network calls and state updates. · `client/include/ClientNetworkManager.h`
- [Server API](https://github.com/salem-5/studysync/blob/main/client/include/ServerAPI.h): request layer · Higher-level interface used by the UI to call the backend. · `client/include/ServerAPI.h`
- [TCP Client](https://github.com/salem-5/studysync/blob/main/client/include/TcpClient.h): transport · Raw TCP transport for client-server communication. · `client/include/TcpClient.h`
- [Language Manager](https://github.com/salem-5/studysync/blob/main/client/include/LanguageManager.h): localization · Loads localized strings for the client UI. · `client/include/LanguageManager.h`

### Local Server

Standalone C++ process handling transport, routing, and persistence.

- [Server App](https://github.com/salem-5/studysync/blob/main/server/src/main.cpp): server entrypoint · Starts the local C++ server process. · `server/src/main.cpp`
- [TCP Server](https://github.com/salem-5/studysync/blob/main/server/include/TcpServer.h): transport · Accepts client connections and incoming messages. · `server/include/TcpServer.h`
- [Message Router](https://github.com/salem-5/studysync/blob/main/server/include/MessageRouter.h): dispatcher · Routes incoming payloads to application handlers. · `server/include/MessageRouter.h`
- [Server Routes](https://github.com/salem-5/studysync/blob/main/server/src/ServerRoutes.cpp): handlers · Application-level request handlers for groups, chat, and tasks. · `server/src/ServerRoutes.cpp`
- [Database](https://github.com/salem-5/studysync/blob/main/server/include/Database.h): sqlite wrapper · Persistence layer wrapping embedded SQLite access. · `server/include/Database.h`

### Shared Model

Common data structures used by both processes.

- [Data Structures](https://github.com/salem-5/studysync/blob/main/shared/include/DataStructures.h): shared contract · Common request, response, and entity types shared by both processes. · `shared/include/DataStructures.h`

## Connections

- Client App → Main Window: launches · Client startup creates the main UI shell.
- Main Window → Client State: uses · UI shell reads and updates application state.
- Main Window → Login: opens · Login dialog is part of the main client flow.
- Main Window → Dashboard: navigates · Main shell switches to the dashboard screen.
- Main Window → Groups: navigates · Main shell switches to the groups screen.
- Main Window → Chat: navigates · Main shell switches to group chat.
- Main Window → Tasks: navigates · Main shell switches to task management.
- Main Window → Focus Timer: navigates · Main shell switches to the focus timer.
- Main Window → AI Tutor: navigates · Main shell can show the AI Tutor placeholder.
- Groups → Network Manager: requests · Group workflows call into the client network coordinator.
- Chat → Network Manager: requests · Chat screen sends and receives through the network layer.
- Tasks → Network Manager: requests · Task workflows use the client network coordinator.
- Dashboard → Network Manager: loads · Dashboard aggregates server-backed data through the network layer.
- Network Manager → Server API: delegates · Coordinator uses the higher-level backend API.
- Server API → TCP Client: sends · API serializes requests onto the TCP transport.
- Language Manager → Main Window: localizes · Localized strings feed the UI layer.
- Server App → TCP Server: starts · Server startup creates the TCP listener.
- TCP Server → Message Router: forwards · Incoming payloads are handed to the router.
- Message Router → Server Routes: dispatches · Router passes application requests to route handlers.
- Server Routes → Database: persists · Handlers read and write persistent state.
- Server Routes → Data Structures: uses · Routes operate on shared message and entity types.
- Server API → Data Structures: uses · Client API encodes and decodes the shared contract.
- TCP Client → TCP Server: connects · Raw network link between the desktop client and local server.
- Client App → Data Structures: uses · Client startup compiles against shared types.
- Server App → Data Structures: uses · Server startup compiles against shared types.
