Skip to content

Commit

Permalink
Write description about ZAPP
Browse files Browse the repository at this point in the history
  • Loading branch information
parksb committed Nov 14, 2023
1 parent a335610 commit 9cef2c1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
- [Introduction](./introduction.md)

- [Getting Started]()
- [Architectures](./architectures.md)
- [Architectures](./architectures/README.md)
- [Project Structures](./architectures/project-structures.md)
- [ZAPP (Zap Protocol)](./architectures/zap-protocol.md)
- [Specifications](./specifications/README.md)
- [Client & Server](./specifications/client-and-server.md)
- [Models](./specifications/models.md)
Expand Down
15 changes: 0 additions & 15 deletions src/architectures.md

This file was deleted.

9 changes: 9 additions & 0 deletions src/architectures/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Architectures

Zap is structured as a client-server model. The client unidirectionally sends data, and the server receives and processes it. This architecture keeps Zap's design simple and naturally allows a 1:N structure where multiple clients can send data to a single server.

![](https://user-images.githubusercontent.com/6410412/282689836-12d14a7d-eeca-4a8c-996c-2ce9fa5caf4f.png)

A data sent from the client to the server is transmitted over UDP socket. Zap is implemented to send this data by defining 'ZAPP Object' defined on top of datagram, which contain the client's UUID, resource type, and the actual data value. ZAPP Object is the data unit of ZAPP(Zap Protocol), for more detailed information about the protocol, please check the [ZAPP page](./zap-protocol.md).

Zap uses callback functions to enable the transformation of a single-device application into a multi-device application while maintaining its own structure. The client, after obtaining the data they wish to transmit through the data source access API provided by their development framework, simply needs to call `zap.send(...)`. The server, running a Zap server instance, only needs to define callback functions to specify what code to execute each time it receives data from the client.
7 changes: 7 additions & 0 deletions src/architectures/project-structures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Project Structures

The project structure is straightforward. Under the root, there are four main modules: `ZapClient`, `ZapServer`, `Models`, and `Resources`.

![](https://user-images.githubusercontent.com/6410412/282663485-04699a9f-2909-41eb-86cc-41af916b3439.png)

`Models` include interfaces and type definitions generally referenced throughout the Zap system. On the other hand, `Resources` consist of implementations of `Zapable` that can be transmitted via Zap. For example, `ZapAccelerometer` is a `Zapable` implementation representing accelerometer data. These resource implementations are referenced to abstract the data obtained from data sources in `ZapClient` or `ZapServer` and are encapsulated in `ZappObject` for network transmission. For more detailed information on each component, please read the [Specifications](./specifications/README.md) section.
13 changes: 13 additions & 0 deletions src/architectures/zap-protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# ZAPP (Zap Protocol)

Zap defines a new network protocol over UDP to facilitate data exchange in an agreed-upon format across various platforms. This protocol is referred to as ZAPP(Zap Protocol), and the ZAPP data contained in a single datagram is called a 'ZAPP Object'.

The ZAPP Object is divided into two main parts: the header and the payload. The header contains metadata about the ZAPP Object, while the payload represents the actual data of interest to the communicating parties.

![](https://user-images.githubusercontent.com/6410412/282663845-ababb8ba-eb94-49cb-a168-af4733371eee.png)

The header consists of a timestamp and a resource field. The first 64 bits of the header constitute the timestamp field, representing the epoch time in milliseconds when the ZAPP Object was created. As UDP does not guarantee the order of datagrams, this field can be utilized if the order of data is crucial. This field can be interpreted as an unsigned integer.

Following the timestamp, the next 8 bits constitute the resource field. The resource field informs which resource the payload represents and simultaneously implies how the payload is encoded. This field can be interpreted as an unsigned integer.

After the 72-bit header, there is the payload part. The format of the payload varies depending on the resource. It can be a simple primitive type, text with delimiters, or JSON. The maximum length of the payload is theoretically up to 65,518 bytes, although it may vary depending on the implementation of Zap server.

0 comments on commit 9cef2c1

Please sign in to comment.