Skip to content

Repository files navigation

Go!

A crowdsourced search service, built with Rust and SQLite.

Getting Started

Rust

See main.rs and Cargo.toml

Go! is built using Rust, you can install it - and other toolchain components - with rustup:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Some sane defaults might be as follows:

rustup default 1.85.0
rustup component add rust-analyzer

Using Cargo as the de-facto Rust package-manager and build-tool, running the application is then simply:

cargo run

SQLx

See schema.rs and model.rs

Go! uses SQLx for managing database migrations, you can install it with cargo:

cargo install sqlx-cli

After installing, migrations can be added to migrations, and managed using the sqlx command:

sqlx db create
sqlx migrate run
    <!> oh no <!>
sqlx migrate revert

However, using these migrations will require configuring SQLx to run with extensions.

While SQLx can provide compile-time checks of SQL queries, this feature is only available through the provided macros; these suffer some ergonomic downsides which the gains do not justify.

SQLite

See schema.rs

Go! uses SQLite as the SQL database engine of choice - it's quick enough, runs locally to minimise required infrastructure, and allows backups to be as trivial as a single file copy.

SQLite Extensions

Go also leverages the following extensions:

  • The sqlite-vec extension vec0 allows for vector-search queries within SQLite.
  • The sqlite-lembed extension vec0 allows for vector-embeddings within SQLite queries.

These combnined allow

Askama

See template.rs and templates

Go! uses server-side template rendering from Askama.

Jinja-like syntax is used to build HTML templates:

<div id="paged-links">
    <div id="links-content">
        {% for link in links %}
        {%- include "links/view.html" -%}
        {% endfor %}
    </div>
    <div id="paging">
        {%- include "utils/paging.html" -%}
    </div>
</div>

These templates are then bound to Rust structs:

#[derive(Template)]
#[template(path = "paged-links.html")]
pub struct PagedLinksTemplate {
    pub links: Vec<Link>,
    pub paging: Paging,
}

Askama provides type-checking of templates at compile-time.

HTMX

See templates and route.rs

Go! adds interactivity to frontend pages using HTMX.

This is generally achieved through HTTP requests which recieve HTML fragment responses, which are swapped in and out of the DOM.

Bootstrap

Go! uses Bootstrap as a component library and UI toolkit, allowing components to be styled easily and consistently without resorting to CSS fragments.

Bootstrap provides a vast array of CSS classes that can be combined to achieve most common web-app usecases, e.g. a radio button group with:

<div class="btn-group" role="group" aria-label="Basic radio toggle button group">
  <input type="radio" class="btn-check" name="btnradio" id="btnradio1" autocomplete="off" checked>
  <label class="btn btn-outline-primary" for="btnradio1">Radio 1</label>

  <input type="radio" class="btn-check" name="btnradio" id="btnradio2" autocomplete="off">
  <label class="btn btn-outline-success" for="btnradio2">Radio 2</label>

  <input type="radio" class="btn-check" name="btnradio" id="btnradio3" autocomplete="off">
  <label class="btn btn-outline-danger" for="btnradio3">Radio 3</label>
</div>

About

A crowdsourced search service, built with Rust and SQLite.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages