0% found this document useful (0 votes)
17 views

NodeJS

Meteor is a full-stack JavaScript framework that enables developers to create web and mobile applications using a single language for both client and server. It employs a client-server architecture with real-time capabilities, utilizing DDP for communication, MiniMongo for client-side data management, and MongoDB for server-side storage. Key features include a publish/subscribe pattern for data synchronization, support for various client-side rendering libraries, and the use of Fibers for simplified asynchronous operations.

Uploaded by

tathanprestige
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

NodeJS

Meteor is a full-stack JavaScript framework that enables developers to create web and mobile applications using a single language for both client and server. It employs a client-server architecture with real-time capabilities, utilizing DDP for communication, MiniMongo for client-side data management, and MongoDB for server-side storage. Key features include a publish/subscribe pattern for data synchronization, support for various client-side rendering libraries, and the use of Fibers for simplified asynchronous operations.

Uploaded by

tathanprestige
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DOCUMENTATION GENERAL METEOR JS

Meteor es un framework de JavaScript full-stack que simplifica el desarrollo de aplicaciones web y


móviles, permitiendo a los desarrolladores trabajar con un solo lenguaje tanto en el cliente como en
el servidor. Para entender su arquitectura y cómo funciona, podemos desglosarla en varios
componentes fundamentales:

Client-Server Architecture and Full-Stack

Meteor follows a traditional client-server architecture but with additional capabilities that enable
real-time efficiency. Here’s a breakdown of how each part functions:

Client (Frontend): The client side of a Meteor application typically uses Blaze (Meteor's default
templating engine), React, or Vue.js to render the user interface. The client:

 Runs in the browser or in a mobile app (using Cordova).


 Connects to the server via WebSockets (using DDP, Distributed Data Protocol), which allows
real-time updates.
 Manages its data using MiniMongo, an in-memory version of MongoDB, enabling client-side
database queries similar to those on the server.

Server (Backend)

On the server side, Meteor is built on top of Node.js. It handles all backend operations:

 Meteor's databases are usually managed with MongoDB.


 Meteor follows a publish/subscribe pattern to transfer real-time data between the server and
client. The server publishes data, and the client subscribes to it.
 It uses Fibers, a special Node.js feature, which allows Meteor’s server functions to run
synchronously, simplifying the handling of asynchronous operations.

Full-Stack Capabilities

Meteor allows the use of JavaScript on both the client and server sides. This results in significant code
reusability, simplifying the project structure and reducing the learning curve for developers.

Key Components of Meteor’s Architecture

DDP (Distributed Data Protocol) DDP is Meteor’s protocol used for real-time communication
between the client and server. It uses WebSockets to send messages about database changes,
enabling almost instantaneous data updates on the client without refreshing the page.

MiniMongo MiniMongo is a lightweight version of MongoDB that runs on the client side. This
in-memory database allows database operations (like queries and updates) to be performed locally in
the browser. Once data is modified in MiniMongo, changes are automatically synchronized with the
server.

MongoDB (Server-side Database) Meteor uses MongoDB as its main server-side database. Database
modifications are published to clients using the publish/subscribe pattern. The server handles data
synchronization between clients and the database.

Publications and Subscriptions The server publishes data sets (collections), and the client subscribes
to them. Through this mechanism, Meteor efficiently synchronizes real-time data between the server
and clients. This means that any changes to the data in the server’s database are immediately
reflected on the client.
Publications and Subscriptions

 You do a method call and change an object in a collection.


 Mongo oplog will propagate that change to observers that tails it (publications create observers
on oplog).
 Publications observers detect oplog changes that affect its observed data, and it spawns a data
re-fetch on mongo database.
 Meteor merge box will check the diffs and propagate it to the client, as
added/changed/removed.
 Meanwhile, your method results might come after or before. It’s usually before, but if your
oplog is fast and you have more computation after changing the DB, it might come after.

Blaze/React/Vue.js (Client Rendering) While Blaze is Meteor's traditional templating system, many
applications now use React or Vue.js for client-side rendering. Data in these views is updated in
real-time as collection changes from MongoDB are propagated through MiniMongo.

Fibers (Synchronous Behavior on the Server) Meteor uses Fibers, a library that makes JavaScript
functions on the server appear to run synchronously, even though they’re performing asynchronous
operations (like database queries or HTTP requests). This greatly simplifies code by avoiding the
extensive use of callbacks or promises.
Data Flow in Meteor

The data flow in Meteor follows these steps:

Publication: The server publishes collections or subsets of MongoDB data to clients that subscribe to
them.

Subscription: The client subscribes to those publications. Once subscribed, the server sends the data
to the client, and they stay updated in real-time.

MiniMongo: On the client side, data is stored in MiniMongo. When the client queries the database,
it’s resolved locally in MiniMongo, improving speed and reactivity since the operations don’t need to
wait for a server response.

Updates: If data changes on the server, the server sends those changes to all subscribed clients via
DDP. Clients automatically update their data without needing to refresh the page.

Meteor Methods: To perform server-side actions (like inserting or modifying data), the client calls
Meteor methods. These methods are RPCs (Remote Procedure Calls) executed on the server and can
be invoked from the client. The method runs on the client first (optimistic UI) and then on the server,
allowing for a fast, reactive interface.

Meteor maintains a low-level data connection to a server using a protocol called DDP. This protocol
allows the server to send data to the client only at the moment it changes, taking advantage of its
continuous connection with it.

You might also like