- Rust 51%
- Vue 18.5%
- TypeScript 14.3%
- CSS 7.3%
- Shell 6%
- Other 2.9%
| bitlets/list-orders | ||
| blas | ||
| client | ||
| docs | ||
| libs | ||
| tools | ||
| generate_keys | ||
| README.md | ||
Lensa Project
Lensa is a hybrid architecture designed to execute most of the business logic directly in the user's web browser using WebAssembly (WASM). This approach reduces cloud costs and environmental impact. Operations such as SQL query generation, encryption, and data processing are handled in the client, minimizing server-side computation.
How It Works
Lensa is built on three main components:
1. Bitlets
Bitlets are WebAssembly modules written in Rust that encapsulate business logic. They are compiled in two formats:
wasm32-unknown-unknownfor execution in the browser.wasm32-wasip2for execution on the backend (Blas).
A bitlet can generate a SQL query on the client, encrypt it, and send it to the Blas server where it is validated and executed against the database.
2. Blas (Backend)
A secure HTTP/S server that exposes REST endpoints and is responsible for:
- Executing WASI bitlets to validate and run SQL.
- Communicating with the database.
- Verifying authentication and authorization using secure cookies and tokens.
3. Web Client
A Single Page Application (SPA) built with any framework (Vue, React, Svelte, etc). From the client:
- Bitlets are loaded and executed.
- Login and refresh are handled automatically using secure cookies.
- The results of SQL queries processed by the bitlets are displayed.
Security and Encryption
All communication between bitlets (client) and Blas is:
- End-to-end encrypted using embedded asymmetric keys.
- Protected by an authentication system based on access and refresh tokens (handled with
HttpOnly,Secure, andSameSitecookies).
Project Structure
bitlets/ # Contains all WASM modules (bitlets)
blas/ # HTTPS server and SQL validation + execution
client/ # Web application client (framework agnostic)
docs/ # Project documentation
generate_keys/ # Utility to generate asymmetric key pairs
libs/ # Shared libraries between bitlets and Blas
tools/ # Build tools and scaffolding helpers
Future Plans and TODOs
- Create a CLI tool (
lensa-cli) that:- Generates scaffolding for new bitlets and clients.
- Compiles WASM targets for both web and WASIP2.
- Automatically builds the
keys.rsfile with asymmetric keys. - Prepares everything for local or cloud deployment.
Getting Started
1. Generate Asymmetric Keys
Run:
./generate_keys
This will create the file libs/lib-crypto/src/keys.rs with the keys used by both bitlets and Blas.
2. Build Bitlets
Inside the tools/ folder there is a helper script to compile any bitlet:
./tools/build.sh --target web --mode release
./tools/build.sh --target wasi --mode release
This script should be copied into the bitlet folder and executed from there.
3. Compile the Blas Backend
Use the script:
./tools/build_blas.sh --mode release