Skip to content

Latest commit

 

History

History
571 lines (419 loc) · 25.6 KB

slides.md

File metadata and controls

571 lines (419 loc) · 25.6 KB
theme colorSchema background class highlighter lineNumbers info drawings transition title mdc
seriph
light
text-center
shiki
false
## Introduction to PocketBase Presentation slides for developers. Learn more at [Sli.dev](https://sli.dev)
persist
slide-left
Introduction to PocketBase
true

Introduction to PocketBase

An open source, portable Firebase alternative

Ned Palacios

for Davao Interschool Computer Enthusiasts

[email protected]


transition: fade-out title: Who am I?

Who am I?

Ned Palacios

  • 4th year CS student
  • Student developer (Web / DX)
  • Former Lead, GDSC UIC ('22-'23)
  • Founder / Student Relations Lead, DICE
  • Member, DEVCON Davao

layout: center title: Links

Slides: https://github.com/nedpals/pocketbase-devcon-slides

Project Repo: https://github.com/nedpals/pocketwitter


transition: fade-out preload: false title: Firebase

Backend-as-a-service


layout: center

Firebase Benefits

  • Saves time
  • Little to no friction
  • Focus on the idea

layout: center

Firebase Roadblocks

  • Expensive to scale
  • Hard to migrate
  • Requires online connectivity

layout: default

Open Source Firebase Alternatives

Supabase Appwrite
GitHub stars 59.4k stars 37.9k stars
Database PostgreSQL MariaDB
Features Auth, realtime, storage, functions Auth, realtime, storage, functions
Cloud offerings Yes Yes
Official SDKs Yes Yes

layout: section title: Introducing Pocketbase

Introducing Pocketbase


layout: center title: Obligatory XKCD comic

Standards https://xkcd.com/927/


layout: center

Why Pocketbase?

  • Authentication, database, realtime, and storage all in one executable file.
    • Self-hostable and can run offline
    • Deploy the executable in your favorite VPS or deploy via Docker
  • Fast, performant, and reliable because it is written in Go
  • Under the hood it uses the SQLite database to store data

transition: slide-up layout: center level: 2

Demo / Setup

We will be building a simple Twitter clone:

  1. Login / register
  2. List / create / delete posts
  3. Make / list comments
  4. Favorite tweet

Repo: https://github.com/nedpals/pocketwitter


layout: center

Basics

  • Record - individual entries in a collection
    • Firebase: document
    • Database: row
  • Collection - organized groups of related records
    • Firebase: collection
    • Database: table
    • Has a schema = structured
      • column = field
    • Three types:
      • Base Collection
      • View Collection
      • Auth Collection

layout: section

Basics Demo

Objective: Create collection for users, posts, and comments


layout: center

API Rules

  • Flexible and powerful way to control access to your application data
  • Similar to Firebase's Firestore Security Rules
  • By default, the collection can only be accessed by admins (a.k.a. you)

layout: center

Integrate PB to app

  • Provides official SDKs for Javascript and Dart/Flutter
    • Javascript: npm install pocketbase
    • Dart/Flutter: flutter pub add pocketbase
  • No SDK for insert language? Just use a REST API!
  • API documentation readily available
  • Querying options
    • filter - Filters/selects data based on the given query.
    • fields - Specify which fields will be returned.
    • sort - Sort the data by field, + means asc, and - means desc

layout: center

Relations

  • Establish connections between different collections
  • relation field
  • You can existing database relationship structures
    • One-to-one
    • One-to-many
    • Many-to-one
      • Traditional method (dedicated collection)
      • Store multiple IDs in a record
  • Load relationships via expand
    • Normal expand: expand=user,
    • Back-relation expand: expand=comments(post).user

layout: center

Realtime

  • It lets you subscribe to real-time changes in your specific collection.
  • You can be notified when a record has been added, updated, or deleted.
  • Similar to Firebase's realtime database
  • Via Pocketbase SDK: pb.collection(...).subscribe(topic, callback)

layout: center

Notable Mentions

  • Storage

    • Via file field
    • Supports image resizing
    • Store it in your server or in S3-compatible storage
  • Functions

    • Make Pocketbase as a Go web framework
    • Add custom code via Javascript
  • Logging / Telemetry

    • Built-in API telemetry support
    • Can detect HTTP 4xx and 5xx errors
  • Production

    • Deploy the executable in VPS or in Docker
--- layout: center ---

How does it perform?

  • 10,000+ concurrent users (2 vCPU/4GB RAM/80GB Storage $24 on DigitalOcean)
    • Compared to $100 Firebase "on-demand" bill
  • A basic 512MB server can also perform well
    • <200MB RAM usage (based on testing w/ custom code via JS)
  • Use replication tools like Litestream for reliability on simultaneous loads

layout: section

Projects using PB


layout: two-cols

Valentine Wall

Freedom wall project of GDSC UIC every February 14

Repo: https://github.com/gdsc-uic/valentine-wall

  • Previously Go + PostgreSQL
  • Migrated to PocketBase as a framework
    • Maintenance became easier + GUI admin

::right::

Image goes here


layout: two-cols

DevFest Registration System

Handles registration, e-mail sending, and screening. For GDG DevFest Davao 2023

Repo: Coming soon

  • PocketBase + Custom code via JS
  • Completed in 3 weeks
  • Runs smoothly on a free 512mb server
  • Utilized e-mail sending function
  • Storage for receipts

::right::

Image goes here


layout: two-cols-header

Backend for toy project

::left::

::right::

<iframe src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2F100000559682978%2Fvideos%2F693424322331309%2F&width=500&show_text=false&appId=1092368998023400&height=281" width="500" height="281" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowfullscreen="true" allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share" allowFullScreen="true"></iframe>

layout: center

Takeaways

  • With Pocketbase, it is possible for you to setup your backend for your project in minutes
  • Enjoy cost-effective backend solutions with PocketBase, offering savings compared to other services.
  • Provides you flexibility in managing data access with flexible API rules and etc.
--- layout: center ---

Thank you for listening!

  • Follow me on Twitter: @npned
  • Let's connect on LinkedIn: https://linkedin.com/in/nedp
  • Follow me on GitHub: @nedpals
  • Follow me on IG: @nedcodes

layout: section

Q&A