voidcosmos / angular-communities

A list of all the Angular Communities around the world
https://www.angular-communities.com
MIT License
102 stars 38 forks source link

Use Firebase for future features #33

Open Anexon opened 4 years ago

Anexon commented 4 years ago

I guess you have already considered but I think that community.json and communities logos may be moved to a more dynamic place such as database or to firebase even, so it can be modified without any project updates.

In addition, it could be used to develop a simple API service to allow Angular Community Managers to claim the control of their information so they can update it when necessary, as you do on Google My Business. Also, it can be used for getting new communities applications that only need to be reviewed and accepted, without any repository changes.

This may seems quite ambitious, but at the very first step would be only moving the data to a more dynamic place and init the connection to the database so many other features may be proposed around this capability in the future; login, subscribing, notifying events, getting sponsor offers, etc...

In specifics, I would update CommunityService so it retrieves the information from a firebase project or any other database that may be proposed. However, a firebase account with limited access should be created and the data structure instantiated with the current data in communities.json.

I don't know if this is out of scope, what do you think? I would be happy to help by doing this feature or helping on creating the Firebase project or considering other options as well!

NyaGarcia commented 4 years ago

Sounds good, we were actually considering using Firebase, since there's a couple of new features that we were thinking about adding, that would have to make use of DB.

However, adding a database makes us face the issue of authentication. Have you considered this? Because right now, new communities are added by PR, and Github takes care of authentication. Nevertheless, if we use a Firebase project with a DB to store the communities data, we'd have to handle it ourselves. I've never created a Firebase project before, so I have no idea of what it has to offer regarding authentication. Any suggestions?

Anexon commented 4 years ago

Firebase has a great amount of authentication features, in fact you may still use Github account to log in. Alternatives would be using a DB maybe MySQL hosted on a server. That would required developing an OAuth and APIRest or configuring a firewall by IP so you can have control of who can access to the data base and with which privileges.

Using firebase you may set some basic rules about writing and reading capabilities for some known users (administrators for instance) or that only if you own certain data you are allow to modify it without writing any API. A part from that, Firebase is a non-relational DB that would bring enough flexibility for start a new database and change it over time "without taking care of" heavy migrations.

However, firebase offers a free service until you cross a number of queries per month. It is a generous threshold though.

I've created a couple of projects based on a firebase database using firestore, however it implies creating an account that will own the project and I don't know how are you handling this at the moment. I would be happy to have a videochat with you guys and see what would it implies and what other options you were considering so may just discard this option or plan it better as it has an important organizational first step.

moi-j commented 4 years ago

Hi all. In case you think about firestore take into account that if in near future you plan to add more features related to geolocation could be helpfull to use a mongodb database instead as it has a lot of good methods for querying geodata.

Caballerog commented 4 years ago

Hi everybody,

I speak with @Anexon who started a first prototype using Firebase to move the json to the database and he'll create a basic authentication using https://github.com/angular/angularfire (official package).

I think that in the next step, we can build a minimalist backend wich will be use MongoDB as @mjimenezmartin said. We want to develop interesting features using the map because this will be the heart component in this proyect.

Thanks for your time! :-)

Anexon commented 4 years ago

Hi there!

I got some news. Here you may find a working example of using firebase to retrieve communities and images.

I included a script that replicates the current communities.json local file to firebase and upload all generate images in pre-deploy process to google storage.

Before ng serve

Before to get it working you will need to create a new project using firestore on firebase, get the credentials and put them in the mentioned script file (see package.json) and in environment.ts file.

Also you will need to go to Google Cloud Console and make the bucket public so anyone can access to the images.

Now you can execute the script to replicate the content to firebase. Remember to generate images first!

Conclusion

It may seems a little bit tricky to get all of this working but it is only firebase configuration. We may use an "official" account and I would left it configured and running and I would document the process just in case.

If you want to try it by your self first, please let me know if you get stucked in some of the processes of creating firebase elements.

Anexon commented 4 years ago

Hi everyone!

Here you may get a working example of the web as official credentials are set for the default environment. Credentials are public as they are needed for the app to get proper reference to firebase and read content from there, there is "no risk" (better explained here).

I set reading permissions to anonymous requests and writing permissions to admin users that are set manually. So anybody is able to edit the database but the admins and this is the key point, we should decide how would be the adding community procedure as it would not be possible by editing the json file anymore. I would recommend using google forms to get add-communities requests and let some of the admin to update the database using a custom script that I included in the project.

From this point, I would plan a bunch of new features that may be needed to give control to community managers to update their info without editing original repository, all by accessing an user area and so many other features!

Let me know what you think

Caballerog commented 4 years ago

Hi @Anexon !

I have started to raise new issues that could be interesting features in which we need a Firebase store like the one you have raised.

The point is that I think this PR could be integrated when we have a form in angular-communities that allows sending new communities to anyone. What do you think of that?

I would like the community to be able to supply their community information at all times and not to place the burden on the administrators of Angular-Communities.

So what do you think if we develop your issue and proposal as a slightly richer PR in which we will integrate the following features:

Later, I think that with this feature we could open new ones like the ones I have proposed:

What do you think if we get down to work creating a PR in which we integrate the basic functionalities that I have described and work on it to be able to create something of greater value without losing what we have now?

A greeting!

@tonivj5 @NyaGarcia

Anexon commented 4 years ago

Hey @tonivj5 and @NyaGarcia , I think is a great idea. Let's break milestone into smaller pieces. I'll try to attach myself to some of those new issues you just created so we may get to a functional point as soon as possible :D

tonivj5 commented 4 years ago

Yeah, we should break it :+1: I love the idea to level up communities! Thanks @Anexon for your involvement on this, #55 is a good start. I like some functionalities that firebase can offer us.

I think we should follow using community.json to add communities like we have done until now meanwhile we implement new features around firebase and get more confident with it. We could add a new github action to perform the inserting into firebase, and reduce too the amount of deployments we're doing on each commit :eyes: