Syncing local database (mongod) and atlas database

Hello, I’m kinda lost on how to go about this sync database I’m using mern stack with
mongod as a local database and atlas for online database

i have no prior setup between the local and online database

i want the main database to be the atlas database and the local database be the secondary one instead the goal for this setup is when wifi is out or atlas is not available the local database will be used so in production it all good but in the case of wifi not available the application will run locally and use the local database the thing is i need both the local and online database to be in sync. I have search it up and it points me to replication or change streams how should i go about this?