Skip to content

Commit d183cf6

Browse files
rickypidriccardocucia
andauthored
Improvement v0.9.0 (#1)
* Improved documentation * Fixed RSL on chats schema * Add files download support * Test on Android device * Renamed `SupabseChatCore` to `SupabaseChatCore` 😅 (typo) * Added logic to change status in read messages * Dependencies updated --------- Co-authored-by: riccardocucia <[email protected]>
1 parent ca6dccc commit d183cf6

39 files changed

+1744
-3568
lines changed

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
## [0.9.0] - 2024-03-11
2+
#### [@rickypid](https://github.com/rickypid)
3+
4+
* Improved documentation
5+
* Fixed RSL on chats schema
6+
* Add files download support
7+
* Test on Android device
8+
* Renamed `SupabseChatCore` to `SupabaseChatCore` 😅 (typo)
9+
* Added logic to change status in read messages
10+
* Dependencies updated
11+
112
## [0.0.2] - 2024-02-12
213
#### [@rickypid](https://github.com/rickypid)
314

4-
* Improved documentation and fixed GitHub Pages CI
15+
* Improved documentation and fixed GitHub Pages CI
516

617
## [0.0.1] - 2024-02-09
718
#### [@rickypid](https://github.com/rickypid)
819

9-
* Initial release
20+
* Initial release

README.md

Lines changed: 90 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@
4848

4949
<br>
5050

51+
Have you ever wanted to implement a chat in your application? Do you think it's difficult and complex?
52+
53+
Try this, thanks to the magnificent [Supabase](https://supabase.com/) platform and the [Flutter Chat UI](https://pub.dev/packages/flutter_chat_ui) package, you can achieve it in just a few minutes and effortlessly.
54+
55+
---
56+
5157
Flyer Chat is a platform for creating in-app chat experiences using Flutter or [React Native](https://github.com/flyerhq/react-native-supabase-chat-core). This repository contains Supabase BaaS implementation for Flutter. We are also working on our more advanced SaaS and self-hosted solutions.
5258

5359
* **Free, open-source and community-driven**. We offer no paid plugins and strive to create an easy-to-use, almost drop-in chat experience for any application. Contributions are more than welcome! Please read our [Contributing Guide](CONTRIBUTING.md).
@@ -64,6 +70,38 @@ The example project that you find in the package repository allows you to have a
6470

6571
`Dart >=2.19.0` and `Flutter >=3.0.0`, [Supabase](https://supabase.com) project.
6672

73+
### Create a Supabase project
74+
75+
1. Install Supabase CLI: [Official documentation](https://supabase.com/docs/guides/cli/getting-started)
76+
2. Open your bash
77+
3. Login with Supabase:
78+
79+
```bash
80+
supabase login
81+
```
82+
83+
4. Create new project (For example `demo-chat`):
84+
85+
```bash
86+
supabase projects create demo-chat
87+
```
88+
89+
5. Select your organization
90+
6. Select an region
91+
7. Insert a secure password for new Postgres database (Save this in a secure location)
92+
8. Obtain your `REFERENCE ID` (After command select your project, for example `demo-chat`):
93+
94+
```bash
95+
supabase projects list
96+
```
97+
98+
9. Obtain your `anon` key (After command select your project, for example `demo-chat`):
99+
100+
```bash
101+
supabase projects api-keys
102+
```
103+
10. Edit `example project` file `example/lib/supabase_options.dart`, insert your project `{{your_project_reference_id}}` and `{{supabase_anon_key}}`
104+
67105
#### Prepare Supabase project
68106

69107
Inside the example project (`example/utils`) there is a script, running the latter will automatically configure the Supabase project, creating tables, security rules, buckets and everything that is necessary for the example project to function.
@@ -76,14 +114,16 @@ In order to run the script you need to be aware of the following information abo
76114
- `user` : Database user
77115
- `password` : Database password
78116

79-
This information, with the exception of the password which is provided only during the creation of the database (if necessary, you can use the password reset function of your database to obtain it), can be found very easily from the Dashboard of your Supabase project:
117+
This information, except the password which is provided only during the creation of the database (if necessary, you can use the password reset function of your database to obtain it), can be found very easily from the Dashboard of your Supabase project:
80118

81-
![Supabase dashboard database info](doc/static/img/supabase_project_credential.png "Database info")
119+
![Supabase dashboard database info](doc/static/img/supabase-project-credential.png "Database info")
82120

83121
#### Running prepare script
84122

85123
Below are the commands for running the scripts (During execution you will be asked for the password for your database user):
86124

125+
> Required `psql` installed -> [Official documentation](https://www.postgresql.org/download/)
126+
87127
#### Linux
88128

89129
```bash
@@ -102,40 +142,13 @@ after running the database preparation script. you need to change the database s
102142

103143
![Supabase dashboard schema exposure setting](doc/static/img/supabase-schema-exposure-setting.png "Schema exposure setting")
104144

105-
Read our [documentation](https://flutter-supabase-chat-core.insideapp.it) or see the [example](https://github.com/insideapp-srl/flutter_supabase_chat_core/tree/main/example) project. To run the example project you need to have your own [Supabase](https://supabase.com/dashboard/projects) project and then follow [Add Supabase to your Flutter app](https://supabase.com/docs/reference/dart/initializing), override `example/lib/supabase_options.dart`, don't commit it though 😉
106-
107-
After all of this is done you will need to register a couple of users and the example app will automatically suggest email and password on the register screen, default password is `Qawsed1-`. To set up [Supabase Security Rules](https://supabase.com/docs/guides/database/postgres/row-level-security) so users can see only the data they should see, continue with our [documentation](https://flutter-supabase-chat-core.insideapp.it/).
108-
109-
## Contributing
145+
Optional (**Only for test**): Disable email verification and save the configuration (To speed up testing and allow user registration in just one click, it is advisable to disable mailbox verification):
110146

111-
Please read our [Contributing Guide](CONTRIBUTING.md) before submitting a pull request to the project.
112-
113-
## Code of Conduct
147+
![Supabase dashboard disable email verification](doc/static/img/supabase-disable-confirm-email.png "Disable email verification")
114148

115-
Flyer Chat has adopted the [Contributor Covenant](https://www.contributor-covenant.org) as its Code of Conduct, and we expect project participants to adhere to it. Please read [the full text](CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.
116-
117-
## License
118-
119-
Licensed under the [Apache License, Version 2.0](LICENSE)
120-
121-
## Example project progress
122-
123-
Below are the features implemented for each platform:
149+
Read our [documentation](https://flutter-supabase-chat-core.insideapp.it) or see the [example](https://github.com/insideapp-srl/flutter_supabase_chat_core/tree/main/example) project. To run the example project you need to have your own [Supabase](https://supabase.com/dashboard/projects) project and then follow [Add Supabase to your Flutter app](https://supabase.com/docs/reference/dart/initializing), override `example/lib/supabase_options.dart`, don't commit it though 😉
124150

125-
| Feature | Web | Android | iOS | Windows | macOS | Linux |
126-
|-----------------------|:-:|:-------:|:---:|:-------:|:-----:|:--------:|
127-
| Signup || | || | |
128-
| Signin || | || | |
129-
| Rooms list screen || | || | |
130-
| Create direct room || | | | | |
131-
| Create group room | | | | | | |
132-
| Create channel room | | | | | | |
133-
| Chat screen || | || | |
134-
| Search room | | | | | | |
135-
| Upload image || | || | |
136-
| Preview image message || | || | |
137-
| Upload file || | | | | |
138-
| Download file | | | | | | |
151+
After all of this is done you will need to register a couple of users and the example app will automatically suggest email and password on the register screen, default password is `Qawsed1-`. To set up [Supabase Security Rules](https://supabase.com/docs/guides/database/postgres/row-level-security) so users can see only the data they should see, continue with our [documentation](https://flutter-supabase-chat-core.insideapp.it/).
139152

140153
## RLS (Row level security)
141154

@@ -180,15 +193,51 @@ The preparation script automatically configures the security rules on the databa
180193
- `UPDATE` : Only the user himself.
181194
- `DELETE` : Only the user himself.
182195

196+
## Contributing
197+
198+
Please read our [Contributing Guide](CONTRIBUTING.md) before submitting a pull request to the project.
199+
200+
## Code of Conduct
201+
202+
Flyer Chat has adopted the [Contributor Covenant](https://www.contributor-covenant.org) as its Code of Conduct, and we expect project participants to adhere to it. Please read [the full text](CODE_OF_CONDUCT.md) so that you can understand what actions will and will not be tolerated.
203+
204+
## License
205+
206+
Licensed under the [Apache License, Version 2.0](LICENSE)
207+
208+
## Example project progress
209+
210+
Below are the features implemented for each platform:
211+
212+
| Feature | Web | Android | iOS | Windows | macOS | Linux |
213+
|-----------------------|:---:|:-------:|:---:|:-------:|:-----:|:-----:|
214+
| Signup ||| 🟡 || 🟡 | 🟡 |
215+
| SignIn ||| 🟡 || 🟡 | 🟡 |
216+
| Rooms list screen ||| 🟡 || 🟡 | 🟡 |
217+
| Create direct room ||| 🟡 || 🟡 | 🟡 |
218+
| Create group room | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 |
219+
| Create channel room | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 |
220+
| Chat screen ||| 🟡 || 🟡 | 🟡 |
221+
| Search room | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 |
222+
| Search message | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 |
223+
| Search user | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 | 🚧 |
224+
| Upload image ||| 🟡 || 🟡 | 🟡 |
225+
| Preview image message ||| 🟡 || 🟡 | 🟡 |
226+
| Upload file ||| 🟡 || 🟡 | 🟡 |
227+
| Download file ||| 🟡 || 🟡 | 🟡 |
228+
229+
- ✅ Tested
230+
- 🟡 Supported but not tested
231+
- 🚧 Planned
232+
183233
## Activities to complete (Roadmap)
184234

185235
Below are some activities to complete to have a more complete and optimized project also for use cases in larger projects.
186236

187-
1. Check the correct functioning of the RLS security rules
188-
2. Add the missing triggers
189-
3. Optimization of the join of users who are part of a chat room. At the moment every time you want to get a chat room a SELECT is performed to get the users of the chat room. It does not perform as the chat rooms or users present in them grow.
190-
4. Error handling
191-
5. Chat room groups
192-
6. Chat room channels
193-
7. Sending audio messages
194-
8. Improve documentation
237+
1. Add the missing triggers
238+
2. Optimization of the join of users who are part of a chat room. At the moment every time you want to get a chat room a SELECT is performed to get the users of the chat room. It does not perform as the chat rooms or users present in them grow.
239+
3. Error handling
240+
4. Chat room groups
241+
5. Chat room channels
242+
6. Sending audio messages
243+
7. Improve documentation

doc/docs/guides/supabse-trigges.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,20 @@ This is an example of a triggers that sets room's `lastMessages` to the most rec
2424
AFTER INSERT ON chats.messages
2525
FOR EACH ROW
2626
EXECUTE FUNCTION chats.update_last_messages();
27+
```
28+
29+
"This trigger, on the other hand, is responsible for setting the message status to `sent` when it is added to the `messages` table:
30+
31+
```sql
32+
CREATE OR REPLACE FUNCTION set_message_status_to_sent()
33+
RETURNS TRIGGER AS $$
34+
BEGIN
35+
NEW.status := 'sent';
36+
RETURN NEW;
37+
END;
38+
$$ LANGUAGE plpgsql;
39+
40+
CREATE TRIGGER update_status_before_insert
41+
BEFORE INSERT ON chats.messages
42+
FOR EACH ROW EXECUTE FUNCTION set_message_status_to_sent();
2743
```

doc/docs/introduction/supabase-overview.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ title: Overview
44
slug: /
55
---
66

7+
Have you ever wanted to implement a chat in your application? Do you think it's difficult and complex?
8+
9+
Try this, thanks to the magnificent [Supabase](https://supabase.com/) platform and the [Flutter Chat UI](https://pub.dev/packages/flutter_chat_ui) package, you can achieve it in just a few minutes and effortlessly.
10+
11+
---
12+
713
Flyer Chat is a platform for creating in-app chat experiences using Flutter or React Native. This is the documentation for Supabase BaaS implementation for Flutter.
814

915
## How it works?

doc/docs/introduction/supabase-project-configuration.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,40 @@ id: supabase-project-configuration
33
title: Supabase project preparation
44
---
55

6+
### Create a Supabase project
7+
8+
1. Install Supabase CLI: [Official documentation](https://supabase.com/docs/guides/cli/getting-started)
9+
2. Open your bash
10+
3. Login with Supabase:
11+
12+
```bash
13+
supabase login
14+
```
15+
16+
4. Create new project (For example `demo-chat`):
17+
18+
```bash
19+
supabase projects create demo-chat
20+
```
21+
22+
5. Select your organization
23+
6. Select an region
24+
7. Insert a secure password for new Postgres database (Save this in a secure location)
25+
8. Obtain your `REFERENCE ID` (After command select your project, for example `demo-chat`):
26+
27+
```bash
28+
supabase projects list
29+
```
30+
31+
9. Obtain your `anon` key (After command select your project, for example `demo-chat`):
32+
33+
```bash
34+
supabase projects api-keys
35+
```
36+
10. Edit `example project` file `example/lib/supabase_options.dart`, insert your project `{{your_project_reference_id}}` and `{{supabase_anon_key}}`
37+
38+
#### Prepare Supabase project
39+
640
Inside the example project (`example/utils`) there is a script, running the latter will automatically configure the Supabase project, creating tables, security rules, buckets and everything that is necessary for the example project to function.
741

842
In order to run the script you need to be aware of the following information about your Supabase project:
@@ -15,12 +49,14 @@ In order to run the script you need to be aware of the following information abo
1549

1650
This information, with the exception of the password which is provided only during the creation of the database (if necessary, you can use the password reset function of your database to obtain it), can be found very easily from the Dashboard of your Supabase project:
1751

18-
![Supabase dashboard database info](/img/supabase_project_credential.png "Database info")
52+
![Supabase dashboard database info](/img/supabase-project-credential.png "Database info")
1953

2054
#### Running prepare script
2155

2256
Below are the commands for running the scripts (During execution you will be asked for the password for your database user):
2357

58+
> Required `psql` installed -> [Official documentation](https://www.postgresql.org/download/)
59+
2460
#### Linux
2561

2662
```bash
@@ -35,6 +71,15 @@ cd .\example\utils\
3571
.\prepare.ps1 -hostname "your-postgres-host" -port your-postgres-port -database "your-postgres-database-name" -user "your-postgres-user"
3672
```
3773

74+
3875
after running the database preparation script. you need to change the database schema exposure setting by adding the `chats` schema (from the supabase dashboard):
3976

4077
![Supabase dashboard schema exposure setting](/img/supabase-schema-exposure-setting.png "Schema exposure setting")
78+
79+
Optional (**Only for test**): Disable email verification and save the configuration (To speed up testing and allow user registration in just one click, it is advisable to disable mailbox verification):
80+
81+
![Supabase dashboard disable email verification](/img/supabase-disable-confirm-email.png "Disable email verification")
82+
83+
Read our [documentation](https://flutter-supabase-chat-core.insideapp.it) or see the [example](https://github.com/insideapp-srl/flutter_supabase_chat_core/tree/main/example) project. To run the example project you need to have your own [Supabase](https://supabase.com/dashboard/projects) project and then follow [Add Supabase to your Flutter app](https://supabase.com/docs/reference/dart/initializing), override `example/lib/supabase_options.dart`, don't commit it though 😉
84+
85+
After all of this is done you will need to register a couple of users and the example app will automatically suggest email and password on the register screen, default password is `Qawsed1-`. To set up [Supabase Security Rules](https://supabase.com/docs/guides/database/postgres/row-level-security) so users can see only the data they should see, continue with our [documentation](https://flutter-supabase-chat-core.insideapp.it/).

0 commit comments

Comments
 (0)