mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
add a brief architecture file
This commit is contained in:
parent
fc0035306c
commit
ecd207bf26
2 changed files with 35 additions and 8 deletions
35
docs/architecture.md
Normal file
35
docs/architecture.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Anki Architecture
|
||||
|
||||
Very brief notes for now.
|
||||
|
||||
## Backend/GUI
|
||||
|
||||
At the highest level, Anki is logically separated into two parts.
|
||||
|
||||
### Library
|
||||
|
||||
The Python library (pylib) exports "backend" methods - opening collections,
|
||||
fetching and answering cards, and so on. It is used by Anki’s GUI, and can also
|
||||
be included in command line programs to access Anki decks without the GUI.
|
||||
|
||||
The library is accessible in Python with "import anki". Its code lives in
|
||||
the `pylib/anki/` folder.
|
||||
|
||||
These days, the majority of backend logic lives in a Rust library (rslib, located in `rslib/`). Calls to pylib proxy requests to rslib, and return the results.
|
||||
|
||||
pylib contains a private Python module called rsbridge (`pylib/rsbridge/`) that wraps the Rust code, making it accessible in Python.
|
||||
|
||||
### GUI
|
||||
|
||||
Anki's *GUI* is a mix of Qt (via the PyQt Python bindings for Qt), and
|
||||
TypeScript/HTML/CSS. The Qt code lives in `qt/aqt/`, and is importable in Python
|
||||
with "import aqt". The web code is split between `qt/aqt/data/web/` and `ts/`,
|
||||
with the majority of new code being placed in the latter, and copied into the
|
||||
former at build time.
|
||||
|
||||
## Protobuf
|
||||
|
||||
Anki uses Protocol Buffers to define backend methods, and the storage format of
|
||||
some items in a collection file. The definitions live in `proto/anki/`.
|
||||
|
||||
The Python/Rust bridge uses them to pass data back and forth, and some of the TypeScript code also makes use of them, allowing data to be communicated in a type-safe manner between the different languages.
|
|
@ -215,14 +215,6 @@ will fail with a "no such file or directory node_modules/anki" message.
|
|||
|
||||
You can run bazel with '-s' to print the commands that are being executed.
|
||||
|
||||
## Subcomponents
|
||||
|
||||
- pylib contains a Python module (anki) with the non-GUI Python code,
|
||||
and a bridge to the Rust code.
|
||||
- qt contains the Qt GUI implementation (aqt).
|
||||
- rslib contains the parts of the code implemented in Rust.
|
||||
- ts and qt/aqt/data/web contain Anki's typescript and sass files.
|
||||
|
||||
## Environmental Variables
|
||||
|
||||
If ANKIDEV is set before starting Anki, some extra log messages will be printed on stdout,
|
||||
|
|
Loading…
Reference in a new issue