LogSeq: Personal Knowledge Graphs with DB power

Volodymyr Pavlyshyn
5 min readSep 23, 2023

--

Intro

Logseq is a privacy-first, open-source platform for knowledge management and collaboration. It combines the best of both worlds: the non-linear structure of a Zettelkasten and the hierarchical organization of traditional note-taking apps. In this article, we’ll delve into the various features of Logseq and explore its myriad use cases. We’ll also analyze why it stands out in the crowded space of note-taking and knowledge management tools.

Git hub repo is hiden gem itself for a clojure and lisp developers. The code is open GIT ogseq

How it differ from Obsidian ?

  • Logseq code is open
  • Logseq is outliner app focused on blocks vs Obsidian more focus on logform and notes
  • Logseq.is design around database with a datalog and graphs
  • it is support markdown and org mode files

Features

PRIVACY-CENTRIC

Logseq’s privacy-first approach ensures that your data remains yours. All your notes and files are stored locally on your device, and you have the option to sync them with your own cloud storage services like GitHub or Dropbox. This feature aligns well with the growing concern for data privacy.

MARKDOWN AND ORG MODE SUPPORT

For those who are familiar with Markdown or Emacs Org Mode, Logseq offers native support for both. This makes it incredibly flexible for users coming from different text-editing backgrounds.

BI-DIRECTIONAL LINKING

One of the standout features is bi-directional linking, which allows you to connect ideas and notes effortlessly. This is particularly useful for creating a network of related concepts, aiding in more effective knowledge retrieval.

GRAPH VIEW

Logseq provides a graph view that visually represents the connections between your notes. This is not just aesthetically pleasing but also functionally beneficial for understanding the structure and relationships within your knowledge base.

TASK MANAGEMENT

Logseq isn’t just for note-taking; it’s also a capable task manager. You can create to-dos, set deadlines, and even prioritize tasks, making it a versatile tool for both personal and professional use.

DATA BASE AND DATALOG

You could turn you notes to a full queriable data base with a data log. It is open endless uscases

Query sample

{:title  [:h2 "Your query title"]
:query [:find (pull ?b [*])
:where ...]
:inputs [...]
:view (fn [query-result] [:div ...]) ;; or :keyword from config.edn
:result-transform (fn [query-result] ...) ;; or :keyword from config.edn
:collapsed? true
:group-by-page? true
:remove-block-children? true
:rules [...]}

Data base schema it is simple you have 2 entities

  • pages
  • propertiers
  • blocks
  • page
  • properties
  • priorities
  • tasks
  • parent
{:title "Journal blocks in last 7 days with a page reference of datalog"
:query [:find (pull ?b [*])
:in $ ?start ?today ?tag
:where
(between ?b ?start ?today)
(page-ref ?b ?tag)]
:inputs [:-7d :today "datalog"]}

Data Schema

(ns logseq.db.schema
"Main db schema for the Logseq app")
(defonce version 2)
(defonce ast-version 1)
;; A page is a special block, a page can corresponds to multiple files with the same ":block/name".
(def ^:large-vars/data-var schema
{:schema/version {}
:ast/version {}
:db/type {}
:db/ident {:db/unique :db.unique/identity}
:recent/pages {} ;; :block/type is a string type of the current block
;; "whiteboard" for whiteboards
;; "macros" for macro
:block/type {}
:block/uuid {:db/unique :db.unique/identity}
:block/parent {:db/valueType :db.type/ref
:db/index true}
:block/left {:db/valueType :db.type/ref
:db/index true}
:block/collapsed? {:db/index true}
;; :markdown, :org
:block/format {}
;; belongs to which page
:block/page {:db/valueType :db.type/ref
:db/index true}
;; reference blocks
:block/refs {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
;; referenced pages inherited from the parents
:block/path-refs {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
;; for pages
:block/tags {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
;; for pages
:block/alias {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
;; full-text for current block
:block/content {}
;; todo keywords, e.g. "TODO", "DOING", "DONE"
:block/marker {}
;; "A", "B", "C"
:block/priority {}
;; map, key -> set of refs in property value or full text if none are found
:block/properties {}
;; vector
:block/properties-order {}
;; map, key -> original property value's content
:block/properties-text-values {}
;; first block that's not a heading or unordered list
:block/pre-block? {}
;; scheduled day
:block/scheduled {}
;; deadline day
:block/deadline {}
;; whether blocks is a repeated block (usually a task)
:block/repeated? {}
:block/created-at {}
:block/updated-at {}
;; page additional attributes
;; page's name, lowercase
:block/name {:db/unique :db.unique/identity}
;; page's original name
:block/original-name {:db/unique :db.unique/identity}
;; whether page's is a journal
:block/journal? {}
:block/journal-day {}
;; page's namespace
:block/namespace {:db/valueType :db.type/ref}
;; macros in block
:block/macros {:db/valueType :db.type/ref
:db/cardinality :db.cardinality/many}
;; block's file
:block/file {:db/valueType :db.type/ref}
;; file
:file/path {:db/unique :db.unique/identity}
;; only store the content of logseq's files
:file/content {}
:file/handle {}
;; :file/created-at {}
;; :file/last-modified-at {}
;; :file/size {}
;; :file/handle {}
})
(def retract-attributes
#{
:block/refs
:block/tags
:block/alias
:block/marker
:block/priority
:block/scheduled
:block/deadline
:block/repeated?
:block/pre-block?
:block/type
:block/properties
:block/properties-order
:block/properties-text-values
:block/macros
:block/invalid-properties
:block/created-at
:block/updated-at
:block/warning
}
)
;;; use `(map [:db.fn/retractAttribute <id> <attr>] retract-page-attributes)`
;;; to remove attrs to make the page as it's just created and no file attached to it
(def retract-page-attributes
#{:block/created-at
:block/updated-at
:block/file
:block/format
:block/content
:block/properties
:block/properties-order
:block/properties-text-values
:block/invalid-properties
:block/alias
:block/tags})

I recomend you try logseq just to try datalog

Plugin System

Logseq as same as obsidian support a extending it self via plugins. You could find a lot of community plugins but ecosystem is much smaller that Obsidian

Use Cases

ACADEMIC RESEARCH

Logseq’s features like bi-directional linking and graph view make it an excellent tool for academic research. You can easily connect related papers, theories, and ideas, creating a rich tapestry of interconnected knowledge.

SOFTWARE DEVELOPMENT

For software developers, Logseq can serve as a repository for storing code snippets, architectural decisions, and project documentation. Its Markdown support makes it easy to format code blocks and technical specifications.

PERSONAL KNOWLEDGE MANAGEMENT

From book summaries to cooking recipes, Logseq can handle a wide range of personal knowledge management needs. Its privacy-centric approach ensures that your personal information remains secure.

TEAM COLLABORATION

Although primarily designed for individual use, Logseq’s GitHub integration allows for collaborative editing, making it a potential tool for team-based projects.

Why Logseq?

The combination of privacy, flexibility, and powerful features makes Logseq a compelling choice for anyone looking to manage their knowledge more effectively. Its open-source nature also means that it’s continually evolving, with a community of developers contributing to its growth.

Conclusion

Logseq is more than just a note-taking app; it’s a versatile platform for knowledge management and collaboration. Whether you’re an academic researcher, a software developer, or someone looking to organize your thoughts more coherently, Logseq offers a range of features to meet your needs.

--

--

Volodymyr Pavlyshyn

I believe in SSI, web5 web3 and democratized open data.I make all magic happens! dream & make ideas real, read poetry, write code, cook, do mate, and love.