Skip to content

Commit

Permalink
setup world server
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Nov 18, 2023
1 parent 6cb16bf commit 522d9cc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
3 changes: 2 additions & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ leptos_axum = { version = "0.5.1", optional = true }
unavi-web-app = { path = "../web/app", features = ["ssr"], optional = true }

[features]
default = ["web"]
default = ["web", "world"]
web = [
"dep:leptos",
"dep:leptos_axum",
"dep:unavi-web-app"
]
world = []
33 changes: 14 additions & 19 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,41 @@
# Server

A modular UNAVI home server.
A modular UNAVI server.

## Architecture

Home server functionality is divided into separate containers.
Each container can be enabled or disabled, allowing for flexibility in deployment.
Note that some containers rely on other containers.
Home server functionality is divided into separate features.
Each feature can be enabled or disabled, allowing for flexibility in deployment.
Note that some features rely on other features.

For example, I may want to run a lightweight home server that only handles user identity,
and disable the other containers.
Or I may want to split up my service and run each container on a separate machine.
and disable the other features.
Or I may want to split up my service and run each feature on a separate machine.

<div align="center">
<img src="../assets/images/server-architecture.png" height="600" />
</div>

## Containers
## Features

### DB

The DB container runs a MySQL database.
MySQL database.

### IPFS

The IPFS container runs an IPFS Kubo node for file storage and retrieval.
IPFS Kubo node, used for file storage and retrieval.

### Identity

The identity container handles allows users to use the server as their home server.
It handles user authentication, and federates social interactions with other servers.

### Router

The router is the entrypoint into the service.
It recieves external requests and delegates them to other containers.
Allows users to use the server as their home server.
Handles user authentication, and federates social interactions with other servers.

### Web

The web container hosts a web client.
Hosts a web client.

### World

The world container handles world networking over WebSockets and WebRTC.
It is the multiplayer server that connects users in a world together.
Allows worlds to use the server as their world server.
Handles networking, connecting player's within a world together.
7 changes: 7 additions & 0 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@ use std::net::SocketAddr;

#[cfg(feature = "web")]
mod web;
#[cfg(feature = "world")]
mod world;

#[tokio::main]
async fn main() {
println!("Features:");
let feat_web = cfg!(feature = "web");
println!("- web: {}", feat_web);
let feat_world = cfg!(feature = "world");
println!("- world: {}", feat_world);

let router = Router::new().route("/ping", get(ping));

#[cfg(feature = "web")]
let router = router.merge(web::router().await);

#[cfg(feature = "world")]
let router = router.merge(world::router().await);

let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("Listening on {}", addr);

Expand Down
6 changes: 6 additions & 0 deletions server/src/world/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use axum::Router;

pub async fn router() -> Router {
let router: Router = Router::new();
router
}

0 comments on commit 522d9cc

Please sign in to comment.