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)
|
|
slide-left |
Introduction to PocketBase |
true |
Who am I?
- 4th year CS student
- Student developer (Web / DX)
- Former Lead, GDSC UIC ('22-'23)
- Founder / Student Relations Lead, DICE
- Member, DEVCON Davao
Slides: https://github.com/nedpals/pocketbase-devcon-slides
Project Repo: https://github.com/nedpals/pocketwitter
- Saves time
- Little to no friction
- Focus on the idea
- Expensive to scale
- Hard to migrate
- Requires online connectivity
- 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
We will be building a simple Twitter clone:
- Login / register
- List / create / delete posts
- Make / list comments
- Favorite tweet
Repo: https://github.com/nedpals/pocketwitter
- 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
Objective: Create collection for users, posts, and comments
- 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)
- Provides official SDKs for Javascript and Dart/Flutter
- Javascript:
npm install pocketbase
- Dart/Flutter:
flutter pub add pocketbase
- Javascript:
- 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,+
meansasc
, and-
meansdesc
- 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
- Normal expand:
- 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)
-
Storage
- Via
file
field - Supports image resizing
- Store it in your server or in S3-compatible storage
- Via
-
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
- 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
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
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
::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>- 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.
- 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