Welcome to Kiwi! Kiwi is an infrastructure-free programming language designed to streamline the development of cloud-native applications.
You can find the latest official releases on the Kiwi GitHub Releases page:
- JDK 21
- Maven
-
Clone the repository:
git clone git@github.com:kiwi-language/kiwi.git -
Navigate into the cloned directory:
cd kiwi -
Build the project using Maven:
mvn package -
Unpack the generated
dist/target/kiwi.ziparchive to a location of your choice.
To run Kiwi commands like kiwi-server, kiwi build, and kiwi deploy from any location in your terminal, you should add the Kiwi bin directory to your system's PATH environment variable.
The bin directory is located within the root directory of your Kiwi installation.
-
Identify the full path to the Kiwi
bindirectory (e.g.,/path/to/your/kiwi-install/bin). -
Open your shell configuration file (e.g.,
~/.bashrc,~/.zshrc,~/.profile, or~/.bash_profiledepending on your shell). -
Add the following line, replacing
/path/to/your/kiwi-install/binwith the actual path:export PATH="$PATH:/path/to/your/kiwi-install/bin" -
Save the file and reload the configuration (e.g., by running
source ~/.bashrcor opening a new terminal window).
- Identify the full path to the Kiwi
bindirectory (e.g.,C:\path\to\your\kiwi-install\bin). - Search for "Environment Variables" in the Windows search bar and select "Edit the system environment variables".
- Click the "Environment Variables..." button.
- In the "System variables" or "User variables" section, find the
Pathvariable and click "Edit...". - Click "New" and paste the full path to the Kiwi
bindirectory. - Click "OK" on all open dialog boxes.
- You may need to restart any open Command Prompt or PowerShell windows for the changes to take effect.
-
Install PostgreSQL.
-
Create a database within PostgreSQL that Kiwi will use.
-
Locate the
kiwi.ymlconfiguration file. It can be found in theconfigdirectory within your Kiwi installation root (e.g.,/path/to/your/kiwi-install/config/kiwi.yml). -
Edit the
kiwi.ymlfile and update the datasource section with your PostgreSQL details:datasource: host: <your_postgres_host> port: <your_postgres_port> username: <your_postgres_username> password: <your_postgres_password> database: <your_kiwi_database_name>
-
Install Elasticsearch.
-
Edit the
kiwi.ymlfile and update the es section with your Elasticsearch details:es: host: <your_elasticsearch_host> port: <your_elasticsearch_port> user: <your_elasticsearch_user> password: <your_elasticsearch_password>
- JDK 21
Start the server using this command (assuming the bin directory is in your PATH):
kiwi-server start
Once the server is running, you need to initialize it by sending the following HTTP request.
curl -X POST http://localhost:8080/system/init
-
Create a new directory for your test project and navigate into it:
mkdir kiwi_demo cd kiwi_demo -
Create a subdirectory for source files:
mkdir src
-
Create a Kiwi source file named
src/test.kiwiwith the following example code:class Product( var name: string, var price: double, var stock: int ) { fn reduceStock(quantity: int) { require(stock >= quantity, "Out of stock") stock -= quantity } }
-
Build the project using the Kiwi compiler (assuming the
bindirectory is in your PATH):kiwi build
Use the Kiwi CLI to deploy your compiled application to the running Kiwi server (assuming the bin directory is in your PATH):
kiwi deployThe command will prompt you for deployment details. Here are the expected inputs:
name: demopassword: 123456application: demo
After deployment, you can interact with your Product class via HTTP requests to the Kiwi server. Replace <id> in the URLs below with the actual ID returned by the server when you create a product.
Send a POST request to create a new product.
curl -X POST --location "http://localhost:8080/object" \
-H "Content-Type: application/json" \
-H "X-App-ID: {app-id}" \
-d '{
"object": {
"type": "Product",
"fields": {
"name": "Kiwi Fruit",
"price": 10.0,
"stock": 100
}
}
}' Note: The server should respond with the ID of the newly created product.
Send a GET request using the product's ID:
curl -X GET --location "http://localhost:8080/object/01dca8d6b90700" -H "X-App-ID: {app-id}"Send a POST request to the /object/invoke endpoint to invoke the method.
curl -X POST --location "http://localhost:8080/object/invoke" \
-H "Content-Type: application/json" \
-H "X-App-ID: {app-id}" \
-d '{
"receiver": {
"id": "{id}"
},
"method": "reduceStock",
"arguments": {
"quantity": 1
}
}'