GithubHelp home page GithubHelp logo

odonno / surrealdb-presence-demo Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 0.0 375 KB

Demo project on how to create a realtime presence web application using SurrealDB Live Queries

JavaScript 4.06% HTML 0.57% CSS 2.32% TypeScript 93.05%
live-query presence react react-query realtime surrealdb typescript vite jotai

surrealdb-presence-demo's Introduction

SurrealDB Presence Demo

This is a demo project on how to create a realtime presence web application using SurrealDB Live Queries.

Image of the SurrealDB Presence Demo project

Tech stack

This is a list of the most important technologies used in this project:

  • React + TypeScript (Vite template)
  • TanStack Query
  • jotai (jotai-forms)
  • SurrealDB
  • surrealdb-migrations

Features

  • Authentication
    • Sign up
    • Sign in
    • Sign out
    • Display authenticated user details such as realtime presence
  • List of rooms with number of active users, with the ability to join a room
  • Selected room (last joined room)
    • Display the list of users in rooms
    • Show presence of each user
    • Ability to leave the room

Current configuration:

  • Signal user presence in room periodically (every 10 seconds)
  • Display presence status:
    • gray - left
    • green - < 2min of inactivity
    • orange - < 10min of inactivity
    • red - > 10min of inactivity

Get started

  1. Start a new SurrealDB instance locally
surreal start --log debug --user root --pass root memory --auth --allow-guests
  1. Apply migrations
surrealdb-migrations apply
  1. Install dependencies and run the web app
npm install
npm run dev
  1. Launch your web browser on the generated url (eg. http://localhost:5173/) and play with the app (create new accounts, join rooms, leave rooms)

And voilà!

Architecture

This project is using the following architecture:

  • /schemas - list of SurrealDB tables
  • /events - list of SurrealDB events
  • /migrations - list of db migrations that will be automatically applied
  • /src
    • /components
    • /pages
    • /contexts - Theme and SurrealDB providers
    • /queries - surql query files to query the database, using SurrealDB tables
    • /mutations - surql query files to create or update data, using SurrealDB events
    • /lib - functions and app models
    • /constants

surrealdb-presence-demo's People

Contributors

odonno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.