Giter Club home page Giter Club logo

kafsync's Introduction

KafSync

Kafsync is a simple integration application that synchronizes customer data between your local environment and Stripe, a popular payment processing platform. It leverages Kafka as a messaging system to facilitate real-time data synchronization.

Local Setup

Follow these steps to set up Kafsync locally:

  1. Setup Kafka Using Docker:

    • Use the provided Docker Compose file at app/kafka/compose.yaml to set up a Kafka instance locally. Make sure you have Docker installed.
    • Run the following command to start Kafka:
      docker-compose -f app/kafka/compose.yaml up
      
  2. Install Required Libraries:

    • Install the required Python libraries by running:
      pip install -r requirements.txt
      
  3. Create a .env File:

    • Create a .env file in the project root directory to store sensitive information such as URLs and API keys.

    • Configure the following environment variables in the .env file:

      SQLALCHEMY_DATABASE_URL=<Your SQLAlchemy Database URL>
      STRIPE_API_KEY=<Your Stripe API key>
      
  4. Execute Kafka Resources Setup:

    • Run app/kafka/admin.py to configure Kafka resources, including topics and partitions.
  5. Choose Between Polling or Webhook Setup:

    • Decide on the synchronization method for Stripe integration. You can either use the polling mechanism or set up a webhook endpoint in Stripe.

      • Option 1: Polling Mechanism Start the scheduled poller by running the following command:

        python -m app.schedule-poll.py
      • Option 2: Webhook Setup Manually set up a webhook endpoint in your local environment using a tool like Ngrok or Localtunnel. Note the public URL generated and configure it in your Stripe account like https://{public_URL}/api/v1/customers/webhook. LocalTunnel usage can be as follows:

        npm install -g localtunnel
        lt -p 8000
  6. Start the Server:

    • Run the following command to start the server using Uvicorn with auto-reload:
      uvicorn app.main:app --reload
      
  7. Execute Kafka Consumer:

    • Start the Kafka consumer by running app/kafka/consumer.py. This consumer listens for events and processes data for synchronization.
  8. Access the API:

    • Open a web browser and navigate to http://localhost:8000/docs to interact with the API endpoints. Use this interface to trigger events for customer synchronization.
  9. Interact with Stripe:

    • Access your Stripe account and interact with it to observe the two-way synchronization between your local environment and Stripe.

You should now be able to see the synchronization in action.

Usage

  • Use the provided API documentation (Swagger) at http://localhost:8000/docs to create, update, and delete customer records. These changes will be propagated to Stripe and vice versa in near real-time.

Next Steps

Checkout Issues section for more information on things that are to be implemented, improved, and fixed.

kafsync's People

Contributors

ganimtron-10 avatar

Watchers

 avatar

kafsync's Issues

Things needed to be incoporated to make this system robust.

  • Always document the python functions and classes.
  • Create functionalities separate ie. DB should only handle db related stuff and should not know about anything else
  • There should a service layer between the API which would call the DB and similarly between the DB and the Producer
  • Change Polling System to Webhooks
  • Fix the DB Commit Flaw, Learn about Transactional Block
  • Learn more about partition
  • Models value should be non empty
  • Create a test suite
  • Add logging
  • Work on Exception handling

ToDos

  • Optimise and remove reduntant update calls
  • Fix Pool Queue Quota Issue
  • Searching and Researching new optimization approaches

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.