KarmaWerks, Part 0

The Engine

Mafinar Khan • theScore • @mafinar

What is KarmaWerks

  • Graph based Task Management Tool
  • DGraph |> Elixir |> Phoenix
  • MIT Licensed
  • Customizable and Layered

Eh, Engine?

  • Modules that speak to the Store
  • Library agnostic Data Structures
  • Wrappable with Ecto, API, UI, Anything BEAM
  • WIP till January 2020, and then forever

But what does it do?

How do you want to see your tasks?

We want to see

We wants tasks to see themselves

Why not both?

But Database?

Graph Database

  • Store things as Graph Things
  • More than 10 SQL Joins? No Problem
  • DGraph, Neo4J, OrientDB etc
  • Let's talk about DGraph!!!

DGraph

  • Scalable, Distributed, Highly Distributed Graph Database 
  • GraphQL (more or less) query language
  • Open Source
  • Easy to write Drivers in (GRPC!)
  • Sweet Admin Panel

KarmaWerks

  • Layered Architecture
  • Elixir < > DGraph
  • Wraps DGraph Nodes with Context

Core Actors

  • User
  • Group
  • Task
  • Activity
  • Comment

Let's focus on Tasks

How do we see tasks?

Let's Play!!!

I want to make KarmaWerks

  • Let's Make the Engine
    • Let's make the database
      • Make the user database
        • Make the node
        • ...
    • Have Elixir Talk to the database
      • Make the user module
        • Extract user by UID
        • Have them authenticated
  • Let's make an API
    • Make authentication - but it's blocked by user module

How about making that your workflow?

  1. Define the top level task (Project?)
  2. Subtask it
  3. Go to #2 unless it's smallest
  4. Attach blockers along the way
  5. Mind the infinite loop
  6. Move the lanes
  7. Block on blockers (or any parent of it)

Result?

  • One type of data, capable of infinite nest
  • See the "really big" picture
  • Project? They're just top level nodes
  • Kanban board? Aim for the leaves
  • Best of most worlds!

The Data View

Note to self: Switch to the Dashboard!

Why Elixir?

  • Pattern Matching, really good for Data manipulation
    • ...while keeping sanity
  • Good for trees, kinda good for DAGs
  • Realtime capability
  • LiveView can be sweet with tree-like renders
  • Because it's AWESOME!

Example MODULES?

defmodule KarmaWerks.Engine.Task do
  @moduledoc """
  Service functions for task management
  """
  import ShorterMaps

  def create_task(~m/name, description, owner, assignees, group/) do
    Dlex.mutate(:karma_werks, ~s[
      _:t <name> "#{name}" .
      _:t <type> "Task" .
      _:t <description> "#{description}" .
      _:t <owner> <#{owner}> .
      _:t <group> <#{group}> .
      #{Enum.map(assignees, fn assignee ->
        ~s[_:t <asignees> <#{assignee}> .]
      end) |> Enum.join("\n")}
    ])
  end
end

andalso...

 @spec get_user_by(String.t(), String.t()) :: {:ok, [map()]} | {:error, any}
  def get_user_by(attribute, value) do
    query = ~s/{
      result (func: eq(#{attribute}, "#{value}")) {
        uid
        name
        email
        bio
        type
      }
    }/ |> String.replace("\n", "")

    case Dlex.query(:karma_werks, query) do
      {:ok, %{"result" => result}} -> {:ok, result}
      error -> error
    end
  end

and sweet sweet future

  • Write amazing macros after suffering enough
  • Use it as middleware
    • Wrap it with Ecto
    • Sink it into Absinthe
    • Call it from LiveView
  • DGraph will stop feeling alien, even in the most "opinionated" corners of Phoenix!

Current State

TODO

  • Cycle Detection
  • Comments
  • Activity Stream
  • Tag Intelligence
  • Reporting

Wanted

  • Opinion
  • Contribution
  • UX!!!
  • Criticism
  • Rants

Thank You!

KarmaWerks, Part 0

By Mafinar Khan

KarmaWerks, Part 0

  • 1,436