Skip to content

Commit c727b27

Browse files
committed
Minor: a few more coffee tutorial tweaks.
1 parent a7af9ee commit c727b27

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

docs/src/content/docs/getting-started/first-ui-app.mdx

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ title: >
66
import { Code } from "@astrojs/starlight/components";
77
import { Aside } from "@astrojs/starlight/components";
88

9-
In this tutorial, we'll set up a coffee database, implement a custom TypeScript
10-
HTTP handler for performing vector searches, and a simple production-ready web app
11-
all in ~100 lines of code.
12-
9+
In this tutorial, we'll bootstrap a database with a coffee data, implement a
10+
custom TypeScript HTTP handler for finding the best coffee matches using vector
11+
search, and deploy a simple production-ready web app all in ~100 lines of code.
1312

1413
<div class="flex justify-center">
1514
<div class="w-[80%] shadow-lg ">
@@ -19,8 +18,8 @@ all in ~100 lines of code.
1918

2019
<div class="h-[24px]" />
2120

22-
This introductory tutorial is part of the main TrailBase code repository, which
23-
you can download to follow along running:
21+
This introductory tutorial is part of TrailBase's main code repository, which
22+
can be downloaded to follow along by running:
2423

2524
```bash
2625
$ git clone https://github.com/trailbaseio/trailbase.git
@@ -36,7 +35,8 @@ import GettingTrailBase from "./_getting_trailbase.md";
3635
## Importing Data
3736

3837
We'll use the `sqlite3` CLI directly to import
39-
`examples/coffeesearch/arabica_data_cleaned.csv` with the following SQL script[^1]:
38+
`examples/coffeesearch/arabica_data_cleaned.csv` with the following SQL
39+
script[^1]:
4040

4141
```sql
4242
-- First create the strictly typed "coffee" table.
@@ -72,47 +72,47 @@ FROM temporary;
7272
DROP TABLE temporary;
7373
```
7474

75-
Note that we didn't initialize the vector `embedding`. This is because the
76-
`sqlite3` CLI doesn't have the necessary extensions built-in.
77-
We'll update the entries to add the embedding later as part of a TrailBase
78-
migration.
75+
Note that we didn't initialize the vector `embedding`. This is merely because
76+
`sqlite3` doesn't have the necessary extensions built-in.
77+
We'll update the entries to add the embedding later as part of our initial
78+
database migrations shortly[^2].
7979

80-
While in `example/coffeesearch`, you can run
80+
From within the `example/coffeesearch` directory, you can execute the script
81+
above and import the coffee data by running:
8182

8283
```bash
8384
$ cat import.sql | sqlite3 traildepot/data/main.db -
8485
```
8586

86-
to execute above script.
87-
88-
After the initial data import and still in the same directory, let's start the
89-
`trail` binary for the first time:
87+
After importing the data while still in the same directory, we can start the
88+
`trail` server:
9089

9190
```bash
9291
$ trail run
9392
```
9493

95-
This will apply the migrations under `examples/coffeesearch/traildepot/migrations`, basically
94+
Because `trail` starts for the first time the migrations in
95+
`traildepot/migrations` will be applied, which are essentially:
9696

9797
```sql
9898
UPDATE coffee SET embedding = VECTOR(FORMAT("[%f, %f, %f, %f]", Aroma, Flavor, Acidity, Sweetness));
9999
```
100100

101-
to initialize the previously missing `coffee.embedding` for all records.
101+
initializing the previously skipped `coffee.embedding` for all records.
102102

103103

104104
## Custom TypeScript Endpoint
105105

106-
Starting `trail` also executes JavaScript and TypeScript files under
107-
`traildepot/scripts`.
106+
Any time you start `trail run`[^3], JavaScript and TypeScript files under
107+
`traildepot/scripts` will be executed.
108108

109109
<Aside type="note">
110110
TrailBase will automatically transpile TypeScript to JavaScript which can
111111
then execute on the underlying V8 engine. You don't need a separate build
112112
step.
113113
</Aside>
114114

115-
We can use this to register custom HTTP endpoints among other things.
115+
We can use this to register custom HTTP API routes among other things.
116116
Let's have a quick look at `examples/coffeesearch/traildepot/scripts/main.ts`,
117117
which defines a `/search` API route we'll later use in our application to
118118
find coffees most closely matching our desired coffee notes:
@@ -200,7 +200,7 @@ You can now check out your fuly self-contained app under
200200
[http://localhost:4000/](http://localhost:4000/) or browse the coffee data in
201201
the [admin dashboard](http://localhost:4000/_/admin).
202202

203-
All we need to serve our application in production is[^2]:
203+
All[^4] we need to serve our application in production is:
204204

205205
- the static `trail` binary,
206206
- the `traildepot` folder containing the data and endpoints,
@@ -221,9 +221,9 @@ $ docker build -t coffee . && docker run -p 4000:4000 coffee
221221
will speed-run this entire tutorial by building and starting the app listening
222222
at [http://localhost:4000/](http://localhost:4000/).
223223

224-
That's it. We hope this was a fun little introduction showcasing some of
225-
TrailBase's features. If you have any feedback, don't hesitate and reach
226-
out on [GitHub](https://github.com/trailbaseio/trailbase).
224+
That's it. We hope this was a fun little showcase of some of TrailBase's
225+
features. If you have any feedback, don't hesitate and reach out on
226+
[GitHub](https://github.com/trailbaseio/trailbase).
227227

228228
<div class="h-[50px]" />
229229

@@ -235,6 +235,17 @@ out on [GitHub](https://github.com/trailbaseio/trailbase).
235235
[download](https://www.sqlite.org/download.html) pre-built binaries
236236

237237
[^2]:
238+
Migrations are versioned SQL scripts that will be executed by the database
239+
on first encounter to programmatically and consistently evolve your database
240+
schema and data along with your code.
241+
For example, when you add a new column you'll likely want all your
242+
integration tests, development setups, and production deployments to add
243+
the column so your application logic has a consistent schema to target.
244+
245+
[^3]:
246+
Unless explicitly disabled.
247+
248+
[^4]:
238249
To serve HTTPS you'll either need a reverse proxy in front to terminate TLS
239250
or if you don't require end-to-end encryption (e.g. you're not using auth
240251
or handling sensitive data) you can fall back to TLS termination via a CDN

0 commit comments

Comments
 (0)