Reputation: 21
I am a highschool student, trying to make a network of web applications for different purposes for my school. I use React on Meteor, but I do not know what is the best approach to structure these apps. The apps use the same user accounts, and will be able to automatically login if already logged into another application in this network. I will also need to build admin apps for each small applications.
In order to do this, I think that I will need to use DDP to connect data in these applications? If so, should I make a backend Meteor application that controls the users and database, and separate frontend Meteor applications for all the different purposes?
How would you recommend me to structure these apps? Thank you so much!
Upvotes: 1
Views: 858
Reputation: 1548
You are on the right way. One Meteor App is going to be the backend, the others Meteor apps are going to be clients for your master app. DDP is the way to go. Once you connect a client to your server app with DDP, your frontend act exactly as if your two apps are the same app. It works very well.
Here is the DDP.connect(url) doc: here
This is from the official Meteor guide:
Sharing data Another important consideration is how you’ll share the data between your different applications.
The simplest approach is to point both applications at the same MONGO_URL and allow both applications to read and write from the database directly. This works well thanks to Meteor’s support for reactivity through the database. When one app changes some data in MongoDB, users of any other app connected to the database will see the changes immediately thanks to Meteor’s livequery.
However, in some cases it’s better to allow one application to be the master and control access to the data for other applications via an API. This can help if you want to deploy the different applications on different schedules and need to be conservative about how the data changes.
The simplest way to provide a server-server API is to use Meteor’s built-in DDP protocol directly. This is the same way your Meteor client gets data from your server, but you can also use it to communicate between different applications. You can use DDP.connect() to connect from a “client” server to the master server, and then use the connection object returned to make method calls and read from publications.
Upvotes: 2