Skip to content

[Chore] Update Django Demo Readme #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions demos/django-todolist/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PowerSync + Django Flutter Demo: Todo List App

Demo app demonstrating use of the PowerSync SDK for Flutter together with the [demo Django backend](https://github.com/powersync-ja/powersync-django-backend-todolist-demo).
Demo app demonstrating use of the PowerSync SDK for Flutter together with the [demo Django backend](https://github.com/powersync-ja/powersync-django-backend-todolist-demo).

# Running the app

Expand All @@ -12,17 +12,45 @@ Ensure you have [melos](https://melos.invertase.dev/~melos-latest/getting-starte
4. Insert your Django URL and PowerSync project credentials into `lib/app_config.dart` (See instructions below)
5. `flutter run`

# Set up Django project
A test user with the following credentials will be available:

Follow the instructions in the django backend project's README.
```
username: testuser
password: testpassword
```

# Service Configuration

This demo can be used with cloud or local services.

## Local Services

The [Self Hosting Demo](https://github.com/powersync-ja/self-host-demo) repository contains a Docker Compose Django backend demo which can be used with this client.
See [instructions](https://github.com/powersync-ja/self-host-demo/blob/main/demos/django/README.md) for starting the backend locally.

The backend demo should perform all the required setup automatically.

### Android

Note that Android requires port forwarding of local services. These can be configured with ADB as below:

```bash
adb reverse tcp:8080 tcp:8080 && adb reverse tcp:6061 tcp:6061
```

## Cloud Services

### Set up Django project

Follow the instructions in the django backend project's README.

The instructions guide you through the following:

1. Creates `lists` and `todos` tables.
2. Creates a test user.
3. Create a logical replication publication called `powersync` for `lists` and `todos`.

# Set up PowerSync Instance
### Set up PowerSync Instance

Create a new PowerSync instance by signing up for PowerSync Cloud at www.powersync.com, then connect to the database of your Django project.

Expand All @@ -38,6 +66,6 @@ bucket_definitions:
- select * from todos where list_id = bucket.list_id
```

# Configure the app
### Configure the app

Insert the credentials of your new Django backend and PowerSync projects into `lib/app_config.dart`
6 changes: 3 additions & 3 deletions demos/django-todolist/lib/app_config_template.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copy this template: `cp lib/app_config_template.dart lib/app_config.dart`
// Edit lib/app_config.dart and enter your Django and PowerSync project details.
class AppConfig {
static const String djangoUrl = 'https://foo.ngrok.app';
static const String powersyncUrl =
'https://myprojectid.powersync.journeyapps.com';
// These are defaults when using the [self-host local demo](https://github.com/powersync-ja/self-host-demo/tree/main/demos/django)
static const String djangoUrl = 'http://localhost:6061';
static const String powersyncUrl = 'http://localhost:8080';
}
37 changes: 14 additions & 23 deletions demos/django-todolist/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
PODS:
- app_links (1.0.0):
- FlutterMacOS
- FlutterMacOS (1.0.0)
- path_provider_foundation (0.0.1):
- Flutter
Expand All @@ -12,41 +10,38 @@ PODS:
- shared_preferences_foundation (0.0.1):
- Flutter
- FlutterMacOS
- sqlite3 (3.46.0):
- sqlite3/common (= 3.46.0)
- sqlite3/common (3.46.0)
- sqlite3/fts5 (3.46.0):
- "sqlite3 (3.46.0+1)":
- "sqlite3/common (= 3.46.0+1)"
- "sqlite3/common (3.46.0+1)"
- "sqlite3/dbstatvtab (3.46.0+1)":
- sqlite3/common
- "sqlite3/fts5 (3.46.0+1)":
- sqlite3/common
- sqlite3/perf-threadsafe (3.46.0):
- "sqlite3/perf-threadsafe (3.46.0+1)":
- sqlite3/common
- sqlite3/rtree (3.46.0):
- "sqlite3/rtree (3.46.0+1)":
- sqlite3/common
- sqlite3_flutter_libs (0.0.1):
- FlutterMacOS
- sqlite3 (~> 3.46.0)
- "sqlite3 (~> 3.46.0+1)"
- sqlite3/dbstatvtab
- sqlite3/fts5
- sqlite3/perf-threadsafe
- sqlite3/rtree
- url_launcher_macos (0.0.1):
- FlutterMacOS

DEPENDENCIES:
- app_links (from `Flutter/ephemeral/.symlinks/plugins/app_links/macos`)
- FlutterMacOS (from `Flutter/ephemeral`)
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
- powersync_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/powersync_flutter_libs/macos`)
- shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos`)
- url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`)

SPEC REPOS:
trunk:
- powersync-sqlite-core
- sqlite3

EXTERNAL SOURCES:
app_links:
:path: Flutter/ephemeral/.symlinks/plugins/app_links/macos
FlutterMacOS:
:path: Flutter/ephemeral
path_provider_foundation:
Expand All @@ -57,19 +52,15 @@ EXTERNAL SOURCES:
:path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin
sqlite3_flutter_libs:
:path: Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos
url_launcher_macos:
:path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos

SPEC CHECKSUMS:
app_links: 10e0a0ab602ffaf34d142cd4862f29d34b303b2a
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
powersync-sqlite-core: 4c38c8f470f6dca61346789fd5436a6826d1e3dd
powersync_flutter_libs: 1eb1c6790a72afe08e68d4cc489d71ab61da32ee
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695
sqlite3: 154b084339ede06960a5b3c8160066adc9176b7d
sqlite3_flutter_libs: 1be4459672f8168ded2d8667599b8e3ca5e72b83
url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqlite3: 292c3e1bfe89f64e51ea7fc7dab9182a017c8630
sqlite3_flutter_libs: 5ca46c1a04eddfbeeb5b16566164aa7ad1616e7b

PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367

Expand Down
Loading