# sleitnick/knit architecture

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

- Interactive diagram: https://gitdiagram.com/sleitnick/knit
- Repository: https://github.com/sleitnick/knit

## Overview

##### Project Type and Purpose
- Project Type: This is a lightweight framework built specifically for Roblox to streamline communication between the server and client.
- Purpose: Knit simplifies the creation of services and controllers by abstracting away the low-level RemoteFunctions and RemoteEvents. It provides mechanisms for asynchronous operations (using Promises) and a structure for creating and consuming services on both the server and client. The README clearly demonstrates its use cases with examples like a “MoneyService.”

##### File Structure
- Top-level directories and files such as “src”, “test”, “docs”, and configuration files (e.g., wally.toml, moonwave.toml, selene.toml) indicate a well-organized project with source code, tests for both server and client, continuous integration workflows, and documentation.
- Within the “src” folder, you see files like “KnitClient.luau”, “KnitServer.luau”, and “init.luau” which denote the core components used to initialize and run Knit on either the client or the server.
- Multiple configuration files (for actions, testing, formatting, and project management) suggest the project supports modern development practices (like CI/CD and dependency management with Wally).

##### Interpreting the README
- The documentation emphasizes a simple entry point for both server and client: one main script on each side that loads and starts Knit.
- It further explains how to create a service on the server and expose client-accessible methods, highlighting the internal use of RemoteFunctions behind the scenes.
- The implementation illustration in the README clearly points out the abstraction over the conventional Roblox networking components and the promise-based error handling.

## Diagram (Mermaid)

```mermaid
graph TD
    RE["Roblox Environment"]:::env

    subgraph "Core Framework"
        KF1["Knit Init"]:::core
        KF2["Knit Client"]:::core
        KF3["Knit Server"]:::core
        PR["Promise-based Async"]:::coreNote
    end

    subgraph "Server Side"
        SS["MoneyService (Server Service)"]:::server
    end

    subgraph "Client Side"
        CC["Client Controllers"]:::client
    end

    subgraph "CI/CD & Config"
        WF["CI/CD Workflows"]:::config
        PC["Project Config Files"]:::config
        SC["Selene Config"]:::config
        ST["Stylua Config"]:::config
    end

    %% Connections between layers
    RE --> KF1
    KF1 --> KF2
    KF1 --> KF3
    KF1 --> PR
    KF2 -->|"abstracts_RF/RE"| KF3

    KF3 --> SS
    KF2 --> CC
    CC -->|"RemoteCall(Promise)"| SS
    SS -->|"Response"| CC

    RE --> WF
    RE --> PC
    RE --> SC
    RE --> ST

    %% Click Events for Core Framework Initialization
    click KF1 "https://github.com/sleitnick/knit/blob/main/src/init.luau"
    click KF2 "https://github.com/sleitnick/knit/blob/main/src/KnitClient.luau"
    click KF3 "https://github.com/sleitnick/knit/blob/main/src/KnitServer.luau"

    %% Click Events for Server-Side Services
    click SS "https://github.com/sleitnick/knit/blob/main/docs/services.md"
    click SS "https://github.com/sleitnick/knit/blob/main/test/server/KnitServerTest.server.luau"

    %% Click Events for Client-Side Controllers
    click CC "https://github.com/sleitnick/knit/blob/main/docs/controllers.md"
    click CC "https://github.com/sleitnick/knit/blob/main/test/client/KnitClientTest.client.luau"

    %% Click Events for CI/CD and Configuration
    click WF "https://github.com/sleitnick/knit/tree/main/.github/workflows"
    click PC "https://github.com/sleitnick/knit/blob/main/dev.project.json"
    click SC "https://github.com/sleitnick/knit/blob/main/selene.toml"
    click ST "https://github.com/sleitnick/knit/blob/main/stylua.toml"

    %% Styles
    classDef env fill:#dcdcdc,stroke:#333,stroke-width:2px
    classDef core fill:#ffcc00,stroke:#333,stroke-width:2px
    classDef coreNote fill:#ffeeaa,stroke:#333,stroke-dasharray: 5, 5,stroke-width:2px
    classDef server fill:#ff9999,stroke:#333,stroke-width:2px
    classDef client fill:#99ff99,stroke:#333,stroke-width:2px
    classDef config fill:#99ccff,stroke:#333,stroke-width:2px
```
