DEV Community

Satish Choudhary
Satish Choudhary

Posted on

I built a Python package that syncs backend & frontend without any API endpoints — dsn-sync

Every time I started a new project, I had to write the same boilerplate — REST endpoints, WebSocket setup, Redis config, Firebase integration. I thought: what if none of this was needed?

So I built dsn-sync — a Python package that lets your backend and frontend talk to each other directly, with zero API setup.

The problem it solves

A typical data sync stack looks like this:

Backend → REST API → Controller → Route → Middleware → Frontend
(Plus: Redis, Celery, WebSocket, Firebase...)
Enter fullscreen mode Exit fullscreen mode

With dsn-sync, it becomes:

Backend → Frontend ✅ (That's it!)
Enter fullscreen mode Exit fullscreen mode

Installation

pip install dsn-sync        # Backend (Python)
npm install dsn-sync-client # Frontend (JS)
Enter fullscreen mode Exit fullscreen mode

Quick example

Backend (Python):

from dsn_sync import DSNSync

sync = DSNSync(port=3000)
sync.start()

sync.define_table('users', {
    'key': 'user_id',
    'fields': ['name', 'email', 'status']
})

# Push data to frontend — no API needed!
sync.sync('users', 'user_123', {
    'name': 'Satish',
    'email': 'satish@example.com',
    'status': 'active'
})
Enter fullscreen mode Exit fullscreen mode

Frontend (JavaScript):

import { connectDSN } from 'dsn-sync-client';

const client = connectDSN('YOUR_URL', 'YOUR_TOKEN');

// Get all users — auto synced!
const users = await client.getAll('users');

// Listen for real-time changes
client.onDataChange('users', (data) => {
    console.log('Data updated!', data);
});
Enter fullscreen mode Exit fullscreen mode

What it supports

Beyond basic sync, dsn-sync handles full CRUD, real-time notifications, a chat system, background auto-tasks, and live chart data — all without WebSocket, Firebase, Redis, or Celery. It uses encrypted communication with token-based auth and works with Python 3.7+.

CRUD example

@sync.on_create('users')
def handle_create(data):
    print(f"New user: {data['name']}")
    return True

@sync.on_update('users')
def handle_update(data):
    print(f"Updated: {data}")
    return True

@sync.on_delete('users')
def handle_delete(data):
    print(f"Deleted: {data['user_id']}")
    return True
Enter fullscreen mode Exit fullscreen mode

Try it out

PyPI: https://pypi.org/project/dsn-sync/
GitHub: https://github.com/python-hacked

I would love feedback from the dev community — what features would you want next? Drop a comment below!

— Satish Choudhary

Top comments (0)