Markdown Powered Graph API

What is Arachne?

Arachne, (Greek: “Spider”) in [[greek/mythology]], the [[Arachne:daughter of:Idmon of Colophon]] in Lydia, a dyer in purple. Arachne was a weaver who acquired such skill in her art that she ventured to challenge Athena, goddess of war, handicraft, and practical reason.

Arachne is a simple application written in Go that traverses a directory and parses markdown files looking for relationship syntax, and creates a graph structure from what it finds.

It also starts a websocket server and simple endpoint to access the structure.

Takes this syntax

// Will generate a relationship between the current page and "target"
[[target]]

// Will generate a relationship between the "source" and "target", with a label of "action"
ex: [[Sally:Is Studying:Computer Science]]
[[source:action:target]]

// Will generate a relationship between the current page and "target" with a label of "action"
[[:action:target]]

// Will generate a relationship between "source" and the current page with a label of "action"
[[source:action:]]

And transforms it into this shape


// Edge represents a relationship between two nodes
type Edge struct {
	id      string
	Source  string `json:"source"`
	Target  string `json:"target"`
	Context string `json:"context"`
	Label   string `json:"label"`
	FoundIn string `json:"foundIn"`
}

// Node represents a discrete "thing" derived from notes
type Node struct {
	Name       string      `json:"name"`
	Properties interface{} `json:"properties"`
	FileEntry  FileEntry   `json:"fileEntry"`
}

// Graph ...
type Graph struct {
	Nodes      []Node                 `json:"nodes"`
	Edges      []Edge                 `json:"edges"`
	Keys       map[string]bool        `json:"-"`
	Properties map[string]interface{} `json:"properties"`
	Content map[string]string `json:"content"`
	Base string `json:"base"`
}

And serves it over (REST)

GET http:localhost:PORT/graph

And serves it over (Websockets)

// javscript example
let socket = new WebSocket(`ws://${window.location.hostname}:8080/ws`);

socket.onmessage = evt => {
  try {
    const graph = JSON.parse(evt.data);
	console.log(graph) // your graph data
  } catch (e) {
    console.warn(e);
  }
};

So what does this enable?

This is your notes and the relationships you define in those notes as a real time API, do whatever you want with it. Build awesome things. Don't get tied down to any particular editor.

Why

I needed a weekend project.

Because the whole point of using markdown for your files is that it's supposed to be open and platform independent.

As a developer I hate having to figure out how to work with someone else's plugin system for quick extensions / functionality additions,

Example

---
name: Arachne
description: Markdown Powered Knowledge Base API
created: July 2021
---

# What is Arachne?
> Arachne, (Greek: “Spider”) in [[greek/mythology]], the [[Arachne:daughter of:Idmon of Colophon]] in Lydia, a dyer in purple. Arachne was a weaver who acquired such skill in her art that she ventured to challenge Athena, goddess of war, handicraft, and practical reason.
{
  "nodes": [
    {
      "name": "main",
      "properties": {
        "created": "July 2021",
        "description": "Markdown Powered Knowledge Base API",
        "name": "Arachne"
      },
      "fileEntry": {
        "path": "notes/main.md",
        "fileName": "main.md",
        "directory": "notes",
        "updatedAt": 1625440392,
        "root": "./notes"
      }
    },
    {
      "name": "greek/mythology",
      "properties": null,
      "fileEntry": {
        "path": "",
        "fileName": "",
        "directory": "",
        "updatedAt": 0,
        "root": ""
      }
    },
    {
      "name": "Arachne",
      "properties": null,
      "fileEntry": {
        "path": "",
        "fileName": "",
        "directory": "",
        "updatedAt": 0,
        "root": ""
      }
    },
    {
      "name": "Idmon of Colophon",
      "properties": null,
      "fileEntry": {
        "path": "",
        "fileName": "",
        "directory": "",
        "updatedAt": 0,
        "root": ""
      }
    }
  ],
  "edges": [
    {
      "source": "main",
      "target": "greek/mythology",
      "context": "> Arachne, (Greek: “Spider”) in [[greek/mythology]], the [[Arachne:daughter of:Idmon of Colophon]] in Lydia, a dyer in purple. Arachne was a weaver who acquired such skill in her art that she ventured to challenge Athena, goddess of war, handicraft, and practical reason.",
      "label": "",
      "foundIn": "notes/main.md"
    },
    {
      "source": "Arachne",
      "target": "Idmon of Colophon",
      "context": "> Arachne, (Greek: “Spider”) in [[greek/mythology]], the [[Arachne:daughter of:Idmon of Colophon]] in Lydia, a dyer in purple. Arachne was a weaver who acquired such skill in her art that she ventured to challenge Athena, goddess of war, handicraft, and practical reason.",
      "label": "daughter of",
      "foundIn": "notes/main.md"
    }
  ],
  "properties": {
    "main": {
      "created": "July 2021",
      "description": "Markdown Powered Knowledge Base API",
      "name": "Arachne"
    }
  },
  "content": {
    "Arachne": "",
    "Idmon of Colophon": "",
    "greek/mythology": "",
    "main": "---\nname: Arachne\ndescription: Markdown Powered Knowledge Base API\ncreated: July 2021\n---\n\n# What is Arachne?\n> Arachne, (Greek: “Spider”) in [[greek/mythology]], the [[Arachne:daughter of:Idmon of Colophon]] in Lydia, a dyer in purple. Arachne was a weaver who acquired such skill in her art that she ventured to challenge Athena, goddess of war, handicraft, and practical reason.\n"
  },
  "base": "./notes"
}

