Coder Social home page Coder Social logo

kayvanshah1 / firebase-realtime-db-emulator Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 111 KB

Emulates Firebase Realtime Database RESTful API functionality with FastAPI and MongoDB

Home Page: https://firemongo-kayvanshah1.cloud.okteto.net/

License: GNU General Public License v3.0

Dockerfile 0.54% Shell 0.06% Python 92.93% CSS 1.01% HTML 5.46%
bootstrap5 emulator fastapi firebase-realtime-database mongodb-atlas python restful-api docker pymongo okteto-cloud

firebase-realtime-db-emulator's Introduction

FireMongo

This project is a REST API for storing and retrieving data documents. It allows users to create new data documents by sending a POST request to the API endpoint.

The API supports the creation of multiple data documents at once, each identified by a unique ID. The created documents are stored in a MongoDB database.

The API also supports retrieving data documents by their ID, using a GET request to the appropriate endpoint. The project uses Python and the FastAPI web framework, with asynchronous programming using the asyncio library. It also uses the PyMongo library for interfacing with MongoDB.

The API includes error handling and input validation to ensure data integrity and prevent unexpected errors.

Getting Started

Setup of development environment

  1. Create a new Python environment and activate.

    Conda (from scratch)

    export PYTHON_VERSION=3.10.10
    conda create --name fastapi python=PYTHON_VERSION
    conda activate fastapi

    Conda environment.yml file

    conda env create -f conda-environment.yml

    Virtual environment

    python -m venv ENV
    source ENV/bin/activate
  2. Install dependencies in your environments

    pip install -r requirements.txt
    pip install -r requirements-dev.txt

Setup Environment Variables for the App

Requirements

  • You need have you own MongoDB Atlas Cluster
  • Get the connection details including the URI, username and password

Creating a .env file

  • Create a new environment file named .env
  • Copy the environment variables from example.env file from the root directory and paste it into the .env file created above
  • Add the MongoDB Atlas URI with username and password next to the MONGODB_URI environment variable
  • To generate a the secret key, run the following command:
    openssl rand -hex 32

Run the APP

Locally

Run the command below in the terminal

  1. Linux

    scripts/server.sh
  2. Windows

    uvicorn app.main:app --reload
  3. Run with Uvicorn multiple workers

    uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4
  4. Run with Gunicorn & Uvicorn

    gunicorn app.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000

Deploy

Deploy on Docker

  • Build the docker image with the following tag

    docker build . -t {DOCKERHUB_USERNAME}/firebase-realtime-db-emulator:latest
  • Create and run the container

    docker compose up

Deploy on Okteto

okteto login
okteto deploy --build

About

The theme of this semester’s project was emulation where the goal was to develop a prototype system that emulates the interface and working of a big data system.

Project Developed for DSCI 551: Foundations of Data Management | Spring 2023

Developed By Kayvan Shah | M.S. in Applied Data Science | University of Southern California

References

  1. Firebase. (n.d.). Use the Firebase Realtime Database REST API

  2. The MongoDB documentation

  3. MongoDB Atlas. (2021). Cloud-hosted MongoDB

  4. Okteto. (2021). Okteto Cloud Documentation. Okteto Cloud.

  5. Sebastian Ramirez et al. FastAPI. 2020. [Online].

  6. Deta. (n.d.). Deta Space Documentation

  7. Docker. (2021). Docker Documentation

firebase-realtime-db-emulator's People

Contributors

kayvanshah1 avatar

Watchers

 avatar  avatar  avatar

firebase-realtime-db-emulator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.