kosolabs / koso

Make a plan with Koso.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Development Environment (MacOS)

First Time Setup

  1. Install Homebrew.

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install PostgreSQL.

    brew install postgresql@16
  3. Start PostgreSQL.

    brew services start postgresql@16
  4. Install Rust.

    brew install rustup
    rustup-init
  5. The backend uses SQLx to interact with PostgreSQL. Install the SQLx in order to run migrations and perform other administrative operations.

    cargo install sqlx-cli --no-default-features --features rustls,postgres
  6. Configure SQLx with the DATABASE_URL.

    export DATABASE_URL=postgresql://localhost/koso

    Also, add the environment variable to the appropriate profile file (~/.profile, ~/.bash_profile, ~/.bashrc, ~/.zshrc, ~/.zshenv) so you don't have to run it every time.

  7. Create the database and run the DB migrations.

    In the backend folder, run:

    sqlx database create
    sqlx migrate run
  8. Install Node.js.

    brew install node
  9. Install the frontend dependencies.

    In the frontend folder, run:

    npm install

Start Backend and Frontend

  1. Start the backend server.

    In the backend folder, run:

    cargo run
  2. Start the frontend server.

    In the frontend folder, run:

    npm run dev
  3. Navigate to http://localhost:5173/

VS Code

The Koso Workspace is configured for development in VS Code.

The following plugins are recommended:

DB Migrations

Add a migration:

sqlx migrate add some-meaningful-name

Run migrations

sqlx migrate run

Backend Interactions

Once a server has been started, you can interact with it at http://localhost:3000. There are example requests in koso.http which you can run with REST Client.

Backend Auto-reload

Tired of manually restarting your server after editing the code? Use systemfd and cargo-watch to automatically recompile and restart the server whenever the source code changes. It uses listenfd to be able to migrate connections from an old version of the app to a newly-compiled version.

One time setup:

cargo install cargo-watch systemfd

Running:

systemfd --no-pid -s http::3000 -- cargo watch -x run

Running a Built Frontend with the Backend

This setup is similar to how the app will run in production. A single server serves the API, WebSocket, and static frontend files.

  1. In the frontend folder, run:

    npm run build
  2. In the backend folder, run the server:

    systemfd --no-pid -s http::3000 -- cargo watch -x run

This will create a frontend/build folder. The backend/static folder is symlinked to that folder and will serve the compiled frontend directly from the backend.

About

Make a plan with Koso.


Languages

Language:Svelte 36.9%Language:Rust 35.0%Language:TypeScript 24.4%Language:JavaScript 1.7%Language:CSS 0.9%Language:PLpgSQL 0.7%Language:Shell 0.3%Language:HTML 0.2%