Skip to content

High Level Architecture #1

Closed
Closed

Description

@dailker

High Level Architecture

@codehubbers/core-contributors

This issue is created to document and review the high-level architecture of the msg-sdk-cpp project.

Goals:

  • Provide a clear architectural overview of the SDK.
  • Define major components/modules.
  • Show key data flow and interaction patterns.
  • Facilitate collaboration and feedback from all contributors.

Deliverables:

  • Canva link to architecture diagram.
  • Initial architectural breakdown (modules, interfaces, dependencies).
  • Open feedback thread for suggestions or clarifications.

Diagram:

🔗 View Architecture Diagram on Canva


When changes made briefly explain so we can know what changed. Please continue architecture discussion here. That will appear in project history and can be easily accessible later.

Activity

  1. dailker commented on Jul 8, 2025

    @dailker
    MemberAuthor

    Base open preview

    Image
  2. dailker commented on Jul 8, 2025

    @dailker
    MemberAuthor

    You can edit via above link.
    🔗 View Architecture Diagram on Canva

  3. efecan0 commented on Jul 9, 2025

    @efecan0
    Member

    I have designed use cases off sdk, just look at it and brainstorming after all give some ideas!!!
    When everything done we will pass object diagrams

  4. dailker commented on Jul 9, 2025

    @dailker
    MemberAuthor

    I have designed use cases off sdk, just look at it and brainstorming after all give some ideas!!! When everything done we will pass object diagrams

    Eager to see it!

  5. dailker commented on Jul 9, 2025

    @dailker
    MemberAuthor

    Enhanced High Level Architecture ~ Looks fancy now

  6. linked a pull request that will close this issueBuild system proposal #2on Jul 9, 2025
  7. removed a link to a pull requestBuild system proposal #2on Jul 9, 2025
  8. linked a pull request that will close this issueBuild system proposal #2on Jul 9, 2025
  9. added theissue type on Jul 9, 2025
  10. dailker commented on Jul 9, 2025

    @dailker
    MemberAuthor
    classDiagram
        class CLI {
            +dialPeer(address: string): Connection
            +sendCommand(cmd: string): Status
        }
        class SDK_Core_API {
            +initiateConnection(addr: string): SecureSession
            +manageKeypair(): Keypair
            +processHandshake(conn: Connection): CipherState
        }
        class Identity {
            +generateKeypair(): Keypair
            +resolvePeerPublicKey(addr: string): PublicKey
        }
        class Session {
            +performNoiseHandshakeXX(conn: Connection, keys: Keypair): CipherState
            +encryptMessage(msg: Buffer): CipherText
            +decryptMessage(cipher: CipherText): Buffer
        }
        class Transport {
            +openTCPConnection(addr: string): Socket
            +writePacket(packet: Buffer): Status
            +readPacket(): Buffer
        }
        CLI --> SDK_Core_API : initiates connection
        SDK_Core_API --> Identity : retrieves keys
        SDK_Core_API --> Session : establishes session
        SDK_Core_API --> Transport : manages connection
        Session --> Transport : sends/receives packets
    
    Loading

    Sequence Diagram

    sequenceDiagram
        participant CLI
        participant SDK as SDK Core API
        participant ID as Identity
        participant SES as Session
        participant TR as Transport
        CLI->>SDK: Dial("tcp", "peer.server.com:8080")
        SDK->>ID: GetLocalKeypair()
        ID-->>SDK: localKeypair {privateKey, publicKey}
        SDK->>ID: GetPeerPublicKey("peer.server.com:8080")
        ID-->>SDK: remotePublicKey
        SDK->>TR: DialTCP("peer.server.com:8080")
        TR-->>SDK: rawConnection {socketFD}
        SDK->>SES: NewInitiatorSession(rawConnection, localKeypair, remotePublicKey)
        SES->>SES: Perform Noise Handshake (XX pattern)
        Note over SES: Generates handshake message 1
        SES->>TR: Write(handshakeMsg1: Buffer)
        TR-->>SES: Read(handshakeMsg2: Buffer)
        Note over SES: Processes handshake message 2
        SES->>TR: Write(handshakeMsg3: Buffer)
        Note over SES: Completes handshake, establishes cipherstates
        SES-->>SDK: secureSession {cipherStateIn, cipherStateOut}
        SDK-->>CLI: Session established (status: OK)
    
    Loading

    Object Diagram

    classDiagram
        class CLI_Instance {
            -address: string
            -commandQueue: Queue~string~
            +dialPeer(addr: string): Connection
            +sendCommand(cmd: string): Status
        }
        class SDK_Core_API_Instance {
            -connectionPool: Map~string,Connection~
            -keyStore: KeyStore
            +dialTCP(addr: string): Socket
            +initiateSecureSession(addr: string): SecureSession
            +handleHandshake(conn: Connection): CipherState
        }
        class Identity_Instance {
            -keyStore: Map~string,Keypair~
            +generateKeypair(): Keypair
            +getPeerPublicKey(addr: string): PublicKey
        }
        class Session_Instance {
            -sessionId: string
            -cipherStateIn: CipherState
            -cipherStateOut: CipherState
            -noiseProtocol: Noise_XX
            +initNoiseXX(conn: Connection, keys: Keypair): void
            +writeHandshakeMsg(msg: Buffer): Status
            +readHandshakeMsg(): Buffer
            +encryptPayload(data: Buffer): CipherText
        }
        class Transport_Instance {
            -socketFD: int
            -remoteAddr: string
            -bufferSize: int
            +openTCPConnection(addr: string): Socket
            +writePacket(packet: Buffer): Status
            +readPacket(): Buffer
        }
        class Keypair {
            -privateKey: Buffer
            -publicKey: Buffer
        }
        class Connection {
            -socketFD: int
            -remoteAddr: string
        }
        class CipherState {
            -key: Buffer
            -nonce: int
        }
        class Noise_XX {
            -state: string // Values: init, msg1, msg2, msg3
            -ephemeralKey: Buffer
        }
        class SecureSession {
            -sessionId: string
            -cipherStateIn: CipherState
            -cipherStateOut: CipherState
        }
        CLI_Instance --> SDK_Core_API_Instance : initiates
        SDK_Core_API_Instance o--> Connection : manages
        SDK_Core_API_Instance o--> KeyStore : uses
        SDK_Core_API_Instance --> Identity_Instance : queries
        SDK_Core_API_Instance --> Session_Instance : creates
        SDK_Core_API_Instance --> Transport_Instance : utilizes
        Identity_Instance o--> Keypair : stores
        Session_Instance o--> Noise_XX : executes
        Session_Instance o--> CipherState : maintains
        Session_Instance o--> SecureSession : produces
        Session_Instance --> Transport_Instance : reads/writes
        Transport_Instance o--> Connection : holds
    
    Loading
  11. dailker commented on Jul 9, 2025

    @dailker
    MemberAuthor

    Mermaid files uploaded, canva mermaid converted preview uploaded.

  12. efecan0 commented on Jul 10, 2025

    @efecan0
    Member

    We need more contributors to help our architecture! We need to design architecture nice and clear first. All softwares strong as their architecture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentationenhancementNew feature or requestgood first issueGood for newcomershelp wantedExtra attention is needed

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions