# What Are the Modular Components of FastProxy Architecture?

> Explore the five modular components of FastProxy an independent Center, InProxy, OutProxy, Server, and Client SDK for flexible deployments.

- Repository: [Kingson4Wu/fast_proxy](https://github.com/kingson4wu/fast_proxy)
- Tags: architecture
- Published: 2026-03-05

---

**FastProxy is built around five independent modules—Center, InProxy, OutProxy, Server, and Client SDK—that communicate via protobuf and can be combined for sidecar, gateway, or embedded deployments.**

FastProxy (kingson4wu/fast_proxy) implements a modular service-mesh architecture written in Go. The system decomposes proxy functionality into discrete components that operate as a control plane, data plane, or application layer depending on your operational requirements. Each module can be deployed independently or bundled into a single binary, enabling zero-downtime policy changes and flexible topology options.

## The Five Core Modules of FastProxy

The FastProxy architecture separates concerns into five distinct components. This separation allows operators to run only the necessary parts for their specific deployment pattern, whether as a centralized gateway or distributed sidecar.

### Center (Control Plane)

The **Center** module serves as the control plane for the entire FastProxy architecture. It holds service metadata, configuration, and dynamic rule sets that govern traffic behavior. Located in the `center/` directory (with the entry point typically called via `center.New`), this component distributes policies and configuration updates to the data-plane proxies. It acts as the source of truth for discovery and policy distribution across the mesh.

### InProxy (Ingress Data Plane)

The **InProxy** module handles all inbound traffic termination. Implemented in [`inproxy/inproxy.go`](https://github.com/kingson4wu/fast_proxy/blob/main/inproxy/inproxy.go), it accepts incoming requests, decrypts payloads, verifies digital signatures, and enforces inbound security policies before forwarding valid traffic downstream. When initialized with `inproxy.New()`, it pulls dynamic policies from the Center and applies them at the edge of your service.

### OutProxy (Egress Data Plane)

The **OutProxy** module manages outbound traffic from your services. Found in [`outproxy/outproxy.go`](https://github.com/kingson4wu/fast_proxy/blob/main/outproxy/outproxy.go), this component applies encryption, compression, and outbound policies before forwarding requests to upstream services. It ensures that traffic leaving your service mesh meets security and compliance requirements. Like InProxy, it initializes with `outproxy.New()` and receives configuration updates from the Center.

### Server (Application Host)

The **Server** module hosts the actual business-logic service or forwards to an upstream service. Located in [`common/server/server.go`](https://github.com/kingson4wu/fast_proxy/blob/main/common/server/server.go), this component provides a robust HTTP server implementation (supporting both standard `net/http` and FastHTTP) that runs your application code. It can operate as a standalone HTTP server or as part of a larger proxy chain. The constructor `server.NewServer()` accepts configuration, logging, and handler functions to bootstrap your service.

### Client SDK (Embedded Library)

The **Client SDK** provides Go APIs that let applications embed FastProxy directly without running separate processes. Exposed through [`examples/client/client.go`](https://github.com/kingson4wu/fast_proxy/blob/main/examples/client/client.go) (and importable as `github.com/Kingson4Wu/fast_proxy/client`), this module allows developers to invoke the proxy programmatically using `client.New()`. This is ideal for sidecar patterns where you want proxy capabilities compiled directly into your application binary.

## How the Modules Communicate

These modules exchange data using **protobuf-encoded payloads**, ensuring efficient binary serialization across the network. The Center pushes configuration updates to InProxy and OutProxy instances, while the Server and Client SDK consume these policies to enforce local behavior. This design enables the control plane to update security rules and routing policies across the entire fleet without requiring process restarts.

## Deploying a Complete FastProxy Pipeline

You can run all modules together in a single Go binary for testing or lightweight deployments. Each component accepts the same configuration object loaded via `config.LoadYaml()`, ensuring consistency across the stack.

```go
package main

import (
	"log"

	"github.com/Kingson4Wu/fast_proxy/center"
	"github.com/Kingson4Wu/fast_proxy/common/config"
	"github.com/Kingson4Wu/fast_proxy/common/logger"
	"github.com/Kingson4Wu/fast_proxy/common/server"
	"github.com/Kingson4Wu/fast_proxy/inproxy"
	"github.com/Kingson4Wu/fast_proxy/outproxy"
)

func main() {
	// Load a YAML config that all modules share
	cfg, err := config.LoadYaml("./test/config/outconfig.yaml")
	if err != nil {
		log.Fatalf("load config: %v", err)
	}
	// Initialize shared logger
	l := logger.NewZapLogger()

	// 1️⃣ Start the control plane (Center)
	ctr := center.New(cfg, l)
	go ctr.Start()

	// 2️⃣ Launch the downstream business server
	srv := server.NewServer(cfg, l, func(w http.ResponseWriter, r *http.Request) {
		w.Write([]byte("hello from real service"))
	})
	go srv.Start()

	// 3️⃣ Start InProxy for ingress handling
	in := inproxy.New(cfg, l, func(w http.ResponseWriter, r *http.Request) {
		// Security checks and forwarding logic handled internally
		w.Write([]byte("processed by inproxy"))
	})
	go in.Start()

	// 4️⃣ Start OutProxy for egress handling
	out := outproxy.New(cfg, l, func(w http.ResponseWriter, r *http.Request) {
		// Encryption and compression applied here
		w.Write([]byte("final payload"))
	})
	go out.Start()

	select {} // Block forever
}

```

This example demonstrates how `center.New()`, `server.NewServer()`, `inproxy.New()`, and `outproxy.New()` can be orchestrated within the same process while maintaining their logical separation.

## Embedding FastProxy with the Client SDK

For scenarios requiring direct integration without standalone proxy processes, the Client SDK abstracts the proxy protocol:

```go
package main

import (
	"context"
	"log"

	"github.com/Kingson4Wu/fast_proxy/client"
	"github.com/Kingson4Wu/fast_proxy/common/config"
)

func main() {
	// Load configuration containing endpoints and encryption keys
	cfg, _ := config.LoadYaml("./test/config/outconfig.yaml")

	// Initialize client that talks to existing FastProxy deployment
	c, err := client.New(cfg)
	if err != nil {
		log.Fatalf("client init: %v", err)
	}

	// Execute request through the proxy mesh
	resp, err := c.Do(context.Background(), "GET", "/api/v1/resource", nil)
	if err != nil {
		log.Fatalf("request error: %v", err)
	}
	log.Printf("proxy response: %s", string(resp.Body))
}

```

The `client.New()` constructor returns an instance that handles all encryption, compression, and policy enforcement transparently.

## Key Source Files and Implementation Details

Understanding the implementation location of each module helps when customizing or debugging the FastProxy architecture:

- **[`inproxy/inproxy.go`](https://github.com/kingson4wu/fast_proxy/blob/main/inproxy/inproxy.go)** – Entry point for the InProxy module; contains ingress filtering, decryption, and signature verification logic.
- **[`outproxy/outproxy.go`](https://github.com/kingson4wu/fast_proxy/blob/main/outproxy/outproxy.go)** – Entry point for the OutProxy module; implements egress encryption, compression, and outbound policy application.
- **[`common/server/server.go`](https://github.com/kingson4wu/fast_proxy/blob/main/common/server/server.go)** – Core server implementation used by the Server component; supports both HTTP and FastHTTP protocols.
- **[`examples/client/client.go`](https://github.com/kingson4wu/fast_proxy/blob/main/examples/client/client.go)** – Reference implementation of the Client SDK showing how to embed proxy capabilities in Go applications.
- **`center/`** – Directory containing the Center service implementation that manages configuration distribution and service discovery.

These files illustrate the clean separation of concerns that makes FastProxy both highly extensible and easy to embed in various deployment patterns.

## Summary

- **FastProxy** decomposes proxy functionality into five distinct modules: Center, InProxy, OutProxy, Server, and Client SDK.
- **Center** acts as the control plane, distributing configuration and policies to data-plane components.
- **InProxy** and **OutProxy** form the data plane, handling ingress decryption and egress encryption respectively.
- **Server** provides the application host layer, while the **Client SDK** enables embedded deployment.
- All modules communicate via **protobuf** and can be initialized using constructors like `center.New()`, `inproxy.New()`, and `client.New()`.
- The architecture supports sidecar, gateway, and embedded deployment topologies without code changes.

## Frequently Asked Questions

### What is the difference between InProxy and OutProxy in FastProxy?

**InProxy** terminates inbound traffic and enforces security policies at the entry point, handling decryption and signature verification. **OutProxy** manages outbound connections from your services, applying encryption and compression before traffic leaves the mesh. According to the source code in [`inproxy/inproxy.go`](https://github.com/kingson4wu/fast_proxy/blob/main/inproxy/inproxy.go) and [`outproxy/outproxy.go`](https://github.com/kingson4wu/fast_proxy/blob/main/outproxy/outproxy.go), both fetch dynamic rules from the Center but operate on opposite traffic directions.

### How does the Center module manage configuration in FastProxy?

The **Center** stores service metadata and rule sets, acting as the control plane for the entire FastProxy architecture. It pushes protobuf-encoded configuration updates to InProxy and OutProxy instances, enabling zero-downtime policy changes across the fleet without restarting data-plane components.

### Can I run FastProxy modules separately or do they need to be together?

You can deploy FastProxy modules independently or combined. The architecture supports running Center, InProxy, OutProxy, and Server as separate processes distributed across different hosts, or bundled into a single binary for simplified deployment. Each module only requires access to the shared configuration loaded via `config.LoadYaml()`.

### Is FastProxy suitable for sidecar deployment patterns?

Yes, FastProxy is specifically designed for sidecar deployment. The **Client SDK** allows embedding proxy functionality directly into application code, while the modular design lets you run InProxy and OutProxy as separate sidecar containers alongside your main service containers. This flexibility enables service-mesh architectures without requiring centralized gateways.