{"id":23719639,"url":"https://github.com/mrinalxdev/bidirect-graph","last_synced_at":"2025-04-11T20:08:49.918Z","repository":{"id":269311628,"uuid":"906907411","full_name":"mrinalxdev/BiDirect-graph","owner":"mrinalxdev","description":"Implementation of A linkedIn's optimise way of solving set inter-set problem","archived":false,"fork":false,"pushed_at":"2024-12-23T07:39:42.000Z","size":14,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T20:08:43.928Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrinalxdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-22T09:13:54.000Z","updated_at":"2025-03-10T12:44:43.000Z","dependencies_parsed_at":"2024-12-22T17:17:50.490Z","dependency_job_id":"76630b69-3e88-4920-bd5e-84bd9d9df631","html_url":"https://github.com/mrinalxdev/BiDirect-graph","commit_stats":null,"previous_names":["mrinalxdev/set-interset-paper","mrinalxdev/bidirect-graph"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2FBiDirect-graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2FBiDirect-graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2FBiDirect-graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrinalxdev%2FBiDirect-graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrinalxdev","download_url":"https://codeload.github.com/mrinalxdev/BiDirect-graph/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473128,"owners_count":21109628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-30T21:53:18.074Z","updated_at":"2025-04-11T20:08:49.893Z","avatar_url":"https://github.com/mrinalxdev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BiDirect - Social Graph Service\n\nBiDirect is a minimalist implementation of a distributed social graph service, designed to demonstrate the core concepts of building scalable social networking systems like LinkedIn or Facebook's social graph infrastructure.\n\n## Overview\n\nThis implementation is a micro-instance of how large-scale social networks manage connection data and calculate relationship distances. While production systems handle billions of connections across thousands of nodes, this implementation uses a smaller scale to demonstrate the key architectural concepts.\n\n### Key Features\n- Distributed graph storage using Redis\n- Partitioned data architecture\n- Connection degree calculation (1st, 2nd, 3rd degree connections)\n- Shared connection discovery\n- Network distance computation\n\n## Architecture\n\n### Scaled-Down Components\n\n1. **Partitioning Strategy**\n   - Current: Simple modulo-based partitioning across 3 Redis nodes\n   - Production: Would use consistent hashing or range-based sharding across thousands of nodes\n\n2. **Caching Layer**\n   - Current: Single Redis instance for second-degree connections\n   - Production: Multi-tiered caching with in-memory, near-memory, and disk-based caches\n\n3. **Node Management**\n   - Current: Static node configuration\n   - Production: Dynamic node discovery and automated rebalancing\n\n### API Endpoints\n\n```\nGET  /api/connections/{memberID}           # Get member's direct connections\nGET  /api/shared-connections/{id1}/{id2}   # Find shared connections\nPOST /api/distances                        # Calculate network distances\n```\n\n## Technical Design Decisions\n\n### Data Distribution\n- Uses partition-based distribution to demonstrate how social graphs can be split across multiple nodes\n- Each node manages multiple partitions to show how load can be distributed\n- Simplified partitioning function for demonstration purposes\n\n### Connection Traversal\n- Implements efficient 2nd and 3rd-degree connection discovery\n- Uses Redis sorted sets for quick connection lookups\n- Demonstrates caching of frequently accessed paths\n\n### Set Cover Algorithm\n- Implements a greedy approach for finding minimum node sets\n- Shows how to optimize multi-node queries in a distributed system\n\n## Getting Started\n\n### Prerequisites\n- Go 1.21+\n- Docker and Docker Compose\n\n### Running the Service\n\n1. Start the infrastructure:\n```bash\ndocker-compose up -d\n```\n\n2. The service will be available at `http://localhost:8080`\n\n3. Load sample data:\n```bash\npython imp.py\n```\n\n## Production Considerations\n\nThis implementation is intentionally simplified. In a production environment, you would need to consider:\n\n1. **Scalability**\n   - Current: 3 Redis nodes, 10 partitions per node\n   - Production: Thousands of nodes, dynamic partition allocation\n\n2. **Reliability**\n   - Current: Basic error handling\n   - Production: Circuit breakers, fallbacks, redundancy\n\n3. **Performance**\n   - Current: Simple caching strategy\n   - Production: Multi-level caching, pre-computation of common paths\n\n4. **Monitoring**\n   - Current: Basic logging\n   - Production: Comprehensive metrics, tracing, alerting\n\n5. **Security**\n   - Current: No authentication\n   - Production: OAuth, rate limiting, encryption\n\n## Design Choices\n\n### Why Redis?\n- Demonstrates in-memory graph storage principles\n- Sorted sets provide efficient connection lookups\n- Easy to understand and set up for demonstration\n\n### Why Partition-Based Distribution?\n- Shows basic concepts of data sharding\n- Demonstrates how to handle cross-partition queries\n- Simplified version of production-grade distribution strategies\n\n## Contributing\n\nThis is an educational project designed to demonstrate distributed systems concepts. Contributions that help clarify these concepts or add new educational examples are welcome.\n\n## License\n\nMIT License\n\n## Acknowledgments\n\nThis implementation draws inspiration from real-world social graph systems while maintaining a focus on educational value and clarity over production-grade features.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrinalxdev%2Fbidirect-graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrinalxdev%2Fbidirect-graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrinalxdev%2Fbidirect-graph/lists"}