Skip to content

feat(examples): Add P2P Calc, EtherCalc-powered collaborative spreadsheet example using py-libp2p#1382

Merged
seetadev merged 18 commits into
libp2p:mainfrom
seetadev:feat/p2pcalc-ethercalc-libp2p-integration
Jul 12, 2026
Merged

feat(examples): Add P2P Calc, EtherCalc-powered collaborative spreadsheet example using py-libp2p#1382
seetadev merged 18 commits into
libp2p:mainfrom
seetadev:feat/p2pcalc-ethercalc-libp2p-integration

Conversation

@seetadev

@seetadev seetadev commented Jul 11, 2026

Copy link
Copy Markdown
Member

Summary

This PR adds P2P Calc to the examples/ directory of py-libp2p as a comprehensive reference application built on top of EtherCalc. The example extends EtherCalc with native py-libp2p networking, demonstrating how collaborative spreadsheets can operate over secure peer-to-peer connections.

Unlike basic networking examples, P2P Calc showcases py-libp2p in a real-world application, providing developers with an end-to-end example of building decentralized collaborative software.

What's Included

  • Add P2P Calc as a new example under examples/.
  • Extend EtherCalc with py-libp2p for peer-to-peer collaboration.
  • Demonstrate decentralized spreadsheet synchronization between peers.
  • Showcase secure communication using libp2p networking primitives.
  • Provide a reusable architecture for collaborative applications built with py-libp2p.

Why This Matters

While py-libp2p includes examples covering networking primitives, developers often look for complete applications that demonstrate how these components fit together. P2P Calc fills this gap by providing a practical, production-inspired example of decentralized collaboration.

This example will help developers understand:

  • Integrating py-libp2p into existing applications.
  • Managing peer-to-peer communication and synchronization.
  • Building collaborative applications on top of libp2p.
  • Designing modular networking layers that can be reused across projects.

Impact

P2P Calc becomes a flagship example for the py-libp2p ecosystem, making it easier for new contributors to learn the library through a familiar application. It also supports broader ecosystem growth by demonstrating a compelling real-world use case for py-libp2p, encouraging adoption across collaborative software, distributed systems, AI agent frameworks, and Web3 applications.

This example aligns with ongoing efforts to expand the py-libp2p ecosystem through high-quality developer tooling, practical reference implementations, and educational resources.

seetadev and others added 18 commits November 6, 2025 11:47
Added a new issue template for the DMP 2026 project, including fields for project description, goals, setup, expected outcomes, acceptance criteria, implementation details, mockups, product name, organization name, governance domain, technical skills required, mentors, and categories.
Adds examples/p2pcalc/ — a working integration layer that replaces
EtherCalc's centralised Redis pub-sub sync with py-libp2p GossipSub.

Architecture:
- operation.py: SocialCalc command encoding with Hybrid Logical Clocks
  and MessagePack serialisation
- crdt.py: Multi-Value Register (cell conflicts) + RGA (structural ops)
- adapter.py: Redis <-> GossipSub bridge (zero EtherCalc source changes)
- p2p_node.py: libp2p host with GossipSub v2.0, topic-per-sheet design
- state_sync.py: two-phase late-joiner snapshot + op-log replay

Innovations beyond baseline:
- HLC timestamps instead of wall clocks (causal ordering across peers)
- MVR conflict detection surfaces concurrent edits rather than silently
  dropping them (unlike LWW)
- RGA for row/col structural ops handles concurrent inserts correctly
- Causal buffering ensures out-of-order ops are applied correctly
- Echo loop prevention at Redis inject layer
- Local op-log WAL for crash recovery without full network resync

Tests: 42 unit tests, no network or Redis required.

Closes #34
- main.py: split long help string (E501, was 103 chars)
- state_sync.py: replace os.path.join/makedirs with pathlib.Path (path-audit P1)
- test_p2pcalc.py: replace os.path.dirname/abspath with pathlib.Path (path-audit P1)
- p2pcalc/__init__.py: add module docstring
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@seetadev

Copy link
Copy Markdown
Member Author

@yashksaini-coder, @DZDasherKTB : Thank you guys for this initiative. We will evolve this project with Filecoin and IPFS clients in the coming days and will discuss it in the upcoming calls.

Also, wish to thank @sumanjeet0012 for his support.

@seetadev seetadev changed the title Feat/p2pcalc ethercalc libp2p integration feat(examples): Add P2P Calc, EtherCalc-powered collaborative spreadsheet example using py-libp2p Jul 12, 2026
@seetadev seetadev merged commit e67729e into libp2p:main Jul 12, 2026
38 checks passed
@seetadev seetadev deleted the feat/p2pcalc-ethercalc-libp2p-integration branch July 12, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants