![Banner](https://astra.arkforge.net/banner.png)

[![Release Linux](https://github.com/ArkForgeLabs/Astra/actions/workflows/linux_release.yml/badge.svg)](https://github.com/ArkForgeLabs/Astra/actions/workflows/linux_release.yml)
[![Release Windows](https://github.com/ArkForgeLabs/Astra/actions/workflows/windows_release.yml/badge.svg)](https://github.com/ArkForgeLabs/Astra/actions/workflows/windows_release.yml)
[![Release MacOS](https://github.com/ArkForgeLabs/Astra/actions/workflows/macos_release.yml/badge.svg)](https://github.com/ArkForgeLabs/Astra/actions/workflows/macos_release.yml)
[![Publish the crate](https://github.com/ArkForgeLabs/Astra/actions/workflows/crates_io_publish.yml/badge.svg)](https://github.com/ArkForgeLabs/Astra/actions/workflows/crates_io_publish.yml)
[![Static Badge](https://img.shields.io/badge/Read_The_Docs-blue?style=flat&logo=docsdotrs&color=%23000000)](https://astra.arkforge.net)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Matrix Chat](https://img.shields.io/badge/Chat-Matrix-blue.svg)](https://matrix.to/#/#Astra:matrix.org)

>[!NOTE]
>The code is hosted at [git.arkforge.net/ArkForgelabs/Astra](https://git.arkforge.net/ArkForgeLabs/Astra). The GitHub repository is a mirror. For opening [issues](https://git.arkforge.net/ArkForgeLabs/Astra/issues) and [PR](https://git.arkforge.net/ArkForgeLabs/Astra/pulls)s please visit there instead.

Astra is a Rust based runtime environment for Lua (5.1-5.5), Luau and LuaJIT. The goal is to get as much performance as possible while writing the logic in Lua instead for faster iteration, fault-tolerance, all the batteries included, and complete customization. This project is internally used here at [ArkForge](https://arkforge.net), by universities, research labs, and many large organizations.

For enterprise and business inquiries, send us an email at [contact@arkforge.net](mailto:contact@arkforge.net)

> MSRV: 1.94+

## installation

You can install using an installer script:

### Linux

```bash
sh -c "$(curl -fsSL https://astra.arkforge.net/install.sh)"
```

### Windows

```powershell
powershell -c "irm https://astra.arkforge.net/install.ps1 | iex"
```

### Cargo

Alternatively you can also install through [cargo](https://doc.rust-lang.org/cargo/) tool, if you have it installed:

```bash
cargo install lua-astra
```

Or a specific Lua version:

```bash
cargo install lua-astra --no-default-features --features=luau
```

## Example

```lua
-- Create a new server
local server = require("http").server.new()

-- Register a route
server:get("/", function()
    return "hello from default Astra instance!"
end)

-- Configure the server
server.port = 3000

-- Run the server
server:run()
```

Or fancy some multi threaded async code

```lua
-- spawn an async task that does not block the running thread
spawn_task(function ()
    -- HTTP Request to check your IP address
    local response = require("http").request("https://myip.wtf/json"):execute()
    print(response:status_code(), response:remote_address(), response:body():json())
end)
```

What about some databases and serialization?

```lua
local my_data = require("serde").json.decode('{"name": "John Astra", "age": 21}')

local db = require("database").new("sqlite", ":memory:")
db:execute([[
    CREATE TABLE IF NOT EXISTS data (id INTEGER PRIMARY KEY, name TEXT, age INTEGER) strict;
    INSERT INTO data (name, age) VALUES ($1, $2);
]], { my_data.name, my_data.age })

print(db:query_all("SELECT * FROM data"))
```

There is also support for cryptography, datetime, jinja2, markdown, pubsub/observers, type system for LSP, runtime type safety, and validation, async filesystem, and many more, check them at at the [docs](https://astra.arkforge.net/)

## Community Projects

- Astra Trails - <https://github.com/0riginaln0/astra-trails>
- Hack Club Clubs API - <https://github.com/hackclub/clubapi>

If you have a project that uses or extends Astra, let us know about it by extending the list above or [commenting here](https://git.arkforge.net/ArkForgeLabs/Astra/issues/68).

## Where is the community?

In the past, we had a discord server where you could join and talk in, however we moved it to [Matrix](https://matrix.to/#/#Astra:matrix.org) instead. Please open conversations here from now on.

## License

Astra is licensed under the [Apache License, Version 2.0](LICENSE).

## Note

This project may have breaking changes in minor versions until v1.0. Afterwhich semver will be followed. Contributions are always welcome!
