Accessing the local database
There are two databases in local and on remote and they sync via HTTP(S). The Inkdrop client app is built on top of a PouchDB for storing data in local and syncing with the remote database. For many parts of the application, the database is the source of truth.
Data is written to the local database first, then synced with the remote database, and changes to the database trigger Actions, Stores and components to refresh their contents. The illustration below shows this flow of data:

Accessing the data from plugins
env.localDB — available on the Environment passed to activate(env) — is a proxy to the local database, which lives in the main process. It provides a bunch of useful methods that help you manage notes, notebooks, tags and files, plus utilities and change events.
For example, below code gets data directly from the local database:
const db = env.localDB
// Get a note data by note ID
const note = await db.notes.get('note:F8xUp-23G')
// Get all notebooks
const books = await db.books.all()
// Get notes in a notebook
const notesInBook = await db.notes.findInBook(books[0]._id)
// Search notes with keywords
const result = await db.utils.search('Foobar')
const { docs } = result
console.log('Search result:', docs)
Resources
Local HTTP server
The Inkdrop client app can open a simple HTTP server so that you can access the data from an external program easily.
Accessing via HTTP
Moved to the Integrate with External Programs guide.