Call Us NowRequest a Quote
Back to Blog
Kotlin Multiplatform
July 28, 2024
15 min read

Architecting a Full-Funnel B2B ROI Engine: A Unified Kotlin Multiplatform & Next.js 15 Blueprint for 2026

Induji Technical Team

Induji Technical Team

Content Strategy

Architecting a Full-Funnel B2B ROI Engine: A Unified Kotlin Multiplatform & Next.js 15 Blueprint for 2026

Key Takeaways

  • Unified Logic Core: Use Kotlin Multiplatform (KMP) to write and maintain critical business logic, data models, validation, and API clients once, then deploy natively across Web (via JS), Android (via JVM), and iOS (via Native).
  • High-Performance Frontend: Leverage Next.js 15 with React 19 Server Components to build exceptionally fast, SEO-friendly B2B web portals that handle data-intensive tasks on the server, reducing client-side load.
  • The ROI-Centric Paradigm: This architecture is designed from the ground up to close the loop between marketing spend and revenue. Every component contributes to tracking the customer journey from the first ad click to the final entry in your ERP.
  • Unbreakable Server-Side Tracking: By integrating the KMP SDK into Next.js Server Actions, conversion data (with GCLID/FBCID) is sent directly from your server to Google and Meta's Conversion APIs, bypassing ad blockers and browser privacy restrictions for near-perfect attribution.
  • Event-Driven & Decoupled Backend: An event-driven microservices architecture using tools like Kafka or AWS EventBridge ensures the system is scalable, resilient, and can integrate seamlessly with any ERP (like ERPNext) or CRM to track offline conversions and final revenue.

The Architectural Paradigm: The Unified ROI-Centric Stack

For decades, enterprise B2B stacks have been a patchwork of siloed systems. A web frontend built by one team, native mobile apps by another, a backend by a third, and a marketing analytics stack managed by a fourth. This fragmentation creates data-sync nightmares, inconsistent user experiences, and a cavernous "black box" where marketing ROI goes to die. You spend millions on Google Ads, but can you trace a specific ad click to a multi-million dollar deal closed six months later in your ERP? For most, the answer is a resounding no.

The paradigm shift for 2026 is the Unified ROI-Centric Stack. This is not just about code sharing; it's a philosophical change in how we architect systems. The goal is to build a single, coherent application ecosystem where business logic is canonical and every single user interaction is a trackable event in a full-funnel journey.

At the heart of this paradigm are two transformative technologies: Kotlin Multiplatform (KMP) for the unified logic core and Next.js 15 for the high-performance web experience. Together, they allow us to build an engine where the line between application development and performance marketing is completely erased.

High-level architectural diagram showing the unified B2B ROI engine with Ad Platforms, Next.js 15, the KMP Core, Backend Microservices, and the ERP system.

The Foundation: Kotlin Multiplatform (KMP) as the Business Logic & Data SDK

The most common mistake in cross-platform development is focusing solely on sharing the UI. The real challenge—and the greatest source of bugs and cost—is keeping business logic consistent across platforms. This is where KMP excels as the foundational layer of our architecture.

Why KMP is the Enterprise Choice for 2026

KMP allows us to write our most critical, non-UI code once in Kotlin and compile it for multiple targets: JVM for Android and the backend, JavaScript for the web, and native binaries for iOS. This isn't a web view or a bridge; it's native performance everywhere.

  • Canonical Business Logic: Data models, input validation rules, state management, API request/response handling, and complex attribution algorithms are defined in a single, version-controlled KMP module. A change in a validation rule is instantly reflected on iOS, Android, and the web upon the next build.
  • True Native Performance: KMP compiles to the platform's native format. There's no JavaScript bridge overhead on mobile, ensuring the smooth, responsive performance that enterprise users demand from field service apps or complex mobile dashboards.
  • Seamless Interoperability: KMP is designed to work with the platform, not against it. You can easily call platform-specific APIs (e.g., GPS on mobile) from the shared Kotlin code using expect/actual declarations, giving you the best of both worlds.

Designing the KMP "ROI Core" Module

The central nervous system of our application is a dedicated KMP module we'll call the "ROI Core". This isn't just a collection of utilities; it's the SDK for our entire business.

1. Data Models (kotlinx.serialization): We define immutable data classes for every entity in our system. This ensures that the data structure for a Lead or a ConversionEvent is identical whether it's being handled by a Next.js Server Action or a Swift view in our iOS app.

// In shared/src/commonMain/kotlin/com/induji/models/Lead.kt
@Serializable
data class Lead(
    val id: String? = null,
    val firstName: String,
    val email: String,
    val company: String,
    val attributionData: AttributionData
)

@Serializable
data class AttributionData(
    val gclid: String?,
    val fbcid: String?,
    val utmSource: String?,
    val landingPage: String
)

2. API Client (Ktor): We use Ktor, a multiplatform asynchronous networking library, to define our API interactions. This client, configured within the KMP module, handles everything from request construction and authorization to response parsing.

// In shared/src/commonMain/kotlin/com/induji/api/ApiClient.kt
class ApiClient {
    private val client = HttpClient {
        install(ContentNegotiation) {
            json(Json { ignoreUnknownKeys = true })
        }
    }

    suspend fun submitLead(lead: Lead): Result<SuccessResponse> {
        // This single function is called from Next.js, iOS, and Android
        val response = client.post("https://api.yourcompany.com/v1/leads") {
            contentType(ContentType.Application.Json)
            setBody(lead)
        }
        // ... error handling and response parsing
    }
}

3. Attribution & Validation Logic: This is the most critical part. We embed the logic for validating a lead and handling marketing attribution directly into our KMP module. This ensures that a lead submitted from any channel is processed identically.

// In shared/src/commonMain/kotlin/com/induji/logic/LeadProcessor.kt
object LeadProcessor {
    fun validate(lead: Lead): Boolean {
        // Complex, shared validation logic
        return lead.email.contains("@") && lead.company.isNotBlank()
    }

    fun enrichWithAttribution(lead: Lead, sessionData: Map<String, String>): Lead {
        // Logic to extract gclid, fbcid, etc., from session cookies or mobile storage
        return lead.copy(
            attributionData = AttributionData(
                gclid = sessionData["gclid"],
                fbcid = sessionData["_fbc"],
                // ...
            )
        )
    }
}

The Frontend Powerhouse: Next.js 15 & React 19

With our business logic encapsulated in a portable KMP module, we can now choose the best-in-class technology for our web frontend. For modern, high-performance B2B portals, the undisputed choice is Next.js 15, supercharged by React 19.

Leveraging Server Components for Performance

B2B applications are often data-heavy dashboards, not simple landing pages. React Server Components (RSC), now the default in Next.js, are a game-changer. They allow us to:

  • Reduce Client-Side JavaScript: A significant portion of the component rendering logic executes on the server, sending minimal JavaScript to the browser. This results in dramatically faster First Contentful Paint (FCP) and Interaction to Next Paint (INP).
  • Direct Data Access: Server Components can fetch data directly from a database or internal service without needing a separate client-side API call. This eliminates client-server request waterfalls and simplifies data management.

Integrating the KMP Core into Next.js

The magic happens when we compile our KMP "ROI Core" module to JavaScript. This creates a standard JS library that we can import directly into our Next.js application, primarily within Server Actions.

Server Actions are functions that run securely on the server, triggered by UI interactions like form submissions. This is the perfect place to use our KMP SDK.

Consider a lead submission form:

// In a Next.js 15 React Server Component
import { kmpSdk } from '@/lib/kmp-sdk'; // Our compiled KMP library
import { getSessionCookies } from '@/lib/session';

