Inspiration

The primary inspiration for Safe Connect comes from a deeply personal and urgent need. As residents of Turkey, we live in a region with constant seismic activity. The recent major earthquake was a tragic reminder of our vulnerability, causing immense loss of life and highlighting a critical failure in our infrastructure: communication. During the disaster, mobile operators failed, leaving countless people unable to contact loved ones, coordinate rescue efforts, or even signal for help. This widespread communication blackout was not just an inconvenience; it was a life-threatening problem. The ongoing reality of frequent earthquakes means this is a persistent threat. This project was born from that experience. The "aha!" moment was the realization that we could build a resilient, decentralized communication system that doesn't depend on the same centralized infrastructure that fails us in our most critical moments. Safe Connect is our answer to this challenge, designed to provide a reliable lifeline when all else fails.

What it does

Safe Connect provides an end-to-end encrypted, peer-to-peer communication platform. It enables users to establish direct connections, exchange messages, and share data securely without relying on centralized servers. Key features include:

  • Decentralized Network: Utilizes WebRTC for direct peer-to-peer connections, minimizing reliance on intermediaries.
  • End-to-End Encryption: All communications are encrypted from the sender to the receiver, ensuring privacy and data integrity.
  • Offline Messaging (Conceptual): While primary communication is real-time, we are exploring mechanisms for message relay through trusted nodes when direct connections are not immediately possible.
  • Adaptive Connectivity: Designed to function in challenging network conditions, potentially using alternative transport methods.
  • LaTeX Support for Math: For technical or scientific discussions, Safe Connect allows for seamless rendering of mathematical equations using LaTeX. For example, the quadratic formula can be written as $x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}$.

How we built it

Safe Connect was built using a modern stack focused on performance, security, and scalability.

  • Frontend: React with Vite for a fast and reactive user interface, styled with Tailwind CSS for rapid and consistent UI development.
  • Backend: FastAPI (Python) for a high-performance, asynchronous API gateway, handling initial peer discovery and signaling.
  • Real-time Communication: WebRTC for establishing direct, encrypted peer-to-peer connections between users.
  • State Management: React Context API for efficient global state management in the frontend.
  • Database: IndexedDB (via dexie.js) for local, persistent storage of messages and user data, ensuring data availability even offline.
  • Mapping: Maptiler for interactive and customizable maps.
  • Development Workflow: Agile methodology with daily stand-ups and continuous integration/continuous deployment (CI/CD) practices.

Challenges we ran into

We faced several significant challenges:

  • WebRTC Complexity: Implementing robust WebRTC connections, particularly NAT traversal and ICE candidate gathering, proved to be complex. We extensively debugged and experimented with various STUN/TURN server configurations to ensure reliable connections.
  • Security & Encryption: Ensuring true end-to-end encryption across all communication channels, especially for peer-to-peer setups, required careful design and implementation of cryptographic protocols. We relied on established libraries and best practices to mitigate vulnerabilities.
  • Offline Functionality: Designing a robust offline messaging system that balances data persistence, eventual consistency, and security without a centralized server was a major hurdle. This is still an area of active research and development for us.
  • Scalability of Signaling: While WebRTC is P2P, the initial signaling server needs to be robust. We designed our FastAPI backend to be lightweight and horizontally scalable to handle increasing user loads.

Accomplishments that we're proud of

We are particularly proud of:

  • Successfully implementing a functional end-to-end encrypted peer-to-peer communication system using WebRTC.
  • Creating a responsive and intuitive user interface that makes secure communication accessible.
  • The resilience of our system in establishing connections under varying network conditions.
  • Our ability to integrate complex technologies like WebRTC and FastAPI into a cohesive and performant application.

What we learned

This project provided invaluable learning experiences:

  • Deep dive into WebRTC: Gained extensive knowledge of WebRTC signaling, ICE, STUN/TURN, and data channels.
  • Advanced React & State Management: Enhanced our skills in building complex React applications and managing global state effectively.
  • Asynchronous Programming in Python: Improved our understanding and application of async/await with FastAPI.
  • Security Best Practices: Reinforced the importance of secure coding practices, encryption, and threat modeling in real-world applications.
  • Decentralized System Design: Explored the intricacies of designing and implementing decentralized systems.

What's next for Safe Connect

For the future of Safe Connect, we envision:

  • Group Chat Functionality: Expanding to support secure group conversations.
  • File Sharing: Implementing encrypted file transfer between peers.
  • Improved Offline Capabilities: Developing a more robust message relay and synchronization mechanism for offline users.
  • Mobile Applications: Creating native mobile applications for iOS and Android to broaden accessibility.
  • Further Decentralization: Exploring blockchain or distributed hash table (DHT) based signaling for even greater resilience and censorship resistance.
  • Community Building: Fostering a community of users and contributors to enhance and expand Safe Connect.

Built With

Share this project:

Updates