# dicodingacademy/platform-sync architecture

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

- Interactive diagram: https://gitdiagram.com/dicodingacademy/platform-sync
- Repository: https://github.com/dicodingacademy/platform-sync

## Overview

##### Project type and purpose
- This is an open‑source developer tool (“Platform Sync”) providing two IDE clients (IntelliJ/Android Studio plugin and VS Code extension) that synchronize file and cursor positions with the external Dicoding Review Platform over WebSockets.
- There is no server component in this repo—the remote review platform is external. This is a multi‑module tool project, not a web app or microservices environment.

##### File structure
- Top‑level:
- .github/workflows: CI/CD (build, review)
- intellij-plugin: Kotlin/Gradle code for the IntelliJ‑based IDE plugin
- vscode-extension: TypeScript code for the VS Code extension
- package.json / package-lock.json: npm orchestration scripts to build both
- IntelliJ plugin sub‑structure follows the typical plugin modularization:
- action: user‑invoked commands (e.g., input WebSocket URL)
- service: business logic (WebSocketService, ReviewerIdentifierService)
- widget: UI status bar components
- listener: file/cursor change detectors
- VS Code extension sub‑structure:
- extension.ts: activation/deactivation hooks and command registrations
- websocket.ts: WebSocket client implementation
- types.ts: shared TypeScript interfaces
- Build & deployment artifacts and scripts: Gradle wrappers, npm scripts, CI YAML files.

##### README for additional insights
- Clarifies compatibility, prerequisites (JDK 17+, Node.js 18+), build commands and workflows.
- Emphasizes dual build targets (IntelliJ plugin and VS Code extension), and GitHub Actions that package and release both.

a. Main components
- IntelliJ‑based plugin
- VS Code extension
- GitHub Actions CI/CD pipeline
- External Dicoding Review Platform (WebSocket & HTTP API)
- Local developer environments (IDE hosts)

b. Relationships & interactions
- Both clients connect outbound via WebSocket to the Review Platform.
- Plugins detect local events (file open/change, cursor move) → serialize and send over WebSocket.
- Incoming WebSocket messages from platform → service layer → UI update (status bar, cursor jumps).
- CI workflows trigger on push/tag → build both packages → publish release & VSIX.

c. Architectural patterns & design principles
- Event‑driven plugin architecture: listener → service → UI widget.
- Adapter pattern for WebSocket communication encapsulated in service classes.
- Single Responsibility: actions, services, widgets separated by folder.
- Standard VS Code extension and IntelliJ plugin SDK conventions.

d. Key technologies & frameworks
- Kotlin + IntelliJ Platform SDK + Gradle
- TypeScript + VS Code Extension API + WebSocket
- npm scripts to orchestrate parallel builds
- GitHub Actions for CI/CD

