# Flowfish - Technology Choices and Rationale ## 🎯 Overview Technologies selected for the Flowfish platform follow principles of high performance, scalability, reliability, and developer productivity. --- ## πŸ“Š Technology Stack Summary | Layer | Technology | Version | |--------|-----------|----------| | **Data Collection (L4)** | Inspektor Gadget + eBPF | Latest | | **Data Collection (L7)** | Grafana Beyla + eBPF | v3.8+ | | **Backend** | Python + FastAPI | 3.11+ / 0.100+ | | **Frontend** | React + TypeScript | 18+ / 5+ | | **UI Framework** | Ant Design | 5+ | | **Graph Viz** | Cytoscape.js | 3.26+ | | **Relational DB** | PostgreSQL | 15+ | | **Graph DB** | Neo4j | 3.6+ | | **Time-series DB** | ClickHouse | 23+ | | **Cache** | Redis | 7+ | | **Container** | Docker | 20.10+ | | **Orchestration** | Kubernetes/OpenShift | 1.27+ / 4.13+ | --- ## πŸ”¬ Data Collection: Inspektor Gadget + eBPF ### Selection Rationale **Why Inspektor Gadget?** - βœ… **Kubernetes Native**: Purpose-built for K8s/OpenShift - βœ… **eBPF Powered**: Kernel-level data collection, near-zero overhead - βœ… **Zero Application Change**: No application changes required - βœ… **DaemonSet Architecture**: Easy deployment, automatic scaling - βœ… **Rich Gadget Library**: Network, DNS, TCP, process, syscall, file tracking - βœ… **Open Source**: MIT license, active community **Alternatives and Why They Were Not Chosen:** | Alternative | Pros | Cons | Why Not Chosen | |------------|------|------|----------------| | **Service Mesh (Istio/Linkerd)** | L7 metrics, mTLS | Sidecar injection required, high overhead | Requires application changes | | **APM Tools (Datadog, New Relic)** | Rich UI, easy setup | Paid, vendor lock-in | Costly, external dependency | | **Custom eBPF Programs** | Full control | Development complexity | High development cost | | **Network Sniffer (tcpdump)** | Simple | High performance impact | Scalability issues | ### Technical Details **eBPF (Extended Berkeley Packet Filter)**: - Linux kernel 4.4+ support - In-kernel execution (no user-space round trips) - Verifiable bytecode (safe execution) - CO-RE (Compile Once Run Everywhere) - Minimal CPU/memory overhead (<1–2%) **Inspektor Gadgets**: - `trace_network`: TCP/UDP connection tracking - `trace_dns`: DNS query/response logging - `trace_tcp`: TCP lifecycle events - `trace_exec`: Process execution tracking - `trace_open`: File access monitoring - `trace_bind`: Port binding detection --- ## πŸ”¬ L7 Data Collection: Grafana Beyla + eBPF ### Selection Rationale **Why Grafana Beyla?** - βœ… **eBPF-Based**: Same kernel-level approach as Inspektor Gadget - βœ… **L7 Protocol Support**: HTTP, gRPC, DNS request/response capture - βœ… **Zero Application Change**: No sidecars, no code instrumentation - βœ… **DaemonSet Architecture**: Consistent with existing Inspektor Gadget deployment - βœ… **Multi-Arch**: AMD64 + ARM64 support (~50MB image) - βœ… **OpenTelemetry Native**: Exports OTLP traces and metrics - βœ… **Apache 2.0 License**: Fully open source **Alternatives and Why They Were Not Chosen:** | Alternative | Pros | Cons | Why Not Chosen | |------------|------|------|----------------| | **Kubeshark** | Rich L7 capture, UI | License changed to paid, limited multi-cluster | Commercial licensing | | **Cilium Hubble** | eBPF, L7 visibility | Requires Cilium CNI | Not CNI-agnostic | | **Pixie** | Rich L7 visibility | Cloud-centric, limited self-hosted | External dependency | | **Service Mesh** | mTLS, L7 metrics | Sidecar injection, high overhead | Requires application changes | **Beyla Architecture**: - Deployed as DaemonSet on each cluster node - Instruments Go, Python, Java, Node.js, .NET, Rust applications automatically - Captures HTTP method/path/status, gRPC service/method, DNS queries - Exports OpenTelemetry spans to in-cluster flowfish-l7-collector - flowfish-l7-collector bridges push model to Flowfish pull model via K8s API Service Proxy --- ## πŸš€ Backend: Python + FastAPI ### Selection Rationale **Python**: - βœ… **Ecosystem**: Rich library support (data processing, ML/AI) - βœ… **LLM Integration**: Libraries like OpenAI, LangChain are native to Python - βœ… **Async Support**: Modern async programming with asyncio - βœ… **Developer Productivity**: Fast development, readable syntax **FastAPI**: - βœ… **High Performance**: Starlette + Pydantic, Go/Node.js–level speed - βœ… **Automatic OpenAPI**: Swagger UI generated automatically - βœ… **Type Safety**: Compile-time type checking with Pydantic - βœ… **Async Native**: Native async/await support - βœ… **Dependency Injection**: Clean, testable code - βœ… **WebSocket Support**: Real-time communication **Alternatives**: | Alternative | Why Not Chosen | |------------|----------------| | **Django** | Monolithic, overhead for non-REST needs | | **Flask** | Sync-only, lacks modern features | | **Go (Gin/Echo)** | Weaker Python ecosystem and LLM integration | | **Node.js (Express)** | Callback hell, weak type safety | --- ## βš›οΈ Frontend: React + TypeScript + Ant Design ### Selection Rationale **React 18**: - βœ… **Industry Standard**: Large community, abundant resources - βœ… **Component-Based**: Reusable, maintainable components - βœ… **Hooks**: Modern state management - βœ… **Virtual DOM**: Efficient rendering - βœ… **Server Components**: Future-proof (RSC) **TypeScript**: - βœ… **Type Safety**: Catch errors at compile time - βœ… **Better IntelliSense**: Excellent IDE support - βœ… **Refactoring**: Safe rename, move operations - βœ… **Documentation**: Types = self-documenting code **Ant Design (antd)**: - βœ… **Enterprise-Grade**: Used by Fortune 500 companies - βœ… **Comprehensive**: 60+ high-quality components - βœ… **Consistent**: Unified design language - βœ… **Customizable**: Theme support, CSS-in-JS - βœ… **Accessible**: WCAG 2.0 AA compliant - βœ… **I18n**: Multi-language support built-in **Alternatives**: | Alternative | Why Not Chosen | |------------|----------------| | **Vue.js** | Smaller ecosystem, less enterprise adoption | | **Angular** | Steep learning curve, verbose | | **Material-UI** | Ant Design is more enterprise-focused | | **Chakra UI** | Younger, less battle-tested | --- ## 🎨 Graph Visualization: Cytoscape.js ### Selection Rationale **Cytoscape.js**: - βœ… **Purpose-Built**: Designed specifically for graph visualization - βœ… **Performance**: Handles 1000+ nodes/edges - βœ… **Extensible**: Plugin ecosystem - βœ… **Layout Algorithms**: Hierarchical, force-directed, circular, grid - βœ… **Styling**: CSS-like styling system - βœ… **Events**: Rich interaction events - βœ… **Export**: PNG, JPG, JSON export **Alternatives**: | Alternative | Pros | Cons | |------------|------|------| | **D3.js** | Very flexible, powerful | Steep learning curve, verbose | | **Vis.js** | Easy to use | Performance issues (>500 nodes) | | **Sigma.js** | Fast rendering | Limited feature set | | **React Flow** | React-native | Missing graph algorithms | --- ## πŸ—„οΈ Databases ### PostgreSQL 15+ (Relational Data) **Selection Rationale**: - βœ… **ACID Compliance**: Reliable transactions - βœ… **JSONB Support**: JSON storage for flexible schema - βœ… **Full-Text Search**: Built-in search capabilities - βœ… **Extensions**: PostGIS, pg_trgm, btree_gin - βœ… **Replication**: Streaming replication, logical replication - βœ… **Partitioning**: Table partitioning for large datasets - βœ… **Mature**: 30+ years, production-proven **Use Cases**: - User accounts, roles, permissions - Cluster and namespace metadata - Analysis configurations - Anomaly and change records - Audit logs **Why Alternatives Were Not Chosen**: - **MySQL**: Weak JSONB support, complex replication - **MongoDB**: Weak ACID guarantees, not ideal for relational data ### Neo4j 3.6+ (Graph Database) **Selection Rationale**: - βœ… **Distributed**: Native distributed architecture - βœ… **Scale**: Support for trillions of vertices/edges - βœ… **Performance**: Sub-millisecond graph traversal - βœ… **GQL (nGQL)**: SQL-like graph query language - βœ… **Open Source**: Apache 2.0 license - βœ… **Kubernetes-Friendly**: Helm charts, operators - βœ… **Consistency**: Strong consistency via Raft **Use Cases**: - Workload dependencies (Pod β†’ Deployment β†’ Service) - Communication edges (COMMUNICATES_WITH) - Dependency chains (DEPENDS_ON) - Graph traversal queries (upstream/downstream) **Alternatives**: | Alternative | Why Not Chosen | |------------|----------------| | **Neo4j** | Paid (enterprise), Cypher proprietary | | **JanusGraph** | Lower performance than Neo4j | | **Amazon Neptune** | Vendor lock-in, cloud-only | | **ArangoDB** | Multi-model complexity | ### ClickHouse 23+ (Time-Series/OLAP) **Selection Rationale**: - βœ… **Columnar Storage**: High compression (10–100x) - βœ… **Fast Queries**: Billions of rows, sub-second queries - βœ… **Aggregations**: Pre-aggregation via materialized views - βœ… **TTL Support**: Automatic data cleanup - βœ… **Partitioning**: Date/time based partitioning - βœ… **Replication**: Built-in replication - βœ… **SQL**: Standard SQL dialect **Use Cases**: - Network flow events (raw eBPF data) - DNS queries, TCP connections - HTTP requests, metrics - Process events, syscall traces - Aggregated request metrics **Alternatives**: | Alternative | Why Not Chosen | |------------|----------------| | **TimescaleDB** | PostgreSQL extension, slower | | **InfluxDB** | Non-SQL, limited query capabilities | | **Elasticsearch** | Resource-heavy, complex operations | | **Prometheus** | Short retention, not for raw events | ### Redis 7+ (Cache & Real-time) **Selection Rationale**: - βœ… **In-Memory**: Microsecond latency - βœ… **Pub/Sub**: Real-time event streaming - βœ… **Data Structures**: Lists, sets, sorted sets, hashes - βœ… **TTL**: Automatic expiration - βœ… **Persistence**: RDB + AOF - βœ… **Clustering**: Native clustering support - βœ… **Sentinel**: Automatic failover **Use Cases**: - Session storage (JWT tokens) - Real-time metrics cache - Rate limiting counters - Pub/Sub for WebSocket updates - Distributed locks --- ## 🐳 Container & Orchestration ### Docker **Selection Rationale**: - βœ… **Industry Standard**: De facto containerization platform - βœ… **Image Registry**: Docker Hub, private registries - βœ… **Multi-Stage Builds**: Optimized images - βœ… **BuildKit**: Fast, efficient builds ### Kubernetes / OpenShift **Selection Rationale**: - βœ… **Cloud-Native Standard**: Industry standard orchestration - βœ… **Auto-Scaling**: HPA, VPA - βœ… **Self-Healing**: Automatic restarts, health checks - βœ… **Service Discovery**: Built-in DNS - βœ… **Storage**: PersistentVolumes, StorageClasses - βœ… **Security**: RBAC, NetworkPolicies, PodSecurityPolicies - βœ… **OpenShift**: Enterprise features, operators, built-in monitoring --- ## πŸ” Authentication ### JWT (JSON Web Tokens) **Selection Rationale**: - βœ… **Stateless**: No server-side session required - βœ… **Scalable**: Horizontal scaling friendly - βœ… **Cross-Domain**: CORS-friendly - βœ… **Standard**: RFC 7519 - βœ… **Libraries**: Mature libraries for every language ### OAuth 2.0 / OpenID Connect **Selection Rationale**: - βœ… **SSO**: Single Sign-On support - βœ… **Enterprise**: Azure AD, Okta, Keycloak integration - βœ… **Delegation**: Secure delegation of access - βœ… **Standard**: Industry standard protocol --- ## πŸ“Š Monitoring & Observability ### Recommended Stack (Optional) | Component | Technology | Purpose | |-----------|------------|---------| | **Metrics** | Prometheus | Time-series metrics | | **Logs** | Loki / ELK | Centralized logging | | **Tracing** | Jaeger / Tempo | Distributed tracing | | **Dashboards** | Grafana | Visualization | | **Alerting** | Alertmanager | Alert management | --- ## 🎯 Conclusion The Flowfish technology stack follows modern cloud-native application development best practices: **βœ… Performance**: eBPF, FastAPI, ClickHouse, Redis **βœ… Scalability**: Kubernetes, distributed databases **βœ… Reliability**: PostgreSQL ACID, replication **βœ… Developer Experience**: Python, TypeScript, React **βœ… Maintainability**: Type safety, test frameworks **βœ… Open Source**: No vendor lock-in, community support **Version**: 1.0.0 **Last Updated**: January 2025