# Universal Connectivity
[Project Universal Connectivity](https://github.com/libp2p/universal-connectivity) is a team effort to demonstrate the power, flexibility, and ease-of-use of [libp2p](https://libp2p.io). libp2p is a modular network stack with the aim in making it easy to form peer to peer connections across a variety of platforms, languages, and protocols.
For this guide we'll be assuming you're running a Linux or MacOS system. If you're on Windows, please consider following the [WSL Install Guide](https://learn.microsoft.com/en-us/windows/wsl/install) on Microsoft's website to follow along more easily.
Having some terminal skills will greatly assist in following this guide. If you're on MacOS, installing [Homebrew](https://brew.sh/) is highly recommended.
#### Table of Contents
[TOC]
## Supported Transports
Below is a table of the packages included with the universal connectivity project and the transports they support.
| Package | Description | WebTransport | WebRTC | QUIC | TCP |
| :--------------------------------- | :----------------------------------------------- | ------------ | ------ | ---- | --- |
| [`go-peer`](#Go-Peer) | Chat peer implemented in Go | ✅ | ❌ | ✅ | ✅ |
| [`rust-peer`](#Rust-Peer) | Chat peer implemented in Rust | ❌ | ✅ | ✅ | ❌ |
| [`frontend`](#Javascript-Browser-Peer-amp-Frontend) | Next.js based browser UI of the chat app | ✅ | ✅ | ❌ | ❌ |
You might have noticed there's no one transport that all the implementations support at the same time. However, don't fret! All the peers can still communicate with eachother. With these peers we use [GossipSub](https://docs.libp2p.io/concepts/pubsub/overview/#gossip) to achieve full communication between all three nodes.
[Explain why / how GossipSub helps achieve this]
## Downloading the Code
Ensure git is installed (`sudo apt install git` on Debian-based Linux, or `brew install git` on MacOS) then run:
```bash
git clone https://github.com/libp2p/universal-connectivity.git
```
The Universal Connectivity packages will now be located inside a new directory within the current one titled `universal-connectivity`.
:::info
**Tip**
You can see your current directory with the `pwd` command.
:::
## Running the Peers
Currently, we have 3 different peers:
- A [Go peer](#Go-Peer) which runs in the console, and includes a CLI frontend.
- A [Rust peer](#Rust-Peer) whichs runs in the console, and has no frontend.
- A [Javascript peer](#Javascript-Browser-Peer-amp-Frontend) that lives in the browser which also incudes a NextJS-based frontend.
Below are instructions on how to build and run each of the peers, and how to connect them to eachother.
### Go Peer
The [Go peer](https://github.com/libp2p/universal-connectivity/tree/main/go-peer) supports the WebTransport, QUIC, and TCP transports.
<p align="center" style="width:100%;">
<img style="width:80%;margin:auto;display:block;" src="https://ipfs.io/ipfs/QmVjZyRg5RsW2GkjhFETrnrxwBTjmZU39imf3zBb5nay9E" alt="Screenshot of the Universal Connectivity Go frontend" />
</p>
#### Requirements
- Go
- Linux: Follow the instructions on the [Go download page](https://go.dev/dl/).
- MacOS: `brew install go`
#### Setup
Ensure your terminal is in your Universal Connectivity directory, then run the following commands:
```bash
cd go-peer
go run .
```
The terminal will hang for a bit while the code builds, this is normal. After the code finishes building it will automatically run.
[Explain what is shown on the screen, what the 3 windows represent, and the multiaddrs at the bottom.]
### Rust Peer
The [Rust peer](https://github.com/libp2p/universal-connectivity/tree/main/rust-peer) supports the WebRTC and QUIC transports.
<p align="center" style="width:100%;">
<img style="width:80%;margin:auto;display:block;" src="https://hackmd.io/_uploads/B1opWMPV3.png" alt="Screenshot of the Universal Connectivity Rust peer" />
</p>
#### Requirements
- Rust tools
- Linux / MacOS: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`
#### Setup
Ensure your terminal is in your Universal Connectivity directory, then run the following commands:
```bash
cd rust-peer
cargo run
```
[Explain the build process, and what the user is seeing. Ensure to focus on the multiaddr which will be needed in the frontend node.]
### Javascript Browser Peer & Frontend
The [Javascript browser peer and frontend](https://github.com/libp2p/universal-connectivity/tree/main/packages/frontend/) supports the WebTransport and WebRTC transports.
<p align="center" style="width:100%;">
<img style="width:80%;margin:auto;display:block;" src="https://hackmd.io/_uploads/BJ_1uWw4h.png" alt="Screenshot of the Universal Connectivity NextJS frontend" />
</p>
#### Requirements
- Node.js / npm
- Linux: [NodeJS Install Instructions](https://nodejs.org/en/download/package-manager#installing-node.js-via-package-manager)
- MacOS: `brew install node`
#### Setup
[Explain to edit libp2p.ts with the bootstrap peer, and how to connect to the go peer]
Ensure your terminal is in your Universal Connectivity directory, then run the following commands:
```bash
cd frontend # Enter the frontend directory
npm i # Install the frontend requirements
npm run build # Build the frontend
npm start # Run a webserver at http://localhost:3000, serving the frontend
```
[Explain what's happening, how to open the webpage, etc]
## Conclusion
Conclusion goes here
## Resources
- [Github - libp2p/universal-connectivity](https://github.com/libp2p/universal-connectivity)
- [libp2p - PubSub Overview](https://docs.libp2p.io/concepts/pubsub/overview)