##### Final advice
- Event flows end‑to‑end, including build/release pipeline.
- Keep labels concise but precise (e.g., “FilesDetectionsListener”, “WebSocketService”, “extension.ts”).
- This clarity will ensure maintainers and new contributors instantly grasp the system’s structure and behavior.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Developer Environments
    subgraph "Local Developer Environments"
        DevMachines([Developer IDEs])
    end

    %% IntelliJ Plugin Layer
    subgraph "IntelliJ Plugin" 
        style IntelliJPlugin fill:#cfe2f3,stroke:#000
        IntelliJPluginDir["intellij-plugin/"] 
        BuildGradle["build.gradle.kts"] 
        PluginXML["plugin.xml"] 
        Listener["FilesDetectionsListener"] 
        Action1["PlatformSyncStatusAction"] 
        Action2["ReviewerIdentifierInputAction"] 
        Action3["WebSocketUrlInputAction"] 
        Service1["WebSocketService"] 
        Service2["ReviewerIdentifierService"] 
        Widget1["PlatformSyncStatusBarWidget"] 
        Widget2["PlatformSyncStatusBarWidgetFactory"] 
    end

    %% VS Code Extension Layer
    subgraph "VS Code Extension"
        style VSCodeExt fill:#cfe2f3,stroke:#000
        VSCodeDir["vscode-extension/"] 
        ExtensionTS["extension.ts"] 
        WebsocketTS["websocket.ts"] 
        TypesTS["types.ts"] 
        VSC_pkgjson["package.json"] 
        VSC_tsconfig["tsconfig.json"] 
        VSC_ignore[".vscodeignore"] 
    end

    %% External Service
    ExternalPlatform["Dicoding Review Platform"] 
    class ExternalPlatform external

    %% CI/CD Pipeline
    subgraph "GitHub Actions CI/CD"
        style CI fill:#cccccc,stroke:#000
        BuildWorkflow[".github/workflows/build.yml"] 
        ReviewWorkflow[".github/workflows/review.yml"] 
        RootPkg["package.json"] 
        LockFile["package-lock.json"] 
    end

    %% Flows: IntelliJ
    DevMachines -->|uses| IntelliJPluginDir
    IntelliJPluginDir --> BuildGradle
    IntelliJPluginDir --> PluginXML
    IntelliJPluginDir --> Listener
    IntelliJPluginDir --> Action1
    IntelliJPluginDir --> Action2
    IntelliJPluginDir --> Action3
    IntelliJPluginDir --> Service1
    IntelliJPluginDir --> Service2
    IntelliJPluginDir --> Widget1
    IntelliJPluginDir --> Widget2

    Listener -->|detect events| Service1
    Action1 -->|invoke| Service1
    Action2 -->|invoke| Service2
    Action3 -->|invoke| Service1
    Service1 -->|WebSocket connect| ExternalPlatform
    ExternalPlatform -->|messages| Service1
    Service1 -->|forward| Widget1
    Service1 -->|forward| Widget2

    %% Flows: VS Code
    DevMachines -->|uses| VSCodeDir
    VSCodeDir --> ExtensionTS
    VSCodeDir --> WebsocketTS
    VSCodeDir --> TypesTS
    VSCodeDir --> VSC_pkgjson
    VSCodeDir --> VSC_tsconfig
    VSCodeDir --> VSC_ignore

    ExtensionTS -->|register commands| WebsocketTS
    WebsocketTS -->|WebSocket connect| ExternalPlatform
    ExternalPlatform -->|messages| WebsocketTS
    WebsocketTS -->|events| ExtensionTS

    %% CI/CD flows
    rootpush([Code Push/Tag]) --> BuildWorkflow
    BuildWorkflow -->|build IntelliJ & VSIX| ReviewWorkflow
    ReviewWorkflow -->|publish releases| rootpush
    rootpush --> RootPkg
    rootpush --> LockFile

    %% Click events
    click IntelliJPluginDir "https://github.com/dicodingacademy/platform-sync/tree/master/intellij-plugin/"
    click BuildGradle "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/build.gradle.kts"
    click PluginXML "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/src/main/resources/META-INF/plugin.xml"
    click Listener "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/src/main/kotlin/com/platfom/sync/FilesDetectionsListener.kt"
    click Action1 "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/src/main/kotlin/com/platfom/sync/action/PlatformSyncStatusAction.kt"
    click Action2 "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/src/main/kotlin/com/platfom/sync/action/ReviewerIdentifierInputAction.kt"
    click Action3 "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/src/main/kotlin/com/platfom/sync/action/WebSocketUrlInputAction.kt"
    click Service1 "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/src/main/kotlin/com/platfom/sync/service/WebSocketService.kt"
    click Service2 "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/src/main/kotlin/com/platfom/sync/service/ReviewerIdentifierService.kt"
    click Widget1 "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/src/main/kotlin/com/platfom/sync/widget/PlatformSyncStatusBarWidget.kt"
    click Widget2 "https://github.com/dicodingacademy/platform-sync/blob/master/intellij-plugin/src/main/kotlin/com/platfom/sync/widget/PlatformSyncStatusBarWidgetFactory.kt"
    click VSCodeDir "https://github.com/dicodingacademy/platform-sync/tree/master/vscode-extension/"
    click ExtensionTS "https://github.com/dicodingacademy/platform-sync/blob/master/vscode-extension/src/extension.ts"
    click WebsocketTS "https://github.com/dicodingacademy/platform-sync/blob/master/vscode-extension/src/websocket.ts"
    click TypesTS "https://github.com/dicodingacademy/platform-sync/blob/master/vscode-extension/src/types.ts"
    click VSC_pkgjson "https://github.com/dicodingacademy/platform-sync/blob/master/vscode-extension/package.json"
    click VSC_tsconfig "https://github.com/dicodingacademy/platform-sync/blob/master/vscode-extension/tsconfig.json"
    click VSC_ignore "https://github.com/dicodingacademy/platform-sync/blob/master/vscode-extension/.vscodeignore"
    click BuildWorkflow "https://github.com/dicodingacademy/platform-sync/blob/master/.github/workflows/build.yml"
    click ReviewWorkflow "https://github.com/dicodingacademy/platform-sync/blob/master/.github/workflows/review.yml"
    click RootPkg "https://github.com/dicodingacademy/platform-sync/blob/master/package.json"
    click LockFile "https://github.com/dicodingacademy/platform-sync/blob/master/package-lock.json"

    %% Styles
    classDef external fill:#d9ead3,stroke:#000
    class DefIntelliJ fill:#cfe2f3
    classDef CI fill:#cccccc,stroke:#000
    class IntelliJPluginDir,BuildGradle,PluginXML,Listener,Action1,Action2,Action3,Service1,Service2,Widget1,Widget2 DefIntelliJ
    class VSCodeDir,ExtensionTS,WebsocketTS,TypesTS,VSC_pkgjson,VSC_tsconfig,VSC_ignore DefIntelliJ
```
