demo.video.mp4
- Windows 11
- Anaconda Python 3.10.9 / Python 3.10.9 virtual environment (Link)
- Docker Desktop (Link)
- MySQL 8.0 (Link)
- ngrok (Link)
-
Clone the repository:
git clone https://github.com/atharvabhide/Stripe-Sync.git cd Stripe-Sync
-
Create a Python environment
conda create --name <ENV_NAME> python=3.10.9 conda activate <ENV_NAME> OR virtualenv <ENV_NAME> -p python3.10.9 <ENV_NAME>\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Create a developer account on Stripe and copy the Secret key: https://dashboard.stripe.com/developers
-
Create the MySQL DB:
mysql -u <DB_USERNAME> -p create database <DB_NAME>
-
Create an env file in the backend folder (.env):
DB_USERNAME = <YOUR_DB_USERNAME> DB_PASSWORD = <YOUR_DB_PASSWORD> DB_NAME = <YOUR_DB_NAME> STRIPE_API_KEY = <YOUR_STRIPE_API_PRIVATE_KEY>
-
Create and start Docker containers for Kafka and Zookeeper:
docker-compose -f backend\kafka\docker_compose.yml up -d
-
Expose port 8000 using ngrok:
ngrok http 8000
-
Add the ngrok exposed url (add /stripe-webhook to the url) in the Web Hooks section of the Stripe Developer account: https://dashboard.stripe.com/test/webhooks with the following events:
- customer.created
- customer.updated
- customer.deleted
-
Run the main FastAPI local server (in a separate terminal):
python backend\main.py
-
Run the stripe webhook FastAPI local server (in a separate terminal):
python backend\kafka\api.py
-
Run the main Kafka consumer/worker (in a separate terminal):
python backend\kafka\consumer.py
-
Run the stripe webhook Kafka consumer/worker (in a separate terminal):
python backend\kafka\stripe_consumer.py
-
Outward Sync:
- Open localhost:8080/docs to access the FastAPI documentation.
- Perform CRUD operations by using the APIs.
- The changes get reflected in the Customer list of the developer account on Stripe.
-
Inward Sync:
- Open Customer list of the developer account on Stripe.
- Perform CRUD operations through the Stripe interface.
- The changes get reflected on the local system and can be observed on localhost:8080/docs through the read APIs.
-
To use the Streamlit dashboard for the outward sync (in a separate terminal):
streamlit run frontend\app.py