Introduction
What is the Hypermodern Platform?
The Hypermodern platform is a unified communication framework built in Dart that revolutionizes how we think about client-server architecture. Unlike traditional approaches where you might choose between HTTP REST APIs, WebSocket connections, or TCP sockets, Hypermodern allows you to support all three protocols simultaneously with a single codebase.
At its core, Hypermodern provides:
- Multi-protocol support: HTTP, WebSocket, and TCP transports with identical APIs
- Type-safe communication: Generated client code with full compile-time type checking
- Binary serialization: High-performance data transfer optimized for speed and bandwidth
- Unified routing: Write your business logic once, serve it across all protocols
- Module system: Create reusable, self-contained components with their own schemas and services
Core Philosophy and Design Principles
Protocol Agnostic Development
Traditional web development forces you to choose your communication protocol upfront. Need real-time updates? Use WebSockets. Building a REST API? Stick with HTTP. Need maximum performance? Consider TCP sockets.
Hypermodern eliminates this choice by making your application protocol-agnostic. You write your business logic once, and the platform automatically makes it available across all supported protocols. This means:
- Your mobile app can use HTTP for simple requests
- Your web dashboard can use WebSockets for real-time updates
- Your IoT devices can use TCP for maximum efficiency
- All talking to the same server endpoints
Schema-First Development
Hypermodern embraces a schema-first approach where you define your API contract using JSON schemas. From these schemas, the platform generates:
- Type-safe client libraries
- Server endpoint stubs
- Validation logic
- Documentation
This approach ensures consistency between client and server, catches errors at compile time, and makes API evolution manageable.
Binary-First Performance
While JSON is great for human readability, it's not optimal for network performance. Hypermodern uses binary serialization by default, providing:
- Smaller payload sizes (typically 30-50% smaller than JSON)
- Faster serialization/deserialization
- Better performance on mobile and IoT devices
- Automatic compression
Module-Driven Architecture
Large applications benefit from modular architecture. Hypermodern's module system allows you to:
Multi-Protocol Architecture Overview
The Unified Server
A Hypermodern server runs three protocol handlers simultaneously:
final server = HypermodernServer();
await server.listen(
httpPort: 8080, // REST API
wsPort: 8082, // WebSocket
tcpPort: 8081, // TCP Socket
);
All three servers share the same:
- Endpoint handlers
- Middleware pipeline
- Authentication system
- Business logic
Protocol-Specific Optimizations
While the API remains consistent, each protocol is optimized for its strengths:
HTTP/HTTPS
- Standard REST semantics
- Caching headers
- Status codes
- JSON fallback for debugging
WebSocket
- Bidirectional streaming
- Real-time push notifications
- Connection persistence
- Binary message framing
TCP
- Direct socket communication
- Custom protocol optimization
- Minimal overhead
- Maximum throughput
Client Flexibility
Clients can choose their preferred protocol or even switch protocols dynamically:
// Automatic protocol selection
final client = HypermodernClient('ws://localhost:8082');
// Or explicit protocol choice
final httpClient = HypermodernClient.http('http://localhost:8080');
final tcpClient = HypermodernClient.tcp('localhost:8081');
When to Use Hypermodern
Ideal Use Cases
Multi-Platform Applications When you're building applications that need to serve different types of clients (web, mobile, IoT, desktop), Hypermodern's protocol flexibility ensures each client can use the most appropriate communication method.
Real-Time Applications Applications requiring real-time updates (chat apps, collaborative tools, live dashboards) benefit from WebSocket support while maintaining HTTP compatibility for simpler operations.
Performance-Critical Systems When network performance matters (mobile apps, IoT devices, high-frequency trading), binary serialization and TCP support provide significant advantages.
Rapid Prototyping The schema-first approach and code generation make it easy to iterate on API designs and get prototypes running quickly.
Microservices Architecture The module system makes it easy to break large applications into smaller, manageable services while maintaining type safety across service boundaries.
When to Consider Alternatives
Simple CRUD Applications If you're building a straightforward CRUD application with no real-time requirements, a traditional REST framework might be simpler.
Existing Large Codebases Migrating large existing applications might not be cost-effective unless you can do it incrementally.
Team Expertise If your team is heavily invested in other technologies and the benefits don't justify the learning curve.
What's Next
In the next chapter, we'll get hands-on with Hypermodern by setting up your development environment and creating your first project. You'll see how quickly you can go from concept to working multi-protocol application.
The journey ahead will take you from basic concepts to advanced patterns, giving you the knowledge to build scalable, performant applications with the Hypermodern platform.