Jul 21, 2024
3
min. Reading Time

Federated Protocol for an Open Source Delivery App

Federated Protocol for an Open Source Delivery App

Federated Protocol for an Open Source Delivery App

Eduardo Moreno

Product Designer

This document outlines a federated protocol for an open-source delivery application designed to empower communities to create and manage their own restaurant and courier organizations. By leveraging the principles of the fediverse, this protocol enables decentralized and autonomous instances that can interoperate seamlessly. The protocol covers the interactions between consumers, restaurants, and couriers (drivers), ensuring a cohesive and efficient delivery ecosystem.

The rise of the gig economy and the increasing demand for food delivery services have highlighted the need for more community-driven and decentralized solutions. Traditional delivery platforms often centralize control and profits, leaving local communities with limited autonomy. This federated protocol aims to address these issues by providing a framework for communities to establish their own delivery networks, fostering local economic growth and resilience.




Key Components


1. Instances

An instance represents a self-contained unit within the fediverse, managed by a community or organization. Each instance can host multiple restaurants, couriers, and consumers. Instances communicate with each other using standardized protocols to ensure interoperability.



2. Actors

  • Consumers: Individuals who place orders for food delivery.

  • Restaurants: Establishments that prepare and sell food.

  • Couriers (Drivers): Individuals who deliver food from restaurants to consumers.

3. Communication Protocols

The protocol defines how instances and actors communicate, ensuring secure and reliable data exchange. Key communication protocols include:

  • Authentication: Secure methods for verifying the identity of actors within and across instances.

  • Order Management: Standardized messages for placing, updating, and tracking orders.

  • Delivery Coordination: Protocols for assigning and tracking deliveries.

  • Payment Processing: Secure methods for handling payments and transactions.


Protocol Specifications

1. Authentication

Each actor within an instance must be authenticated to ensure secure interactions. The protocol supports OAuth 2.0 for authentication, providing a robust and widely-adopted framework.

  • Consumer Authentication: Consumers authenticate using their instance credentials.

  • Restaurant Authentication: Restaurants authenticate using instance-issued API keys.

  • Courier Authentication: Couriers authenticate using instance-specific tokens.

2. Order Management

Order management involves the lifecycle of an order from creation to completion. The protocol defines the following messages:

  • Order Creation: Consumers send an OrderCreate message to the restaurant's instance.

  • Order Confirmation: Restaurants respond with an OrderConfirm message.

  • Order Update: Any changes to the order are communicated via OrderUpdate messages.

  • Order Cancellation: Consumers or restaurants can cancel orders using an OrderCancel message.

3. Delivery Coordination

Delivery coordination ensures that orders are efficiently assigned and tracked. The protocol includes:

  • Delivery Assignment: Restaurants send a DeliveryAssign message to available couriers.

  • Delivery Acceptance: Couriers respond with a DeliveryAccept message.

  • Delivery Tracking: Real-time updates are sent using DeliveryUpdate messages.

  • Delivery Completion: Couriers confirm delivery with a DeliveryComplete message.

4. Payment Processing

Secure payment processing is crucial for the success of the delivery app. The protocol supports:

  • Payment Initiation: Consumers initiate payments using a PaymentInitiate message.

  • Payment Confirmation: Payment gateways respond with a PaymentConfirm message.

  • Refund Processing: Refunds are handled via PaymentRefund messages.


Inter-Instance Communication

Instances must communicate to facilitate cross-instance orders and deliveries. The protocol supports:

  • Instance Discovery: Instances discover each other using a federated directory service.

  • Cross-Instance Orders: Orders can be placed across instances using standardized messages.

  • Cross-Instance Deliveries: Deliveries can be coordinated between instances, ensuring seamless service.




Security Considerations

Security is paramount in a federated system. The protocol includes:

  • Data Encryption: All communications are encrypted using TLS.

  • Access Control: Role-based access control ensures that actors have appropriate permissions.

  • Audit Logs: Instances maintain audit logs for all transactions and interactions.


Conclusion

This federated protocol provides a comprehensive framework for an open-source delivery app, enabling communities to create and manage their own delivery networks. By adhering to the principles of the fediverse, the protocol ensures interoperability, security, and autonomy, fostering a more equitable and resilient delivery ecosystem.