You'll notice that the above JSON file has some empty fileEntry properties. These are known as "virtual" nodes, and they're nodes that are referenced in notes but have no actual markdown file backing them.

Usage

There are three executable files in the /bin folder in this repo.

macOs = arachne-amd64-darwin
windows = arachne-386.exe
linux = arachne-amd64-linux

Create a config.toml file (must be a sibling to the executable) that looks like the following:

port = "8080"
root = "./notes"

Then in your terminal run (again make sure you're in the same directory as the config.toml file).

./arachne-amd64-darwin

From any browser you can now visit

// Replace port with the port defined in the config file
// default: http://localhost:8080/graph
http://localhost:<PORT>/graph

And you should see a graph representation of your notes.

TODO

  • Better docs
  • Query API
  • User friendly UI for config updates
  • Build cool stuff on top of this
Similar Resources

Convert Microsoft Word Document to Markdown

Convert Microsoft Word Document to Markdown

docx2md Convert Microsoft Word Document to Markdown Usage $ docx2md NewDocument.docx Installation $ go get github.com/mattn/docx2md Supported Styles

Jan 4, 2023

Stylesheet-based markdown rendering for your CLI apps 💇🏻‍♀️

Stylesheet-based markdown rendering for your CLI apps 💇🏻‍♀️

Glamour Write handsome command-line tools with Glamour. glamour lets you render markdown documents & templates on ANSI compatible terminals. You can c

Jan 1, 2023

go-md2man - 转换 Markdown 为 man 手册内容

go-md2man Converts markdown into roff (man pages). Uses blackfriday to process markdown into man pages. Usage ./md2man -in /path/to/markdownfile.md -o

Dec 22, 2022

A PDF renderer for the goldmark markdown parser.

A PDF renderer for the goldmark markdown parser.

goldmark-pdf goldmark-pdf is a renderer for goldmark that allows rendering to PDF. Reference See https://pkg.go.dev/github.com/stephenafamo/goldmark-p

Jan 7, 2023

Markdown to Webpage app

mark2web Markdown to webpage link Usage $ mark2web test.md https://mark2web.test/aa32d8f230ef9d44c3a7acb55b572c8599502701 $ mark2web /tmp/session/test

Apr 18, 2021

Schedule daily tweets from markdown files in your repo, posted via github actions.

markdown-tweet-scheduler Schedule daily tweets from markdown files in your repo, posted to twitter via github actions. Setup Fork this repo Get your t

Dec 6, 2022

Hugo-to-Gemini Markdown converter

Hugo-to-Gemini converter This repo holds a converter of Hugo Markdown posts to text/gemini (also named Gemtext in this README). The converter is suppo

Nov 19, 2022

Parse data and test fixtures from markdown files, and patch them programmatically, too.

go-testmark Do you need test fixtures and example data for your project, in a language agnostic way? Do you want it to be easy to combine with documen

Oct 31, 2022

Automation Tool to auto generate markdown notes from online classes/talks/presentations.

Automation Tool to auto generate markdown notes from online classes/talks/presentations.

autonotes Automation tool to autocapture screenshots and join them with a supplied .srt or .txt file and output a notes file in markdown. Problem? Wat

Aug 29, 2021
Comments
  • panic: runtime error: slice bounds out of range [:74] with capacity 72

    panic: runtime error: slice bounds out of range [:74] with capacity 72

    Getting this error with my Obsidian vault. Is it too big?

    2021/07/06 01:06:40 Starting server on :7777
    panic: runtime error: slice bounds out of range [:74] with capacity 72
    
    goroutine 6 [running]:
    main.makeRelationships(0xc000051bd0, 0xc0002674b2, 0x4e, 0xc000461ce0, 0x2e, 0xc00009fb90, 0xd, 0xc000461ce0, 0x20, 0x60cfa66d, ...)
    	/Users/expero/Projects/athena/graph.go:182 +0x8ca
    main.ParseFile(0xc000051bd0, 0xc000461ce0, 0x2e, 0xc00009fb90, 0xd, 0xc000461ce0, 0x20, 0x60cfa66d, 0xc00001c2e0, 0x1c, ...)
    	/Users/expero/Projects/athena/graph.go:245 +0x2d2
    main.DeriveGraphStructure(0xc000280000, 0x12e, 0x238, 0xc000016180, 0xc00001c2e0, 0x1c)
    	/Users/expero/Projects/athena/graph.go:269 +0x374
    main.StartGraphStructureService(0xc00001c2e0, 0x1c, 0xc000016180)
    	/Users/expero/Projects/athena/graph.go:327 +0x26f
    created by main.main
    	/Users/expero/Projects/athena/main.go:26 +0xe5
    
Markdown - Markdown converter for golang

markdown ?? Talks ?? Join ?? Youtube ❤️ Sponsor Install via nami nami install ma

Jun 2, 2022
Mdfmt - A Markdown formatter that follow the CommonMark. Like gofmt, but for Markdown

Introduction A Markdown formatter that follow the CommonMark. Like gofmt, but fo

Dec 18, 2022
Blackfriday: a markdown processor for Go

Blackfriday Blackfriday is a Markdown processor implemented in Go. It is paranoid about its input (so you can safely feed it user-supplied data), it i

Jan 8, 2023
⚙️ Convert HTML to Markdown. Even works with entire websites and can be extended through rules.
⚙️ Convert HTML to Markdown. Even works with entire websites and can be extended through rules.

html-to-markdown Convert HTML into Markdown with Go. It is using an HTML Parser to avoid the use of regexp as much as possible. That should prevent so

Jan 6, 2023
Produces a set of tags from given source. Source can be either an HTML page, Markdown document or a plain text. Supports English, Russian, Chinese, Hindi, Spanish, Arabic, Japanese, German, Hebrew, French and Korean languages.
Produces a set of tags from given source. Source can be either an HTML page, Markdown document or a plain text. Supports English, Russian, Chinese, Hindi, Spanish, Arabic, Japanese, German, Hebrew, French and Korean languages.

Tagify Gets STDIN, file or HTTP address as an input and returns a list of most popular words ordered by popularity as an output. More info about what

Dec 19, 2022
Upskirt markdown library bindings for Go

Goskirt Package goskirt provides Go-bindings for the excellent Sundown Markdown parser. (F/K/A Upskirt). To use goskirt, create a new Goskirt-value wi

Oct 23, 2022
A CLI markdown converter written in Go.

MDConv is a markdown converter written in Go. It is able to create PDF and HTML files from Markdown without using LaTeX. Instead MDConv u

Dec 20, 2022
A markdown renderer package for the terminal
A markdown renderer package for the terminal

go-term-markdown go-term-markdown is a go package implementing a Markdown renderer for the terminal. Note: Markdown being originally designed to rende

Nov 25, 2022
A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.

goldmark A Markdown parser written in Go. Easy to extend, standards-compliant, well-structured. goldmark is compliant with CommonMark 0.29. Motivation

Dec 29, 2022
:triangular_ruler:gofmtmd formats go source code block in Markdown. detects fenced code & formats code using gofmt.
:triangular_ruler:gofmtmd formats go source code block in Markdown. detects fenced code & formats code using gofmt.

gofmtmd gofmtmd formats go source code block in Markdown. detects fenced code & formats code using gofmt. Installation $ go get github.com/po3rin/gofm

Oct 31, 2022