export default function LeadForm() {
  async function submitLeadAction(formData: FormData) {
    'use server';

    const rawData = {
      firstName: formData.get('firstName'),
      email: formData.get('email'),
      company: formData.get('company'),
    };
    
    // 1. Get attribution data from cookies
    const sessionData = await getSessionCookies(); // Reads httpOnly cookies

    // 2. Use the KMP SDK for validation and enrichment
    const enrichedLead = kmpSdk.LeadProcessor.enrichWithAttribution(rawData, sessionData);
    const isValid = kmpSdk.LeadProcessor.validate(enrichedLead);

    if (!isValid) {
      return { error: 'Invalid data' };
    }

    // 3. Use the KMP SDK to submit the data
    const result = await kmpSdk.apiClient.submitLead(enrichedLead);

    // 4. Simultaneously trigger server-side conversion tracking
    if (result.isSuccess) {
      await trackServerSideConversion(enrichedLead.attributionData);
    }
    // ... handle redirect or response
  }

  return (
    <form action={submitLeadAction}>
      {/* Form inputs */}
    </form>
  );
}

In this example, the form validation and API submission logic are not defined in JavaScript. They are consumed from the canonical KMP module, guaranteeing consistency with our mobile apps.

Unbreakable Server-Side Attribution

The most powerful part of this architecture is its ability to perform robust, server-side conversion tracking. Browser-based tracking is dying due to ITP, ATT, and ad blockers. The only reliable method is server-to-server communication.

Our trackServerSideConversion function, called from the Server Action, would do the following:

  1. Extract the Google Click ID (gclid) and Meta Click ID (fbcid) from the attributionData.
  2. Make direct, authenticated API calls from our server to the Google Ads API and Meta's Conversions API.
  3. Send the Lead conversion event along with the click IDs and user data (hashed for privacy where required).

This closes the first loop: ad click to lead submission. Because it happens server-to-server, it's nearly 100% accurate.

Sequence diagram of the server-side tracking flow from a Next.js form submission to the KMP SDK, Server Action, and finally to Google/Meta APIs and the internal ERP.

Closing the Loop: Backend Services, ERP Integration, and Blockchain

A submitted lead is not revenue. The final, and most crucial, step is to tie this lead to a closed deal in your Enterprise Resource Planning (ERP) system.

Event-Driven Microservices for Scalability

Our apiClient.submitLead call doesn't write directly to an ERP. That would create a brittle, monolithic system. Instead, it publishes an event like LEAD_SUBMITTED to a message broker such as AWS EventBridge or Apache Kafka.

This decouples our system. A dedicated "ERP Ingestion" microservice subscribes to this event and is solely responsible for creating the lead record in a system like ERPNext or Salesforce. Other microservices can also subscribe to the same event for different purposes, like sending a notification to a Slack channel or adding the user to a nurturing sequence.

ERPNext as the Source of Truth for Revenue

The sales cycle continues within the ERP. When the sales team finally marks a deal as "Closed-Won" and enters a contract value, ERPNext (configured with webhooks or a Debezium connector) triggers a final event: DEAL_CLOSED_WON.

A "Revenue Reconciliation" microservice listens for this event. It contains the following data:

  • Original Lead ID
  • Final Contract Value
  • Currency
  • Close Date

This service then uses the original Lead ID to find the associated gclid. It makes a final server-to-server API call to the Google Ads API to post an offline conversion with the actual revenue value. This is the holy grail for B2B marketers. It feeds Google's Value-based Bidding (VBB) algorithms with precise ROI data, allowing it to optimize for high-value customers, not just cheap leads.

Advanced: Blockchain for Verifiable Attribution

For enterprises in high-stakes B2B environments or those using partner/affiliate channels, attribution disputes are common. A blockchain ledger can provide an immutable source of truth.

When a LEAD_SUBMITTED event is processed, a hash of the lead data and its full attribution trail can be written to a private enterprise blockchain (e.g., Hyperledger Fabric). This creates a permanent, timestamped, and tamper-proof record of when the lead was generated and from which marketing channel. It serves as an incorruptible audit trail for resolving any attribution disputes and verifying marketing performance.

A simplified diagram showing the blockchain ledger as an immutable record store for high-value conversion events, providing a single source of truth for attribution.

The Complete B2B Full-Funnel Flow

