atomic-server 0.13.0

Create, share and standardize linked atomic data!
atomic-server-0.13.0 is not a library.
Visit the last successful build: atomic-server-0.40.1

atomic-server

crates.io Discord chat MIT licensed

Status: alpha, not ready for production usage. Can panic at runtime.

The easiest way to share Atomic Data on the web. Demo on atomicdata.dev

  • No runtime dependencies, fast, runs on all platforms (including on your Raspberry Pi)
  • Embedded HTTP / HTTPS / HTTP2.0 server
  • Serialization to HTML, JSON, Linked Data (RDF/XML, N-Triples / Turtle / JSON-LD) and AD3

Powered by Rust, atomic_lib, actix-web, Sled and more.

Progress

  • Respond to GET request for individual resources
  • HTML serialization
  • JSON serialization
  • JSON-LD serialization
  • AD3 serialization
  • RDF (Turtle / N-Triples) serialization
  • Basic error handling
  • TPF endpoint
  • Homepage
  • Static asset support for .css / .ico / etc.
  • HTTPS (WIP, kind of working)
  • Content-type negotiation
  • Basic design / use CSS framework
  • Eliminate all preventable runtime panics (most already done)
  • URL extension recognition (.json, .ad3, .nt, etc.)
  • Collections / dynamic resources #17
  • Write / Mutations support (might need #16)
  • Auth support (WebID-OICD possibly?) #13
  • Be able to manage the AtomicData.dev website without git

Install from source

Install Cargo to build from source.

git clone git@github.com:joepio/atomic.git
cd atomic/server
# Create a new .env using the template
cp default.env .env
# Run the server. It creates a store in ~/.config/atomic/db by default
cargo run
# Visit http://localhost:8080/test
  • Run atomic-server inside a directory with /static folder for files
  • If you want to use HTTPS / TLS, set ATOMIC_CERT_INIT to true and run the server. After that, set it to false and set ATOMIC_HTTPS to true.
  • If no .ad3 store path is given, a new store will be created from memory.

Running from cargo

You can also install with cargo install atomic-server, but this binary will also require:

  • the .env from this repo, although the defaults should work just fine.
  • the /templates directory
  • the /static directory

Usage

Get individual resources

You can fetch individual items by sending a GET request to their URL.

# Fetch as AD3 triples
curl -i -H "Accept: application/ad3-ndjson" http://127.0.0.1:8081/test
# Fetch as JSON-LD
curl -i -H "Accept: application/ld+json" http://127.0.0.1:8081/test
# Fetch as JSON
curl -i -H "Accept: application/json" http://127.0.0.1:8081/test
# Fetch as Turtle / N3
curl -i -H "Accept: text/turtle" http://127.0.0.1:8081/test

Query the store with Triple Pattern Fragments

# Fetch as AD3 triples
curl -i -H "Accept: application/ad3-ndjson" "http://127.0.0.1:8081/tpf?subject=&property=&value=test"

HTTPS Setup

You'll probably want to make your Atomic Data available through HTTPS. You can use the embedded HTTPS / TLS setup powered by LetsEncrypt, acme_lib and rustls. To setup HTTPS, we'll need to set some environment variables. Open .env and set:

ATOMIC_EMAIL=youremail@example.com
ATOMIC_DOMAIN=example.com

Run the server cargo run. Make sure the server is accessible at ATOMIC_DOMAIN at port 80, because Let's Encrypt will send an HTTP request to this server's /.well-known directory to check the keys. It will now initialize the certificate. Read the logs, watch for errors.

Note that there is no logic yet for renewing certificates - I think removing the generated .https folder is the easiest approach.

Testing

# This also makes sure that cli and server work, plus it test the db feature
cargo test --all

Performance benchmarking

# Install drill
cargo install drill
drill -b benchmark.yml --stats