A Guide On Appwrite
Published: 2022-11-12 18:13:18

##Introduction
How does it feel to have a fully secured, open-source, and self-hosted backend platform? that can be deployed on your preferred cloud tools and easily integrated with any frontend framework? That sounds fantastic, doesn't it? Well, don't worry because Appwrite is here to save the day. So, what exactly is Appwrite?
Appwrite is a self-hosted Backend-as-a-Service (BaaS) platform that gives you all of the core APIs, tools, and management console UI you need to build your application faster and more securely. Appwrite is compatible with any operating system, programming language, framework, or platform. This guide will walk you through the Appwrite installation process, its services, its competitors, and why you should use Appwrite.

##Installation

Appwrite can be installed in two ways. You can use the one-click installation method to get Appwrite up and running on DigitalOcean or Gitpod pretty quickly. If you want to use this method of installation, you can learn more about it [Here](https://appwrite.io/docs/installation#one-click-setups).
You will be installing Appwrite using Docker in this guide; if you do not already have Docker installed on your system, please click [Here](https://docs.docker.com/desktop/) to download and install it. 


You can now install Appwrite. To achieve this:
- Confirm that you have installed Docker and that it is running.
- Go to Appwrite.io.
- Click on the **Get Started** button.
- Copy the following command(Appwrite server is stored as a Docker container, which you can quickly set up from your terminal using the docker-compose 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
```
- Open your terminal and paste it there.
- Press the enter key.
- During installation, you will be asked where you want to run your HTTP port, as shown below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/isy40lvynjghmy4i5a25.png)
- You can make port ```80``` your default.
- You will then be asked to select a secret API, which can be your name, as shown below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz9ogjanuevrgrqmdvwb.png)
- You will be prompted to enter your Appwrite hostname, which should be the local host.
- You will be prompted to enter your DNS record; continue to use the hostname for this.
- Press the enter key and wait for it to be fully installed; you should see the message **Appwrite installed successfully** once the installation is complete.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k4ody9hve1ma5eg4ondz.png)

If you go to your Docker, you should see your Appwrite container running, which has 20 other containers, as shown below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yr1ejsdgv2ovvbghglae.png)
To sign in to Appwrite, open your browser and type
 ```
localhost:80
```  Then enter your information as shown below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2iivqn57kg2nvr4g922u.png)
If you do not already have an Appwrite account, you should create one before you can log in. After signing into Appwrite, you'll be able to see your dashboard and create a new project, as shown below.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bz9ii2jd2fuh4e67z51a.png)

##Appwrite services

These are the Appwrite services; the team service will be covered in detail later.


####Users API
The user service is used to manage the users in your project. It is used to search for and block users, as well as to view your user information, current section, and most recent activity. You can also update your user's preferences and personal information through your user service.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/36zqwxgzvlt8m1mf6rmx.png)

####Databases API
 This service enables you to create structured document collections, query and filter document lists, and manage an advanced set of read and write access permissions.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/90pzux8nge3s0rj8neud.png)
####Storage API
This service enables you to manage your project files by uploading, viewing, downloading, and querying all of your project files. Files are managed in this service using buckets. Collections in the databases service are similar to storage buckets. The difference is that buckets have more power to decide what types of files and sizes you want to allow in that bucket, as well as whether or not to encrypt the files, use antivirus, and much more.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/058yygnoyijzq7uzm1tz.png)
####Localization API
This service enables you to modify your app dashboard based on the location of your users. You can get your user's location, IP address, list of countries and continent names, phone codes, currencies, and more by using this service.

####Functions API
This service aids in the discovery of custom behavior that can be triggered by any supported Appwrite system event or a predefined schedule.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qrfa5anspyn2gd2qevz8.png)
####Avatars API
The service aims to help you complete your daily tasks that are related to your app image, icons, and avatars.

####Health API 
You can use this service to validate and monitor your Appwrite server instance, ensuring that all of its internal components are up and running and responsive.

####Account API
You can use this service to manage and authenticate a user account. It is also used to update user information, retrieve user sections across multiple devices, and retrieve user security logs containing recent activity. You can use the account service to register new user accounts,using the  [Create Account](https://appwrite.io/docs/client/account#accountCreate),[Create Magic URL session](https://appwrite.io/docs/client/account#accountCreateMagicURLSession), or [Create Phone session ](https://appwrite.io/docs/client/account#accountCreatePhoneSession) endpoint. You can authenticate the user account using any of the available signing methods. Once a user has been authenticated, a new session object is created to allow the user access to his or her private data and settings.
One of the account service's fantastic features is the multiple sign-in methods, which allow you to authenticate a user. Following authentication, a new session object will be created to allow the user access to his or her private data or settings.

####Teams API
The team service enables you to group project users and give them read and write access to project resources such as database documents or storage files.
When a user creates a team, he or she becomes the team owner and can exercise ownership by inviting a new team member. Only team owners can invite users.
You will go through a series of team service sessions that will help you create a team in Appwrite.

#####Create Team
When a user creates a team, he or she becomes the team owner, and only the owner can invite new members, add new owners, update the team, and delete the team.
Here's an example of how to use the Create Team Endpoint.
```
import { Client, Teams } from "appwrite";

const client = new Client();

const teams = new Teams(client);

client
    .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
;

const promise = teams.create('[TEAM_ID]', '[NAME]');

promise.then(function (response) {
    console.log(response); // Success
}, function (error) {
    console.log(error); // Failure
});
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/skkmft4m5xf8a2yh5iko.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/db7nc0xlblrkrarpnii8.png)
#####List Teams
 This endpoint returns a list of all the teams that the current user is a member of. You can use the parameters to select your results. It also returns a list of all the latest project teams.
The List Team Endpoint is demonstrated in the code below.

```
import { Client, Teams } from "appwrite";

const client = new Client();

const teams = new Teams(client);

client
    .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
;

const promise = teams.list();

promise.then(function (response) {
    console.log(response); // Success
}, function (error) {
    console.log(error); // Failure
});
```
#####Get Team
You can get a team by its ID using this Endpoint. This resource is accessible for all team members to read.
The Get Team Endpoint is demonstrated in the code below.

```
import { Client, Teams } from "appwrite";

const client = new Client();

const teams = new Teams(client);

client
    .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
;

const promise = teams.get('[TEAM_ID]');

promise.then(function (response) {
    console.log(response); // Success
}, function (error) {
    console.log(error); // Failure
});
```
#####Update Team 
You can use this endpoint to update a team using its ID, and the update can be performed by members who have the owner role.
The Update Team Endpoint is demonstrated in the code below.
```
import { Client, Teams } from "appwrite";

const client = new Client();

const teams = new Teams(client);

client
    .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
;

const promise = teams.update('[TEAM_ID]', '[NAME]');

promise.then(function (response) {
    console.log(response); // Success
}, function (error) {
    console.log(error); // Failure
});
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qpmxj8mo0btg4f9yyqnh.png)
#####Delete Team 
You can use this endpoint to delete a team using its ID, and the update can be performed by members who have the owner role.
The Delete Team Endpoint is demonstrated in the code below.

```
import { Client, Teams } from "appwrite";

const client = new Client();

const teams = new Teams(client);

client
    .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
;

const promise = teams.delete('[TEAM_ID]');

promise.then(function (response) {
    console.log(response); // Success
}, function (error) {
    console.log(error); // Failure
});
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zvkr1ibmdv5ca2otmnxm.png)
##Why Appwrite
There are numerous reasons why you should use Appwrite, 
- one of which is that it is self-hosted.
- Appwrite was designed with scalability in mind.
- Appwrite can scale both horizontally and vertically, using a small number of containers to run where each container has its own job.
- It is fast and secure.
- It can handle access control.
- Appwrite has a completely stateless architecture.
- It supports multi-tenancy, which means that a single Appwrite 
 instance can support an unlimited number of accounts and projects.
- It has pre-built images that you can launch with a single click of the Do button. 
- It was created to work alongside the stack you are currently using. 
- It works fine with your current backend. 
- It supports Cloud functions and has over 15 runtimes, making it simple to implement any custom logic.

##Appwrite vs Competitors

####[Supabase](https://supabase.com/)
Both Supabase and Appwrite are fantastic products, but Appwrite focuses on ease of use and increased productivity. This is done by maintaining a positive developer experience.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/64wc6xgo1kxockbd7v8b.png)
####[Firebase](https://firebase.google.com/)
Appwrite has a beautiful user interface, is simple to set up, and is consistent across platforms. Firebase is expensive, has limited scalability, is not open source, relies on a third party, cannot filter queries, and is not flexible.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j96ncxc3jl0842mroo6n.png)

#### [Parse](https://parseplatform.org/)
Appwrite was created to work in a Docker-oriented environment, making it simple to deploy an infrastructure that already relies on Docker, is security-focused, and includes many security-driven features.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/70la8z25plltqcrahe6x.png)


##Conclusion
You should now have a good understanding of how Appwrite works, its features, and services. You can join Appwrite's Discord community [here](https://discord.com/channels/564160730845151244/636818236310159360). to learn more about it. You can also visit its [webpage](https://appwrite.io/). or [repository ](https://github.com/appwrite/awesome-appwrite).for additional information and resources.