🎯 Recommended Samples
Balanced sample collections from various categories for you to explore
Protocol Buffers Samples
Protocol Buffers (protobuf) schema examples from simple to complex data structures
📝 Basic User Schema
🟢 simple
Simple user information protobuf schema
syntax = "proto3";
package user;
// Basic User Information Schema
message User {
string user_id = 1;
string username = 2;
string email = 3;
string first_name = 4;
string last_name = 5;
enum Gender {
GENDER_UNSPECIFIED = 0;
MALE = 1;
FEMALE = 2;
OTHER = 3;
}
Gender gender = 6;
string phone_number = 7;
string avatar_url = 8;
enum UserStatus {
STATUS_UNSPECIFIED = 0;
ACTIVE = 1;
INACTIVE = 2;
SUSPENDED = 3;
DELETED = 4;
}
UserStatus status = 9;
int64 created_at = 10;
int64 updated_at = 11;
int64 last_login_at = 12;
}
message UserProfile {
User user = 1;
string bio = 2;
string location = 3;
string website = 4;
repeated string interests = 5;
repeated string skills = 6;
message SocialLinks {
string github = 1;
string twitter = 2;
string linkedin = 3;
string facebook = 4;
string instagram = 5;
}
SocialLinks social_links = 7;
message Preferences {
string language = 1;
string timezone = 2;
string theme = 3;
bool email_notifications = 4;
bool push_notifications = 5;
}
Preferences preferences = 8;
}
message UserList {
repeated User users = 1;
int32 total_count = 2;
int32 page = 3;
int32 page_size = 4;
}
message CreateUserRequest {
string username = 1;
string email = 2;
string password = 3;
string first_name = 4;
string last_name = 5;
}
message CreateUserResponse {
bool success = 1;
string message = 2;
User user = 3;
}
message GetUserRequest {
oneof identifier {
string user_id = 1;
string username = 2;
string email = 3;
}
}
message GetUserResponse {
bool success = 1;
string message = 2;
UserProfile user_profile = 3;
}
📝 IoT Device Schema
🟡 intermediate
IoT device data transmission protobuf schema
syntax = "proto3";
package iot;
// IoT Device Data Transmission Schema
message DeviceInfo {
string device_id = 1;
string device_name = 2;
string device_type = 3;
string manufacturer = 4;
string model = 5;
string firmware_version = 6;
string hardware_version = 7;
string serial_number = 8;
enum DeviceStatus {
DEVICE_STATUS_UNSPECIFIED = 0;
ONLINE = 1;
OFFLINE = 2;
ERROR = 3;
MAINTENANCE = 4;
DISABLED = 5;
}
DeviceStatus status = 9;
double battery_level = 10;
double signal_strength = 11;
int64 last_seen = 12;
string location = 13;
}
message SensorData {
string sensor_id = 1;
string sensor_type = 2;
double value = 3;
string unit = 4;
int64 timestamp = 5;
double quality = 6; // Data quality score 0-1
message Metadata {
repeated string tags = 1;
map<string, string> properties = 2;
}
Metadata metadata = 7;
}
message TelemetryData {
string device_id = 1;
int64 timestamp = 2;
repeated SensorData sensors = 3;
message Location {
double latitude = 1;
double longitude = 2;
double altitude = 3;
double accuracy = 4;
}
Location location = 4;
message DeviceMetrics {
double cpu_usage = 1;
double memory_usage = 2;
double disk_usage = 3;
double network_usage = 4;
double temperature = 5;
int64 uptime = 6;
}
DeviceMetrics device_metrics = 5;
repeated string events = 6;
repeated string alerts = 7;
}
message DeviceCommand {
string command_id = 1;
string device_id = 2;
string command_type = 3;
string payload = 4;
int64 timestamp = 5;
int64 timeout = 6;
enum CommandStatus {
COMMAND_STATUS_UNSPECIFIED = 0;
PENDING = 1;
EXECUTING = 2;
COMPLETED = 3;
FAILED = 4;
TIMEOUT = 5;
CANCELLED = 6;
}
CommandStatus status = 7;
string error_message = 8;
string result = 9;
int64 executed_at = 10;
int64 completed_at = 11;
}
message DeviceAlert {
string alert_id = 1;
string device_id = 2;
string alert_type = 3;
string severity = 4; // critical, warning, info
string message = 5;
map<string, string> parameters = 6;
int64 timestamp = 7;
bool acknowledged = 8;
string acknowledged_by = 9;
int64 acknowledged_at = 10;
bool resolved = 11;
string resolved_by = 12;
int64 resolved_at = 13;
}
message DeviceConfig {
string device_id = 1;
int64 version = 2;
int64 applied_at = 3;
map<string, string> settings = 4;
repeated SensorConfig sensor_configs = 5;
message SensorConfig {
string sensor_id = 1;
bool enabled = 2;
double sampling_rate = 3;
double threshold_min = 4;
double threshold_max = 5;
map<string, string> parameters = 6;
}
}
message DeviceRegistration {
string device_id = 1;
string device_type = 2;
string manufacturer = 3;
string model = 4;
string firmware_version = 5;
map<string, string> metadata = 6;
string auth_token = 7;
int64 registered_at = 8;
}
message TelemetryBatch {
string device_id = 1;
repeated TelemetryData telemetry_data = 2;
int64 batch_timestamp = 3;
int32 message_count = 4;
}
// IoT Device Service Definition
service IoTDeviceService {
// Register a new device
rpc RegisterDevice(DeviceRegistration) returns (DeviceInfo);
// Send telemetry data
rpc SendTelemetry(TelemetryData) returns (Empty);
// Send batch telemetry data
rpc SendTelemetryBatch(TelemetryBatch) returns (Empty);
// Send device alert
rpc SendAlert(DeviceAlert) returns (Empty);
// Get device info
rpc GetDeviceInfo(GetDeviceInfoRequest) returns (DeviceInfo);
// List devices
rpc ListDevices(ListDevicesRequest) returns (ListDevicesResponse);
// Update device config
rpc UpdateDeviceConfig(DeviceConfig) returns (Empty);
// Send command to device
rpc SendCommand(DeviceCommand) returns (DeviceCommand);
// Get device status
rpc GetDeviceStatus(GetDeviceStatusRequest) returns (DeviceStatus);
// Stream telemetry data (server streaming)
rpc StreamTelemetry(StreamTelemetryRequest) returns (stream TelemetryData);
}
message Empty {}
message GetDeviceInfoRequest {
string device_id = 1;
}
message ListDevicesRequest {
int32 page = 1;
int32 page_size = 2;
DeviceStatus status = 3;
string device_type = 4;
}
message ListDevicesResponse {
repeated DeviceInfo devices = 1;
int32 total_count = 2;
int32 page = 3;
int32 page_size = 4;
}
message GetDeviceStatusRequest {
string device_id = 1;
}
message DeviceStatus {
string device_id = 1;
DeviceInfo.DeviceStatus status = 2;
int64 last_seen = 3;
double battery_level = 4;
double signal_strength = 5;
}
message StreamTelemetryRequest {
string device_id = 1;
int64 start_timestamp = 2;
int64 end_timestamp = 3;
repeated string sensor_types = 4;
}
📝 E-commerce Order Schema
🔴 complex
Complete e-commerce order system protobuf schema
syntax = "proto3";
package ecommerce;
// E-commerce Order Management System
message Product {
string product_id = 1;
string name = 2;
string description = 3;
double price = 4;
string currency = 5;
enum ProductStatus {
STATUS_UNSPECIFIED = 0;
ACTIVE = 1;
INACTIVE = 2;
OUT_OF_STOCK = 3;
DISCONTINUED = 4;
}
ProductStatus status = 6;
int32 stock_quantity = 7;
repeated string categories = 8;
repeated string tags = 9;
message Image {
string url = 1;
string alt_text = 2;
int32 width = 3;
int32 height = 4;
}
repeated Image images = 10;
message Dimensions {
double length = 1;
double width = 2;
double height = 3;
double weight = 4;
string unit = 5;
}
Dimensions dimensions = 11;
int64 created_at = 12;
int64 updated_at = 13;
}
message OrderItem {
string product_id = 1;
string product_name = 2;
int32 quantity = 3;
double unit_price = 4;
double total_price = 5;
string currency = 6;
repeated string variant_options = 7;
}
message ShippingAddress {
string street_address = 1;
string city = 2;
string state = 3;
string postal_code = 4;
string country = 5;
string address_type = 6; // shipping, billing
string recipient_name = 7;
string phone_number = 8;
}
message PaymentInfo {
string payment_id = 1;
string payment_method = 2; // credit_card, paypal, bank_transfer
enum PaymentStatus {
PAYMENT_UNSPECIFIED = 0;
PENDING = 1;
PROCESSING = 2;
COMPLETED = 3;
FAILED = 4;
REFUNDED = 5;
CANCELLED = 6;
}
PaymentStatus status = 3;
double amount = 4;
string currency = 5;
string transaction_id = 6;
int64 payment_date = 7;
message CreditCardInfo {
string last_four_digits = 1;
string card_type = 2;
string expiry_month = 3;
string expiry_year = 4;
string cardholder_name = 5;
}
CreditCardInfo credit_card_info = 8;
}
message Order {
string order_id = 1;
string customer_id = 2;
string customer_email = 3;
enum OrderStatus {
ORDER_STATUS_UNSPECIFIED = 0;
PENDING = 1;
CONFIRMED = 2;
PROCESSING = 3;
SHIPPED = 4;
DELIVERED = 5;
CANCELLED = 6;
REFUNDED = 7;
RETURNED = 8;
}
OrderStatus status = 4;
repeated OrderItem items = 5;
double subtotal = 6;
double tax_amount = 7;
double shipping_cost = 8;
double discount_amount = 9;
double total_amount = 10;
string currency = 11;
ShippingAddress shipping_address = 12;
ShippingAddress billing_address = 13;
PaymentInfo payment_info = 14;
message ShippingInfo {
string tracking_number = 1;
string carrier = 2;
string shipping_method = 3;
int64 shipped_at = 4;
int64 estimated_delivery = 5;
int64 actual_delivery = 6;
}
ShippingInfo shipping_info = 15;
int64 created_at = 16;
int64 updated_at = 17;
string notes = 18;
}
message OrderList {
repeated Order orders = 1;
int32 total_count = 2;
int32 page = 3;
int32 page_size = 4;
}
message CreateOrderRequest {
string customer_id = 1;
string customer_email = 2;
repeated OrderItem items = 3;
ShippingAddress shipping_address = 4;
ShippingAddress billing_address = 5;
string payment_method = 6;
string discount_code = 7;
string notes = 8;
}
message CreateOrderResponse {
bool success = 1;
string message = 2;
Order order = 3;
string redirect_url = 4;
}
message GetOrdersRequest {
string customer_id = 1;
OrderStatus status = 2;
int32 page = 3;
int32 page_size = 4;
int64 start_date = 5;
int64 end_date = 6;
}
message GetOrdersResponse {
bool success = 1;
string message = 2;
OrderList order_list = 3;
}
message UpdateOrderStatusRequest {
string order_id = 1;
OrderStatus status = 2;
string notes = 3;
message ShippingInfoUpdate {
string tracking_number = 1;
string carrier = 2;
int64 estimated_delivery = 3;
}
ShippingInfoUpdate shipping_info = 4;
}
message UpdateOrderStatusResponse {
bool success = 1;
string message = 2;
Order order = 3;
}
📝 Chat System Schema
🔴 complex
Real-time chat system protobuf schema definition
syntax = "proto3";
package chat;
// Real-time Chat System Schema
message User {
string user_id = 1;
string username = 2;
string display_name = 3;
string avatar_url = 4;
enum UserStatus {
STATUS_UNSPECIFIED = 0;
ONLINE = 1;
AWAY = 2;
BUSY = 3;
INVISIBLE = 4;
OFFLINE = 5;
}
UserStatus status = 5;
string status_message = 6;
int64 last_seen = 7;
bool is_typing = 8;
}
message Message {
string message_id = 1;
string chat_id = 2;
string sender_id = 3;
string content = 4;
int64 timestamp = 5;
enum MessageType {
MESSAGE_TYPE_UNSPECIFIED = 0;
TEXT = 1;
IMAGE = 2;
FILE = 3;
VOICE = 4;
VIDEO = 5;
LOCATION = 6;
CONTACT = 7;
SYSTEM = 8;
}
MessageType type = 6;
message MediaInfo {
string url = 1;
string file_name = 2;
string mime_type = 3;
int64 file_size = 4;
int32 width = 5;
int32 height = 6;
int32 duration = 7; // for audio/video in seconds
}
MediaInfo media_info = 7;
message ReplyInfo {
string original_message_id = 1;
string original_sender_id = 2;
string original_content = 3;
int64 original_timestamp = 4;
}
ReplyInfo reply_info = 8;
message ForwardInfo {
string original_chat_id = 1;
string original_sender_id = 2;
int64 original_timestamp = 3;
}
ForwardInfo forward_info = 9;
enum MessageStatus {
MESSAGE_STATUS_UNSPECIFIED = 0;
SENT = 1;
DELIVERED = 2;
READ = 3;
FAILED = 4;
DELETED = 5;
}
MessageStatus status = 10;
int64 edited_at = 11;
int64 deleted_at = 12;
}
message Chat {
string chat_id = 1;
string chat_name = 2;
string description = 3;
enum ChatType {
CHAT_TYPE_UNSPECIFIED = 0;
DIRECT = 1;
GROUP = 2;
CHANNEL = 3;
BROADCAST = 4;
}
ChatType type = 4;
string avatar_url = 5;
repeated string participants = 6;
string admin_id = 7;
message GroupInfo {
repeated string admins = 1;
bool read_only = 2;
bool join_approval_required = 3;
int32 max_participants = 4;
}
GroupInfo group_info = 8;
message LastMessage {
string message_id = 1;
string content = 2;
string sender_id = 3;
int64 timestamp = 4;
MessageType type = 5;
}
LastMessage last_message = 9;
int64 created_at = 10;
int64 updated_at = 11;
message UnreadCount {
int32 total = 1;
int32 mentions = 2;
}
UnreadCount unread_count = 12;
bool is_pinned = 13;
bool is_muted = 14;
}
message ChatList {
repeated Chat chats = 1;
int32 total_count = 2;
int32 unread_chats = 3;
int32 unread_messages = 4;
}
message SendMessageRequest {
string chat_id = 1;
string content = 2;
MessageType type = 3;
string reply_to_message_id = 4;
MediaInfo media_info = 5;
}
message SendMessageResponse {
bool success = 1;
string message = 2;
Message sent_message = 3;
}
message GetChatsRequest {
int32 page = 1;
int32 page_size = 2;
bool archived_only = 3;
bool pinned_only = 4;
}
message GetChatsResponse {
bool success = 1;
string message = 2;
ChatList chat_list = 3;
}
message GetMessagesRequest {
string chat_id = 1;
string from_message_id = 2;
int32 limit = 3;
bool older_messages = 4;
}
message GetMessagesResponse {
bool success = 1;
string message = 2;
repeated Message messages = 3;
bool has_more = 4;
}
message TypingEvent {
string chat_id = 1;
string user_id = 2;
bool is_typing = 3;
int64 timestamp = 4;
}
message UserStatusEvent {
string user_id = 1;
UserStatus status = 2;
string status_message = 3;
int64 last_seen = 4;
}
message ReadReceipt {
string message_id = 1;
string user_id = 2;
int64 read_at = 3;
}
message NotificationEvent {
string event_type = 1;
string chat_id = 2;
string user_id = 3;
Message message = 4;
int64 timestamp = 5;
}
// Chat Service Definition
service ChatService {
// Send a message
rpc SendMessage(SendMessageRequest) returns (SendMessageResponse);
// Get chat list
rpc GetChats(GetChatsRequest) returns (GetChatsResponse);
// Get messages in a chat
rpc GetMessages(GetMessagesRequest) returns (GetMessagesResponse);
// Mark message as read
rpc MarkMessageRead(ReadReceipt) returns (Empty);
// Create group chat
rpc CreateGroupChat(CreateGroupChatRequest) returns (CreateGroupChatResponse);
// Join chat
rpc JoinChat(JoinChatRequest) returns (JoinChatResponse);
// Leave chat
rpc LeaveChat(LeaveChatRequest) returns (LeaveChatResponse);
}
message Empty {}
message CreateGroupChatRequest {
string chat_name = 1;
string description = 2;
repeated string participants = 3;
string avatar_url = 4;
}
message CreateGroupChatResponse {
bool success = 1;
string message = 2;
Chat chat = 3;
}
message JoinChatRequest {
string chat_id = 1;
string invite_link = 2;
}
message JoinChatResponse {
bool success = 1;
string message = 2;
Chat chat = 3;
}
message LeaveChatRequest {
string chat_id = 1;
bool delete_for_everyone = 2;
}
message LeaveChatResponse {
bool success = 1;
string message = 2;
}
📝 gRPC Service Schema
🔴 complex
gRPC service protobuf service definition
syntax = "proto3";
package userservice;
import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";
// User Management gRPC Service
message User {
string user_id = 1;
string username = 2;
string email = 3;
string first_name = 4;
string last_name = 5;
string phone_number = 6;
string avatar_url = 7;
enum Gender {
GENDER_UNSPECIFIED = 0;
MALE = 1;
FEMALE = 2;
OTHER = 3;
}
Gender gender = 8;
enum UserStatus {
STATUS_UNSPECIFIED = 0;
ACTIVE = 1;
INACTIVE = 2;
SUSPENDED = 3;
DELETED = 4;
}
UserStatus status = 9;
google.protobuf.Timestamp created_at = 10;
google.protobuf.Timestamp updated_at = 11;
google.protobuf.Timestamp last_login_at = 12;
}
message UserProfile {
User user = 1;
string bio = 2;
string location = 3;
string website = 4;
repeated string interests = 5;
repeated string skills = 6;
message SocialLinks {
string github = 1;
string twitter = 2;
string linkedin = 3;
string facebook = 4;
string instagram = 5;
}
SocialLinks social_links = 7;
message Preferences {
string language = 1;
string timezone = 2;
string theme = 3;
bool email_notifications = 4;
bool push_notifications = 5;
}
Preferences preferences = 8;
}
message CreateUserRequest {
string username = 1;
string email = 2;
string password = 3;
string first_name = 4;
string last_name = 5;
string phone_number = 6;
Gender gender = 7;
}
message CreateUserResponse {
bool success = 1;
string message = 2;
User user = 3;
}
message GetUserRequest {
oneof identifier {
string user_id = 1;
string username = 2;
string email = 3;
}
}
message GetUserResponse {
bool success = 1;
string message = 2;
UserProfile user_profile = 3;
}
message UpdateUserRequest {
string user_id = 1;
optional string first_name = 2;
optional string last_name = 3;
optional string phone_number = 4;
optional Gender gender = 5;
optional string avatar_url = 6;
}
message UpdateUserResponse {
bool success = 1;
string message = 2;
User user = 3;
}
message DeleteUserRequest {
string user_id = 1;
bool hard_delete = 2;
}
message DeleteUserResponse {
bool success = 1;
string message = 2;
}
message ListUsersRequest {
int32 page = 1;
int32 page_size = 2;
UserStatus status = 3;
string search_query = 4;
string sort_by = 5;
string sort_order = 6;
}
message ListUsersResponse {
bool success = 1;
string message = 2;
repeated User users = 3;
int32 total_count = 4;
int32 page = 5;
int32 page_size = 6;
}
message AuthenticateUserRequest {
string username = 1;
string password = 2;
}
message AuthenticateUserResponse {
bool success = 1;
string message = 2;
User user = 3;
string access_token = 4;
string refresh_token = 5;
int64 expires_in = 6;
}
message RefreshTokenRequest {
string refresh_token = 1;
}
message RefreshTokenResponse {
bool success = 1;
string message = 2;
string access_token = 3;
string refresh_token = 4;
int64 expires_in = 5;
}
message ChangePasswordRequest {
string user_id = 1;
string current_password = 2;
string new_password = 3;
}
message ChangePasswordResponse {
bool success = 1;
string message = 2;
}
message UploadAvatarRequest {
string user_id = 1;
bytes avatar_data = 2;
string file_name = 3;
string mime_type = 4;
}
message UploadAvatarResponse {
bool success = 1;
string message = 2;
string avatar_url = 3;
}
// User Management gRPC Service Definition
service UserService {
// Create a new user
rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);
// Get user by ID, username, or email
rpc GetUser(GetUserRequest) returns (GetUserResponse);
// Update user information
rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse);
// Delete user
rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse);
// List users with pagination and filtering
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse);
// Authenticate user credentials
rpc AuthenticateUser(AuthenticateUserRequest) returns (AuthenticateUserResponse);
// Refresh access token
rpc RefreshToken(RefreshTokenRequest) returns (RefreshTokenResponse);
// Change user password
rpc ChangePassword(ChangePasswordRequest) returns (ChangePasswordResponse);
// Upload user avatar
rpc UploadAvatar(stream UploadAvatarRequest) returns (UploadAvatarResponse);
// Get current user (from auth token)
rpc GetCurrentUser(google.protobuf.Empty) returns (GetUserResponse);
// Validate user token
rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse);
// Logout user
rpc Logout(LogoutRequest) returns (LogoutResponse);
}
message ValidateTokenRequest {
string access_token = 1;
}
message ValidateTokenResponse {
bool success = 1;
string message = 2;
string user_id = 3;
int64 expires_at = 4;
}
message LogoutRequest {
string access_token = 1;
}
message LogoutResponse {
bool success = 1;
string message = 2;
}
📝 Financial Transaction Schema
🔴 complex
Financial transaction system protobuf data schema
syntax = "proto3";
package financial;
import "google/protobuf/timestamp.proto";
// Financial Transaction System Schema
message Account {
string account_id = 1;
string account_number = 2;
string customer_id = 3;
enum AccountType {
ACCOUNT_TYPE_UNSPECIFIED = 0;
CHECKING = 1;
SAVINGS = 2;
CREDIT_CARD = 3;
INVESTMENT = 4;
LOAN = 5;
}
AccountType account_type = 4;
enum AccountStatus {
ACCOUNT_STATUS_UNSPECIFIED = 0;
ACTIVE = 1;
INACTIVE = 2;
FROZEN = 3;
CLOSED = 4;
SUSPENDED = 5;
}
AccountStatus status = 5;
double balance = 6;
string currency = 7;
double credit_limit = 8;
double available_balance = 9;
google.protobuf.Timestamp created_at = 10;
google.protobuf.Timestamp updated_at = 11;
google.protobuf.Timestamp last_activity = 12;
}
message Transaction {
string transaction_id = 1;
string account_id = 2;
string reference_id = 3;
string description = 4;
double amount = 5;
string currency = 6;
enum TransactionType {
TRANSACTION_TYPE_UNSPECIFIED = 0;
DEBIT = 1;
CREDIT = 2;
TRANSFER_IN = 3;
TRANSFER_OUT = 4;
PAYMENT = 5;
REFUND = 6;
FEE = 7;
INTEREST = 8;
}
TransactionType transaction_type = 7;
enum TransactionStatus {
TRANSACTION_STATUS_UNSPECIFIED = 0;
PENDING = 1;
PROCESSING = 2;
COMPLETED = 3;
FAILED = 4;
CANCELLED = 5;
REVERSED = 6;
}
TransactionStatus status = 8;
google.protobuf.Timestamp transaction_date = 9;
google.protobuf.Timestamp post_date = 10;
message Counterparty {
string name = 1;
string account_number = 2;
string bank_code = 3;
string address = 4;
}
Counterparty counterparty = 11;
repeated string tags = 12;
string category = 13;
string subcategory = 14;
message Metadata {
map<string, string> custom_fields = 1;
string external_reference = 2;
string source = 3;
}
Metadata metadata = 15;
}
message Payment {
string payment_id = 1;
string payer_account_id = 2;
string payee_account_id = 3;
double amount = 4;
string currency = 5;
string reference = 6;
string description = 7;
enum PaymentMethod {
PAYMENT_METHOD_UNSPECIFIED = 0;
BANK_TRANSFER = 1;
CREDIT_CARD = 2;
DEBIT_CARD = 3;
DIGITAL_WALLET = 4;
CRYPTOCURRENCY = 5;
CASH = 6;
}
PaymentMethod payment_method = 8;
enum PaymentStatus {
PAYMENT_STATUS_UNSPECIFIED = 0;
INITIATED = 1;
PENDING = 2;
PROCESSING = 3;
COMPLETED = 4;
FAILED = 5;
CANCELLED = 6;
REFUNDED = 7;
}
PaymentStatus status = 9;
google.protobuf.Timestamp created_at = 10;
google.protobuf.Timestamp completed_at = 11;
message Fees {
double processing_fee = 1;
double transaction_fee = 2;
double currency_conversion_fee = 3;
string fee_currency = 4;
}
Fees fees = 12;
message ExchangeRate {
string from_currency = 1;
string to_currency = 2;
double rate = 3;
google.protobuf.Timestamp rate_date = 4;
}
ExchangeRate exchange_rate = 13;
}
message Card {
string card_id = 1;
string account_id = 2;
string card_number_masked = 3;
string cardholder_name = 4;
enum CardType {
CARD_TYPE_UNSPECIFIED = 0;
DEBIT = 1;
CREDIT = 2;
PREPAID = 3;
}
CardType card_type = 4;
enum CardBrand {
CARD_BRAND_UNSPECIFIED = 0;
VISA = 1;
MASTERCARD = 2;
AMERICAN_EXPRESS = 3;
DISCOVER = 4;
JCB = 5;
UNIONPAY = 6;
}
CardBrand card_brand = 5;
string expiry_month = 6;
string expiry_year = 7;
bool is_active = 8;
bool is_contactless = 9;
double credit_limit = 10;
double available_credit = 11;
google.protobuf.Timestamp issued_at = 12;
google.protobuf.Timestamp expires_at = 13;
google.protobuf.Timestamp last_used = 14;
}
message Customer {
string customer_id = 1;
string first_name = 2;
string last_name = 3;
string email = 4;
string phone_number = 5;
string date_of_birth = 6;
string ssn_last_4 = 7;
enum CustomerStatus {
CUSTOMER_STATUS_UNSPECIFIED = 0;
ACTIVE = 1;
INACTIVE = 2;
SUSPENDED = 3;
CLOSED = 4;
VERIFIED = 5;
UNVERIFIED = 6;
}
CustomerStatus status = 8;
enum CustomerTier {
CUSTOMER_TIER_UNSPECIFIED = 0;
BASIC = 1;
SILVER = 2;
GOLD = 3;
PLATINUM = 4;
}
CustomerTier tier = 9;
message Address {
string street = 1;
string city = 2;
string state = 3;
string postal_code = 4;
string country = 5;
bool is_primary = 6;
}
repeated Address addresses = 10;
google.protobuf.Timestamp created_at = 11;
google.protobuf.Timestamp updated_at = 12;
google.protobuf.Timestamp last_login = 13;
}
message TransactionList {
repeated Transaction transactions = 1;
int32 total_count = 2;
int32 page = 3;
int32 page_size = 4;
double total_debits = 5;
double total_credits = 6;
}
message AccountSummary {
Account account = 1;
double current_balance = 2;
double available_balance = 3;
double pending_debits = 4;
double pending_credits = 5;
message RecentTransaction {
string transaction_id = 1;
string description = 2;
double amount = 3;
google.protobuf.Timestamp date = 4;
}
repeated RecentTransaction recent_transactions = 6;
google.protobuf.Timestamp as_of_date = 7;
}
// Financial Service Definition
service FinancialService {
// Create new account
rpc CreateAccount(CreateAccountRequest) returns (CreateAccountResponse);
// Get account information
rpc GetAccount(GetAccountRequest) returns (Account);
// Get account summary
rpc GetAccountSummary(GetAccountSummaryRequest) returns (AccountSummary);
// Get transactions
rpc GetTransactions(GetTransactionsRequest) returns (TransactionList);
// Make payment
rpc MakePayment(MakePaymentRequest) returns (Payment);
// Get payment status
rpc GetPayment(GetPaymentRequest) returns (Payment);
// Issue new card
rpc IssueCard(IssueCardRequest) returns (Card);
// Get customer information
rpc GetCustomer(GetCustomerRequest) returns (Customer);
// Stream real-time transactions
rpc StreamTransactions(StreamTransactionsRequest) returns (stream Transaction);
}
message CreateAccountRequest {
string customer_id = 1;
AccountType account_type = 2;
string currency = 3;
double initial_deposit = 4;
}
message CreateAccountResponse {
bool success = 1;
string message = 2;
Account account = 3;
}
message GetAccountRequest {
oneof identifier {
string account_id = 1;
string account_number = 2;
}
}
message GetAccountSummaryRequest {
string account_id = 1;
google.protobuf.Timestamp as_of_date = 2;
}
message GetTransactionsRequest {
string account_id = 1;
google.protobuf.Timestamp start_date = 2;
google.protobuf.Timestamp end_date = 3;
int32 page = 4;
int32 page_size = 5;
TransactionType transaction_type = 6;
}
message MakePaymentRequest {
string payer_account_id = 1;
string payee_account_id = 2;
double amount = 3;
string currency = 4;
string reference = 5;
string description = 6;
PaymentMethod payment_method = 7;
}
message GetPaymentRequest {
string payment_id = 1;
}
message IssueCardRequest {
string account_id = 1;
CardType card_type = 2;
string cardholder_name = 3;
bool is_contactless = 4;
}
message GetCustomerRequest {
oneof identifier {
string customer_id = 1;
string email = 2;
string phone_number = 3;
}
}
message StreamTransactionsRequest {
string account_id = 1;
google.protobuf.Timestamp since_timestamp = 2;
repeated TransactionType transaction_types = 3;
}