Let's trace the journey from start to finish:

  1. Acquisition: A prospect clicks a Google Ad and lands on a Next.js 15 page. The gclid is stored in an httpOnly cookie.
  2. Engagement: They submit a lead form, triggering a Next.js Server Action.
  3. Unified Processing: The Server Action uses the KMP SDK to validate the data, enrich it with the gclid from the cookie, and call the internal API.
  4. Server-Side Tracking (Loop 1): The Server Action immediately sends a Lead conversion event to the Google & Meta APIs with the gclid.
  5. Backend Decoupling: The API publishes a LEAD_CREATED event to Kafka.
  6. ERP Ingestion: A microservice consumes this event and creates the lead in ERPNext.
  7. Sales Cycle: The sales team works the lead, potentially using a native mobile app built with the same KMP core for on-the-go updates.
  8. Revenue Realization: The deal is won in ERPNext, triggering a DEAL_CLOSED_WON event containing the revenue value.
  9. ROI Calculation (Loop 2): A final microservice sends an offline conversion with the exact revenue value back to the Google Ads API. Google's VBB algorithm now knows the true value of that initial click, and the ROI loop is fully and verifiably closed.

Frequently Asked Questions (FAQ)

Q1: What is the main advantage of KMP over React Native or Flutter in this specific architecture? For this ROI-centric architecture, the primary advantage of KMP is its focus on sharing non-UI business logic natively. React Native and Flutter are UI-first frameworks. While they can share logic, KMP is purpose-built for creating a core SDK that runs with native performance everywhere, including on the server (via JVM) and in a Next.js environment (via JS). This makes it ideal for encapsulating critical, complex logic like attribution and validation, which we want to be 100% consistent across all touchpoints, including our backend and server-side web components.

Q2: How does this architecture handle DPDP Act compliance? This architecture provides several advantages for DPDP Act compliance. First, by centralizing data models in KMP, we can embed consent flags and data processing purposes directly into our core objects. Second, using Next.js Server Actions and server-side tracking means sensitive user data is handled in a secure server environment, not exposed in the browser. This reduces the surface area for data breaches. Finally, the event-driven backend allows for the easy implementation of a "Data Erasure" microservice that can listen for user deletion requests and propagate them through all connected systems in a compliant manner.

Q3: Is compiling the KMP module to JavaScript performant enough for a complex Next.js app? Yes. The Kotlin-to-JavaScript compiler is highly optimized. For the use case described—handling business logic within Server Actions—the performance is excellent, as the code executes on a powerful server environment, not a resource-constrained browser. The client-side impact is minimal because the KMP logic isn't running on every render; it's invoked during specific server-side events like form submissions. This keeps the client bundle lean and the user experience fast.

Q4: Can this architecture integrate with existing legacy systems besides ERPNext? Absolutely. The use of an event-driven, microservices-based backend is key. As long as your legacy system (e.g., SAP, Oracle, a custom CRM) can be made to either consume events from a message broker (like Kafka) or expose a stable API, an "adapter" microservice can be written to bridge the gap. This decouples your modern KMP/Next.js stack from the legacy system, allowing you to modernize incrementally without a "big bang" rewrite.


Ready to Build Your Unified B2B Engine?

Architecting a system this robust and integrated is a complex undertaking, but the competitive advantage it delivers is transformative. It moves marketing from a cost center to a predictable, data-driven revenue engine. You gain a single source of truth, unparalleled performance, and an irrefutable, end-to-end view of your marketing ROI.

The expert architects at Induji Technologies specialize in building these next-generation, unified enterprise stacks. We can help you design and implement a bespoke blueprint that leverages Kotlin Multiplatform, Next.js 15, and an event-driven backend to drive measurable growth.

Contact Induji Technologies today for a consultation and a detailed quote to bring this blueprint to life for your enterprise.

Related Articles

Ready to Transform Your Business?

Partner with Induji Technologies to leverage cutting-edge solutions tailored to your unique challenges. Let's build something extraordinary together.

Architecting a Full-Funnel B2B ROI Engine: A Unified Kotlin Multiplatform & Next.js 15 Blueprint for 2026 | Induji Technologies Blog