Learn Anything
Explanation of project's high level goals is here.
Current focus is on making Tauri app working. Essentially an app like Obsidian.
Reference file structure to make sense of how code is laid out in the repo.
Read setup to get started with development.
Sharing current tasks in readme until MVP is released.
Ask questions on Discord if interested in developing the project or you get issues with setup.
File structure
- api - server related actions
- db - EdgeDB used as main server database
- dbschema
- default.esdl - EdgeDB schema definining all the models and relations
- migrations - migration files get generated after running
pnpm db:migrate
- client.ts - exports client to connect with EdgeDB
- topic.ts / user.ts - CRUD functions on models
- dbschema
- grafbase - Grafbase provides GraphQL API layer for all server functions like talking with DB
- resolvers - edge resolvers are server functions exposed with GraphQL
- schema.graphql - Grafbase's config
- server - temporary hono server until grafbase supports public resolvers
- db - EdgeDB used as main server database
- app - desktop app in Tauri/Solid
- lib - shared utility functions
- test - test cases (useful for itereating quickly)
- website - learn-anything.xyz website code in Solid
- components - solid components
- routes - routes defined using file system
Setup
This project is a monorepo setup using pnpm workspaces.
Everything is driven using pnpm ..
commands. First run:
pnpm i
pnpm dev-setup
pnpm dev-setup
will git clone
seed repo. It's needed for dev setup + test suite to work.
Run Tauri app
to complete
Moving code from Electron version.
Check tasks.
Useful DevTools panel
In the app you get after running pnpm app:dev
, you will see DevTools panel in bottom right corner. It contains a list of useful actions you can run to aid you.
One of the actions is Seed TinyBase
. This will seed your local TinyBase store/sqlite with one of the wikis in seed folder.
Read app/packages/preload/src/index.ts file for details. syncWikiFromSeed
is the function.
Test
pnpm test
Will run tests found in test.
test/wiki.test.ts file tests markdown file parsing.
Running code via tests is very effective. You can open terminal on your right and edit code on the left and on each .ts
file save it will rerun the test and check if behavior you are testing is correct. Reading through the test suite is great way to understand the backend part of the app.
Setup EdgeDB
First need to make Electron + TinyBase + Solid sync work smoothly. Check ## Tasks
Assumes you installed EdgeDB (run curl ..
command).
pnpm db:init
Follow instructions, name EdgeDB instance learn-anything
.
Run edgedb ui
. This will open EdgeDB graphical interface where you can run queries or explore the schema.
Run below command to apply the schema defined in default.esdl on your local DB:
pnpm db:watch
Then, generate EdgeDB TS bindings with:
pnpm db:ts-generate
Run server
First need to make Electron + TinyBase + Solid sync work smoothly. Check ## Tasks
Before running server, create file at api/server/.env
with this content:
EDGEDB_INSTANCE=learn-anything
EDGEDB_SECRET_KEY=edbt_ey
EDGEDB_SECRET_KEY
can be gotten by running pnpm db:ui
which will open the EdgeDB UI.
In terminal after running above command you will see url like http://localhost:10700/ui?authToken=edbt_ey
. EDGEDB_SECRET_KEY
is the authToken content.
Then run:
pnpm api
In future Grafbase will be used for all API requests. There is blocker there that you can't do both public and private resolvers.
pnpm api:grafbase
Will start Grafbase locally and give you GraphQL access.
Run web
First need to make Electron + TinyBase + Solid sync work smoothly. Check ## Tasks
Create .env
file inside website with this content:
VITE_HANKO_API=https://e879ccc9-285e-49d3-b37e-b569f0db4035.hanko.io
API_OF_GRAFBASE=http://127.0.0.1:4000/graphql
Hanko is used as auth provider. You can swap Hanko API variable content with one from a project you create yourself.
Run:
pnpm web:dev
Contribute
The tasks to do are outlined below.
If you are interested in helping out, please join Discord and let's make it happen.
The project is incredibly ambitious once it works.
Tasks
sorted by priority
- make app work with Tauri
- this app used electron before but it had issues when trying to deploy it, code for it here
- add sqlite persistence
- what tinybase did in electron version
- move markdown parser from ts to rust
- use markdown-rs
- hardlink
lib
folder fromapp
andwebsite
solib
functions can actually be used when deploying - load nikita's wiki into tinybase/sqlite and run queries, check in app, all data is there correctly
pnpm ts-run
will run run.ts file that has code to load things into tinybase from seed/wiki/nikita
- make test/wiki.test.ts test pass (partly done, trying to load nikita's wiki and see what breaks)
- add tests for files that break into test suite with proper
expect
checks
- add tests for files that break into test suite with proper
- electron app close to Obsidian/Reflect in UX
- be able to edit markdown files, show sidebar of files/folders on the left
- sync up with file system, using watcher package most likely
- everything nicely persisted to tinybase with solid.js store syncing working well
- test well
- setup proper code sharing between monorepo packages
- there is
lib
andcomponents
folders at root- should be usable across all the mono repo
- the way packages are imported should be thought out well
- which packages get installed at root? which go to specific package?
- there is
- would be nice if app/packages did not exist potentially
- just don't think app/packages is nice structure, maybe move everything into app/
- afraid to modify it as it came from template and moving things will break
- in dev tools panel when you click on
Seed TinyBase (default)
, it seeds with default files- also add
Seed TinyBase (custom)
, then provide an option of folders to choose what to seed so users can provide custom folders to seed quickly
- also add
- is there need for app/packages/electron-web/package.json?
- or app/package.json is enough
- it's all the same bundle I would think
- VSCode does not automatically suggest imports from lib folder (super annoying)
Better DX
- Setup devenv to get one command dev env install. Currently we ask to install EdgeDB manually for example.
- Can potentially use only one codebase for both web code and electron app renderer code, using vite-plugin-ssr.
- Electron expects
index.html
file as entry but Solid Start does not provide aindex.html
file. At least I don't know how to make that work so for now its split up. The app is quite different to the website in features so it's even for the best.
- Electron expects
Notes
to be moved to docs/ and deployed with vitepress later
- Text editor once used Solid CodeMirror. Similar to CodeImage project. But there were issues in making it work nicely. So now Monaco Editor is used.
- Inlang, CodeImage, Actual have great code to take inspiration from.
- Inlang's tech stack specifically is very great.