# sunbird-knowlg/knowledge-platform architecture

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

- Interactive diagram: https://gitdiagram.com/sunbird-knowlg/knowledge-platform
- Repository: https://github.com/sunbird-knowlg/knowledge-platform

## Overview

##### Project type and purpose
- This is a microservice-based backend platform (“Knowledge Platform 2.0”) exposing domain APIs (Content, Assessment, Search, Taxonomy, etc.) via Play/Netty servers.
- It uses Akka actors for business logic, Cassandra/Neo4j/Redis/Elasticsearch for data/backing stores, Kafka for messaging, and shared libraries for common concerns.

##### File structure
- Top-level per-domain folders (content-api, assessment-api, search-api, taxonomy-api, ontology-engine, platform-core, platform-modules)
- Each domain splits into an “actors” module (the Akka actor layer) and a “service” module (HTTP controllers, filters, DI modules)
- Shared libraries in platform-core (actor-core, cassandra-connector, kafka-client, cache, common utilities, telemetry, schema-validator)
- platform-modules for off-line/content import, MIME‐type and URL management
- Infrastructure-as-code under build/ (Dockerfiles, CI pipelines), docker-compose.yml, kubernetes/helm_charts/, terraform/

##### Key insights from README
- All services are run locally via Docker (Cassandra, Neo4j, Redis, Kafka, Elasticsearch)
- Each service starts with “mvn play2:run” on port 9000 and exposes a /health endpoint
- Local setup script automates container provisioning

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    Clients["Clients (Postman/UI)"]:::external

    %% Microservices
    subgraph "Content Service" 
        direction TB
        CC["ContentController"]:::api
        CH["ContentHandler/Module"]:::module
        CA["ContentActor"]:::logic
        CC -->|HTTP Request| CH
        CH -->|Invoke| CA
        click CC "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/content-api/content-service"
        click CA "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/content-api/content-actors"
    end

    subgraph "Assessment Service"
        direction TB
        AC["AssessmentController"]:::api
        AH["AssessmentHandler/Module"]:::module
        AA["AssessmentActor"]:::logic
        AC -->|HTTP Request| AH
        AH -->|Invoke| AA
        click AC "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/assessment-api/assessment-service"
        click AA "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/assessment-api/assessment-actors"
    end

    subgraph "Search Service"
        direction TB
        SC["SearchController"]:::api
        SH["SearchHandler/Module"]:::module
        SA["SearchActor"]:::logic
        CORE["SearchCoreLib"]:::lib
        SC -->|HTTP Request| SH
        SH -->|Invoke| SA
        SA -->|Query| CORE
        click SC "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/search-api/search-service"
        click SA "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/search-api/search-actors"
        click CORE "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/search-api/search-core"
    end

    subgraph "Taxonomy Service"
        direction TB
        TC["TaxonomyController"]:::api
        TH["TaxonomyHandler/Module"]:::module
        TA["TaxonomyActor"]:::logic
        TC -->|HTTP Request| TH
        TH -->|Invoke| TA
        click TC "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/taxonomy-api/taxonomy-service"
        click TA "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/taxonomy-api/taxonomy-actors"
    end

    subgraph "Ontology Engine"
        direction TB
        GC["GraphDACAPI"]:::module
        GE["GraphEngine"]:::logic
        GCORE["GraphCoreImpl"]:::logic
        GCOMM["GraphCommonUtils"]:::lib
        GC -->|DI| GE
        GE -->|Access| GCORE
        GE -->|Utilize| GCOMM
        click GCORE "https://github.com/sunbird-knowlg/knowledge-platform/blob/master/ontology-engine/graph-core_2.12"
        click GC "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/ontology-engine/graph-dac-api"
        click GCOMM "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/ontology-engine/graph-common"
        click GE "https://github.com/sunbird-knowlg/knowledge-platform/blob/master/ontology-engine/graph-engine_2.12"
    end

    %% Shared Libraries
    subgraph "Shared Libraries"
        direction TB
        AKCORE["Actor Core"]:::lib
        CASCONN["Cassandra Connector"]:::lib
        KAFKC["Kafka Client"]:::lib
        REDISC["Redis Cache"]:::lib
        COMMLIB["Common Utilities/DTOs"]:::lib
        TELE["Telemetry & Logging"]:::lib
        SCHEMA["Schema Validator"]:::lib
        click AKCORE "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-core/actor-core"
        click CASCONN "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-core/cassandra-connector"
        click KAFKC "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-core/kafka-client"
        click REDISC "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-core/platform-cache"
        click COMMLIB "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-core/platform-common"
        click TELE "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-core/platform-telemetry"
        click SCHEMA "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-core/schema-validator"
    end

    %% Shared Modules
    subgraph "Shared Modules"
        direction TB
        IMPORT["Import Manager"]:::module
        MIME["MIME-type Manager"]:::module
        URLM["URL Manager"]:::module
        click IMPORT "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-modules/import-manager"
        click MIME "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-modules/mimetype-manager"
        click URLM "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/platform-modules/url-manager"
    end

    %% External Systems
    Cassandra[Cassandra Cluster]:::db
    Neo4j[Neo4j Graph DB]:::db
    Redis[Redis Cache]:::db
    Elasticsearch[Elasticsearch Cluster]:::db
    Kafka[Kafka Bus]:::bus
    TelemetrySys[Telemetry System]:::external

    %% Infrastructure
    subgraph "Infrastructure & CI/CD"
        direction TB
        DockerCompose["Docker Compose"]:::infra
        K8s["Kubernetes/Helm"]:::infra
        Terraform["Terraform Scripts"]:::infra
        CI["CI/CD Pipelines"]:::infra
        click DockerCompose "https://github.com/sunbird-knowlg/knowledge-platform/blob/master/docker-compose.yml"
        click K8s "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/kubernetes/, knowlg-automation/helm_charts/"
        click Terraform "https://github.com/sunbird-knowlg/knowledge-platform/tree/master/knowlg-automation/terraform/"
        click CI "https://github.com/sunbird-knowlg/knowledge-platform/blob/master/.github/workflows/, .circleci/config.yml"
    end

    %% Connections
    Clients -->|"Calls"| CC & AC & SC & TC & GC
    CA -->|Read/Write| Cassandra
    AA -->|Read/Write| Cassandra
    SA -->|Read/Write| Cassandra
    TA -->|Read/Write| Cassandra
    CA -->|Cache| Redis
    AA -->|Cache| Redis
    SA -->|Cache| Redis
    TA -->|Cache| Redis
    CA -->|Publish Events| Kafka
    AA -->|Publish Events| Kafka
    SA -->|Publish Events| Kafka
    TA -->|Publish Events| Kafka
    GE -->|Graph Ops| Neo4j
    SA -->|Search Ops| Elasticsearch
    Kafka -->|Consume| CA & AA & SA & TA & GE
    CA -->|Telemetry| TelemetrySys
    AA -->|Telemetry| TelemetrySys
    SA -->|Telemetry| TelemetrySys
    TA -->|Telemetry| TelemetrySys
    GE -->|Telemetry| TelemetrySys

    %% Infra interactions
    DockerCompose -->|"Deploy Locally"| Clients & CC & AC & SC & TC & GC
    K8s -->|"Deploy Prod"| Clients & CC & AC & SC & TC & GC
    Terraform -->|"Provision Infrastructure"| DockerCompose & K8s
    CI -->|"Trigger Build/Deploy"| DockerCompose & K8s

    %% Styles
    classDef api fill:#cfe2f3,stroke:#6fa8dc;
    classDef module fill:#d9ead3,stroke:#93c47d;
    classDef logic fill:#fff2cc,stroke:#ffd966;
    classDef db fill:#fce5cd,stroke:#f6b26b,stroke-width:2px;
    classDef bus fill:#d9d2e9,stroke:#8e7cc3,stroke-width:2px,shape:hexagon;
    classDef lib fill:#e7e6e6,stroke:#999999,stroke-dasharray: 2 2;
    classDef external fill:#ead1dc,stroke:#c27ba0,stroke-width:2px;
    classDef infra fill:#f4cccc,stroke:#ea9999;
```
