AppWrite: How To Use AppWrite
Tags: webdev, programming, tutorial, beginners
Published: 2022-11-18 17:15:02

When managing databases became too complex, developers built cloud solutions that could make databases easier to manage and handle. 
The same thing is happening with the backend as backend development becomes more complex. Companies are building services that provide backend functions for developers.
 
We term these services backend-as-a-service (BAAS). Appwrite is a good example of a BAAS. This piece of writing is about: 

> 1. [What is Appwrite](#whatisappwrite)
2. [Why Appwrite](#whyappwrite)
3. [How to install Appwrite](#installappwrite)
4. [Appwrite Services](#appwriteservices)
5. [How to create a database on Appwrite](#appwritedatabase)
6. [Appwrite vs Firebase](#appwritevsfirebase)
7. [Appwrite vs Nhost](#appwritevsnhost)
8. [Appwrite vs Supabase](#appwritevssupabase)
9. [Conclusion](#conclusion)

## What is AppWrite? <a name="whatisappwrite"></a>
According to [appwrite.io](https://appwrite.io), 

> Appwrite is a self-hosted backend-as-a-service platform that provides developers with all the core APIs required to build any application.
 
This means that appwrite provides backend features or services that you can integrate into your frontend or mobile application. Appwrite provides these services for your application, irrespective of the programming language or operating system the program is running on.
 
Appwrite is popularly called the Firebase alternative. Firebase is a backend solution owned by Google. Appwrite prides itself on being open-source, with a large community of developers, and believes itself to be the developers' favourite.

**Note:** I did this tutorial using Windows, so most of the commands are for Windows.


## Why Appwrite? <a name="whyappwrite"></a>

- Appwrite provides all the backend features that you need to get your application running.
 

- You can use appwrite with your custom backend application for an optimum experience as well.
 

- Appwrite saves you the cost of having to maintain a server.

- Appwrite provides a database as well, sparing you with the hassle of creating and managing a database.
 

- Appwrite takes away the long process of having to learn a new language just to build a server. As it is language-agnostic, developers can run it in any language they wish.


## How To Install AppWrite <a name="installappwrite"></a>
Appwrite uses Docker containers to run, so to install appwrite, you need to install Docker Desktop.

If you are using Windows, you will need to install Linux before you can use Docker. So follow this [link to install the Windows Subsystem for Linux 2](https://learn.microsoft.com/en-us/windows/wsl/install). 
Afterwards, you can [install Docker Desktop](https://www.docker.com/products/docker-desktop/).
 
After installing Docker Desktop, open Windows PowerShell and enter this command:

```
docker run -it --rm `
    --volume /var/run/docker.sock:/var/run/docker.sock `
    --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
    --entrypoint="install" `
    appwrite/appwrite:1.0.3
```


![screenshot of installing appwrite on powershell](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/emrbne1jy5j5scxeffw2.png)

You can follow this link to [install it either on the command line or on Unix](https://github.com/appwrite/appwrite).

Appwrite is installed successfully so open docker you should see the appwrite container.


![screenshot of appwrite container on docker](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwj362vceot3w41e6ivg.png)

To view appwrite on a browser, scroll down to the traefik container and click on any of the links.


![screenshot of appwrite container on docker](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oodiodasvw551xo88dpn.png)

That will open on your local browser and you should see the appwrite UI. 

Fill in your details and click on `sign up`


![screenshot of appwrite signup page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/46lwac6ybpcfij7rmgkg.png)

After registering, go back to the docker container and click on the same link again.

This time around, it will prompt you to sign in.


![screenshot of appwrite signin page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ujjb1qk18q6w2rlze18.png)

Sign in and it will take you to the appwrite dashboard.

![screenshot of appwrite dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9n9b7vhtem7ns3r68vww.png)

Then you can begin to create projects.

## Appwrite services <a name="appwriteservices"></a>
Appwrite offers services such as
 

1. **Creating and managing databases**
With this service, you can perform database functions like read, write, and update and you can also query your data.

2. **Storage**
This service allows you to record, store and delete files.

3. **Users' authentication and authorization**
With this service, you can grant authorized access to your users. You can limit your users from accessing information you wish to keep out of their reach.

4. **Use of webhooks**
Appwrite provides the use of webhooks. Which lets you connect your client app to receive requests from appwrite for events that you register for.

5. **API Keys**
Appwrite also provides an API key that you can use to perform API requests and make your client app functional

6. **Task management**
Appwrite manages your tasks for you, sending you notifications of relevant updates.

## How to create a database on Appwrite <a name="appwritedatabase"></a>
To create a database on Appwrite, you must create a project first.

- Click on the `Create a project` button.

- Name your `project` and name your `project-id` too and that would create a new project.


![screenshot of creating a project on appwrite](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xqthm512j77x28e7byzq.png)


![screenshot of creating an appwrite project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ez7nliu6xxsdryh9m1t2.png)


![screenshot of an appwrite project's dashboard ](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1chyi99qvfj270h0jnh2.png)

- After creating the project, then you can create a new database by clicking on the `database` button.


![screenshot of a highlighted appwrite database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nqudu1fho0z8dvuui73q.png)

- When you click on the database, it will open the database section where you can create a new database.


![screenshot of an appwrite dashboard for creating a new database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y8ug9ycsvdeh3j82lh24.png)

- Then Click on `Add Database`, so you can create a new database.


![screenshot of selecting the create button to create a new database](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jb09sjoziuztp853leb3.png)

- Enter the name of the `database` and the `databaseid` and then click on `Create`
That will create a database for you. 

- The next thing would be to create a collection. A collection is a compilation of documents with the same structure.
A collection will contain options like attributes, indexes, and documents for the database you created.


![screenshot of the add collection button highlighted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nvb594a1z4d3xuuytpd2.png)

- Name your `collection` and your `collectionid` and click on `Create`.


![a screenshot of the create button highlighted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wiyo82zgb03d6xxu50ai.png)

That would create a collection for you.

- Enable permission for the users or members you would allow.


![screenshot of permission enabled](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t95mj8f5fuf7fvba63gy.png)

- Click on the `Add Role` button and select the users or members you allow. You can also assign the operations they are to carry out. For the sake of this tutorial, I will add only one role.


![screenshot of setting permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ifp8tkkq7r1og0tzy5t.png)

- After that, you can enable permission for the documents, which will grant your users access.


![screenshot of setting other permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9bu4ap51wz7hbbj6ak9a.png)

- Click on `Update` to update the changes you have made.

- After that, you can add attributes.

> An attribute will be used by the Appwrite API to validate your users' input. It will also define the structure of your document.(Source: [Appwrite documentation](https://appwrite.io/docs)) 


![screenshot of add attribute button highlighted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rg2v4ge1f2g138pypfwa.png)

- Click on the `Add Attribute` button to add attributes.

- I will select the email attribute for this tutorial, you can choose an attribute you need.


![screenshot of email attribute highlighted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uvr74hoqr122ruo9wstc.png)

- Name the `attributeid` and give it a default value if you do not want to make it required. I will give it a default value of `mymail@mail.com`


![screenshot of create button highlighted](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n3o39j18yxnhv9f8e3kf.png)

- When you click on `Create`, it will create the email attribute.
The next thing would be to create documents.

- Click on `Add Document`, and that will bring up a prompt.


![screenshot of add document dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h1w8cjqmscqtng3rv20u.png)

- Name your document, grant permissions, and click on `Create`, which will create the document.


![screenshot of adding permission](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aaldg905cdjrtpup58l1.png)


![screenshot of setting permissions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5qq95yoll7p5gdrkqn4.png)

- After adding the permissions and clicking on `Create` that will create the document.


![screenshot of the database setup complete](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/atp2djbikjfrgppnbztz.png)

The document has been created. That is how to create a database for your project on appwrite.

## Appwrite vs Firebase <a name="appwritevsfirebase"></a>
Appwrite and Firebase are both BASS and they offer the same services but there are some differences between them. 


![appwrite logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5a5pbxawxf7tno5b4464.png)


![firebase logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zoxqs64v2s9xy2isiim.png)

|Appwrite   	| Firebase  	|
|---	|---	|
|Provides MySQL and NoSQL database   	|Provides NoSQL database   	|
|Self-hosted and open source   	|Hosted on Google’s cloud   	|
|Tedious set-up process   	|Easier to set up   	|
|Free access to an unlimited number of projects   	|Provides free access to a few projects   	|
|Open source   	|Backed by Google, a private entity   	|
|Has a large community of developers and is open to all   	|Access to google developers   	|

## Appwrite vs Nhost <a name="appwritevsnhost"></a>

![appwrite logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7naz54kav5nuvmb82fcw.png)


![Nhost logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1inxwykfz8t3wo517wuv.png)

Appwrite and Nhost are BASS too and they are both open source and see themselves as the Firebase alternative. However, there are some differences between them.


|Appwrite   	|Nhost   	|
|---	|---	|
|Uses MySQL and NoSQL databases   	|Uses PostgreSQL   	|
|Uses Docker   	|Uses AWS   	|
|Free, for now,   	|Offers paid packages on their cloud version   	|
|Does not use the Hasura framework   	|Uses the Hasura framework   	|
|Uses REST APIs   	|Uses GRAPHQL API   	|
|Self-hosted only    |Self-hosted and hosted on the cloud     |


## Appwrite vs Supabase <a name="appwritevssupabase"></a>


![appwrite logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/78w45m6672xim4so2wgo.png)


![Image of Supabase dashboard](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wpmy1op48pd9n4pwwh0a.jpg)

Appwrite and Supabase are BASS and they share so many similarities. They are both open source, they use the same REST APIs and they call themselves the Firebase alternative too. But there are some differences between them.

|Appwrite   	|Supabase   	|
|---	|---	|
|Self-hosted   	|Hosted on the cloud and self-hosted   	|
|Uses MySQL and NoSQL databases   	|Use PostgreSQL database   	|
|Self-hosting pattern has advanced features   	|Self-hosting has basic features   	|
|Free packages   	|Offers paid packages   	|

## Conclusion <a name="conclusion"></a>

Now, you have learned about appwrite, how to install it, and the service they provide. 
There are other services that you can use on appwrite. You can check their [official documentation for a thorough guide on how to use appwrite](https://appwrite.io/docs). 
You can also join their [developer community on discord](https://discord.com/invite/appwrite)