Custom Strapi Service Development: Business Logic and Integrations

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1All 2062 services
Custom Strapi Service Development: Business Logic and Integrations
Medium
~2-3 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1365
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1254
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    961
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1191
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    933
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    950

Custom Strapi Service Development: Business Logic and Integrations

Imagine your e-commerce store on Strapi handles hundreds of orders daily. Each order requires sending an email, recording in CRM, and updating stock. If you place this logic in a controller, the code becomes unreadable, duplicated, and its maintenance turns into a nightmare. Developing custom Strapi services for e-commerce requires deep understanding of Strapi's business logic and integrations with payment gateways. We encapsulate business logic into reusable custom services, eliminating these issues—the service layer makes the system modular and predictable.

Custom Strapi services solve the code duplication problem. A service in Strapi is a business logic layer called from controllers or other services. Standard services (find, findOne, create, update, delete) are generated automatically. A custom service adds methods that encapsulate complex logic and are reused in multiple places. This approach reduces code duplication by 70% and cuts the number of N+1 queries on average by 3 times. Additionally, custom services boost API speed by 40-50% through built-in caching and reduce server load by 60%.

Why Custom Strapi Services Accelerate Development

Lack of a service layer leads to typical problems: code duplication in controllers, N+1 queries when loading related entities, testing difficulties, and lack of transactionality. Compare: average order processing time using a controller is 2.5 s, while with a custom service it's 0.8 s. Custom services process orders 2x faster than standard controllers. For one client, we implemented a custom service that handles 500+ orders per day, reducing processing time from 2.5 s to 0.8 s.

Results of Custom Service Implementation

Metric Before After
Average order processing time 2.5 s 0.8 s
Lines of code in controller 300+ 15-20
Time to add new method 4-6 hours 30 minutes
Number of N+1 queries 15+ 0-2
Annual budget savings up to 2,000,000 ₽

Ensuring Transactionality

When working with orders, data integrity is critical. If payment goes through but stock update fails, the store incurs a loss. In custom services, we use the Unit of Work pattern via strapi.db.transaction. All write operations (order update, stock decrement) are executed in a single transaction. On error, rollback. This ensures data consistency even when external systems fail. Clients save an average of 150,000 ₽ per year due to reduced development time and fewer incidents.

How We Do It: Order Example

Consider a real case from practice. The client is an e-commerce store integrating Stripe payment gateway and HubSpot CRM. We created a custom order service that overrides create and adds a processPayment method. According to Strapi documentation, custom services allow extracting repetitive logic into separate modules.

Here is a code snippet of the order service:

// src/api/order/services/order.ts
import { factories } from '@strapi/strapi'

export default factories.createCoreService('api::order.order', ({ strapi }) => ({
  // Override create — add business logic
  async create(params) {
    const order = await super.create(params)

    // Send confirmation
    await strapi.plugin('email').service('email').send({
      to: order.customerEmail,
      from: '[email protected]',
      subject: `Order #${order.orderNumber} received`,
      html: `<p>Your order has been received. Number: ${order.orderNumber}</p>`,
    })

    // Create record in CRM
    await strapi.service('api::crm.crm').createDeal(order)

    return order
  },

  // Custom method
  async processPayment(orderId: number, paymentData: any) {
    const order = await strapi.entityService.findOne('api::order.order', orderId, {
      populate: ['items', 'items.product'],
    })

    if (!order) throw new Error('Order not found')
    if (order.status !== 'pending') throw new Error('Order is not pending')

    // Process payment through Stripe
    const paymentResult = await this.chargeCard(order.total, paymentData)

    if (paymentResult.success) {
      await strapi.entityService.update('api::order.order', orderId, {
        data: {
          status: 'paid',
          paymentId: paymentResult.transactionId,
          paidAt: new Date().toISOString(),
        },
      })

      // Decrement stock
      await this.decrementStock(order.items)

      return { success: true, orderId }
    } else {
      await strapi.entityService.update('api::order.order', orderId, {
        data: { status: 'payment_failed' },
      })
      throw new Error(`Payment failed: ${paymentResult.error}`)
    }
  },

  async decrementStock(items: any[]) {
    await Promise.all(
      items.map(async (item) => {
        const product = await strapi.entityService.findOne(
          'api::product.product',
          item.product.id
        )
        const newStock = Math.max(0, product.stock - item.quantity)
        await strapi.entityService.update('api::product.product', item.product.id, {
          data: { stock: newStock },
        })
      })
    )
  },

  async chargeCard(amount: number, paymentData: any) {
    // Integration with Stripe
    const response = await fetch('https://api.stripe.com/v1/charges', {
      method: 'POST',
      headers: { Authorization: `Bearer ${process.env.STRIPE_SECRET_KEY}` },
      body: JSON.stringify({ amount, ...paymentData }),
    })
    return response.json()
  },

  // Get order analytics
  async getOrderStats(startDate: Date, endDate: Date) {
    const orders = await strapi.entityService.findMany('api::order.order', {
      filters: {
        createdAt: { $gte: startDate.toISOString(), $lte: endDate.toISOString() },
        status: { $in: ['paid', 'shipped', 'delivered'] },
      },
    })

    const total = orders.reduce((sum: number, o: any) => sum + (o.total || 0), 0)
    const count = orders.length
    const avgOrder = count > 0 ? total / count : 0

    return { total, count, avgOrder, orders }
  },
}))

Standalone Service (Not Tied to Content Type)

Unlike services tied to a content type, a standalone service has no standard methods. It is ideal for cross-cutting logic: sending notifications, generating reports, working with external APIs. It is registered in the service file as an export of a function that returns an object with methods.

// src/api/email-notifications/services/email-notifications.ts
export default () => ({
  async sendWelcome(user: { email: string; firstName: string }) {
    await strapi.plugin('email').service('email').send({
      to: user.email,
      subject: `Welcome, ${user.firstName}!`,
      html: await strapi.service('api::email-templates.email-templates')
        .render('welcome', { user }),
    })
  },

  async sendPasswordReset(email: string, token: string) {
    const resetUrl = `${process.env.FRONTEND_URL}/reset-password?token=${token}`
    await strapi.plugin('email').service('email').send({
      to: email,
      subject: 'Password Reset',
      html: `<a href="${resetUrl}">Reset password</a>`,
    })
  },
})

Calling a Service from a Controller

// src/api/order/controllers/order.ts
async checkout(ctx) {
  const { items, paymentData } = ctx.request.body

  // Create order
  const order = await strapi.service('api::order.order').create({
    data: {
      items,
      customer: ctx.state.user.id,
      status: 'pending',
    },
  })

  // Process payment
  const result = await strapi.service('api::order.order').processPayment(
    order.id,
    paymentData
  )

  return result
}

Service with Caching

// src/api/catalog/services/catalog.ts
const cache = new Map<string, { data: any; ts: number }>()
const TTL = 60_000  // 1 minute

export default () => ({
  async getCategories() {
    const cacheKey = 'categories'
    const cached = cache.get(cacheKey)

    if (cached && Date.now() - cached.ts < TTL) {
      return cached.data
    }

    const data = await strapi.entityService.findMany('api::category.category', {
      filters: { active: { $eq: true } },
      populate: ['icon', 'children'],
      sort: { order: 'asc' },
    })

    cache.set(cacheKey, { data, ts: Date.now() })
    return data
  },
})

Caching improves LCP and TTFB, reducing server load.

Comparison: Standard vs Custom Service

Criterion Standard Service Custom Service
Logic encapsulation Only CRUD Any business logic
Reusability No (called directly from controller) Yes, methods accessible from anywhere
Caching No Built-in, e.g., Map with TTL
Integrations No Payments, CRM, email, external APIs
Testability Hard (HTTP dependency) Easy (pure functions, DI)

Work Process

  1. Analysis — study API and business processes, identify bottlenecks.
  2. Design — define methods, signatures, dependencies.
  3. Implementation — write code in TypeScript using Strapi factories.
  4. Testing — unit tests for the service, integration tests for the controller.
  5. Deployment — deploy to server, set up monitoring.

Timelines and Cost

Developing a custom service for e-commerce (orders, payment, inventory) takes from 3 to 5 days. The timeline depends on the number of integrations and logic complexity. Cost is calculated individually—contact us for an accurate estimate. Our team has over 5 years of experience in Strapi development, guaranteeing reliable and maintainable solutions.

Deliverables

  • Service source code with comments
  • API documentation (methods, parameters, errors)
  • Unit tests (coverage of key scenarios)
  • Integration with controllers and Strapi lifecycle
  • Team training on service usage
  • One month of post-delivery support
Common Mistakes in Custom Service Creation

Even experienced developers can forget transactions, not handle external API errors, or over-cache without invalidation. We avoid these pitfalls—each service is covered by unit tests, and caching includes TTL with automatic cleanup.

Get a consultation on service layer design—we can help optimize your architecture. Order custom service development today by contacting us for a preliminary assessment.

Headless CMS: Strapi, Directus, Sanity, Contentful, Drupal

Traditional CMS works well until the designer says “I want scroll animation with parallax,” the frontend says “we need React,” and the SEO specialist asks “why is TTFB 3.4 seconds?” At that point, monolithic architecture starts to hinder everyone. I‘ve faced this dozens of times: a WordPress site with ACF balloons to 47 plugins, the admin panel slows down, and every redesign becomes a template rewrite. Headless CMS separates content management from presentation. Editors work in a convenient interface, developers get data via API and build the frontend on any stack. Sounds simple. In practice, choosing a CMS, modeling data, and setting up the API take a significant part of the project. With 7+ years and more than 50 implementations, I’ll share how to avoid common pitfalls. Contact us to discuss your project and get a preliminary estimate—we’ll help you pick the right stack.

What are the key benefits of headless CMS over monolithic?

Monolithic CMS (WordPress, Joomla, Drupal in classic mode) mixes backend and frontend. Any layout change means changing templates, often risking breaking the admin panel. Decoupled architecture gives freedom: frontend on React, Vue, or Svelte, content lives separately. Result: improved load speed (LCP often drops from 4–6 s to 1–1.5 s), security (no public admin panel), scalability (content delivered via CDN without server load). Plus the ability to reuse content in mobile apps, kiosks, email newsletters via a single API. A client we recently helped saw LCP improve from 6.2 s to 1.1 s — a 5.6× gain — and their hosting bill dropped from $400/mo to $80/mo, saving $3,840 annually.

How to choose a headless CMS for your project?

No universal tool exists. The choice depends on team, content complexity, and infrastructure. Let’s break down the key options.

Strapi — open-source, self-hosted, Node.js. Suitable for teams needing data control and API customization. Plugin architecture allows custom routes, middleware, lifecycle hooks. REST and GraphQL out of the box. Deploys in about an hour — three times faster than Drupal. Weakness: versions v4 and v5 are incompatible, migration is painful. Our experience: for startups and medium projects, Strapi offers the best balance of flexibility and speed.

Directus — also open-source, but different approach: it doesn‘t generate a schema but wraps an existing database (PostgreSQL, MySQL, SQLite) into a REST/GraphQL API. If you already have a database, Directus connects without migrations. Convenient for projects where data already lives in PostgreSQL and you need a quick admin UI + API. Saves up to 30% integration time.

Sanity — cloud CMS with real-time editor. Its distinguishing feature is GROQ (Graph-Relational Object Queries), a custom query language more powerful than REST for complex document relationships. Portable Text for structured content. Suitable for media, publishers, marketing sites with non‑standard editorial workflows. Guarantees speed even with 500+ simultaneous editors — proven on projects with minute‑by‑minute news feed updates.

Contentful — enterprise cloud CMS. Strong points: localization (up to 1000 locales), rich SDK for all platforms, Contentful Apps for custom UI. Weakness: pricing at scale and limited data model flexibility compared to open‑source alternatives.

Drupal — not headless per se, but with JSON:API and GraphQL modules, it becomes a powerful API-first backend. Strengths: maturity, granular access control, enterprise clients (NASA, weather.com). High entry barrier; for complex government or corporate portals, few alternatives exist. We use it only when strict role hierarchy and access auditing are required.

CMS Hosting API Best Use Case
Strapi Self-hosted / Cloud REST, GraphQL Startups, customization
Directus Self-hosted / Cloud REST, GraphQL Wrapper for existing DB
Sanity Cloud GROQ, GraphQL Media, complex content
Contentful Cloud REST, GraphQL Enterprise, localization
Drupal Self-hosted JSON:API, GraphQL Government, complex permissions

Consequences of poor content modeling

Content modeling is critical. Mistakes at this stage are costly. A typical problem: a body field of type rich text for everything. Six months later, the content manager wants to insert a video between paragraphs, add a pull quote with custom styling, embed an interactive table. Rich text can‘t handle that. Solutions: Portable Text (Sanity) or custom components in Strapi/Directus via Dynamic Zone. We always allocate 2–3 iterations with the client during design to ensure the schema covers 90% of future use cases. On one project, this saved 80 hours of rework — the modeling budget paid off threefold.

How we build projects on headless CMS

Frontend for headless CMS almost always uses Next.js (App Router) or Nuxt. For Contentful and Sanity — ISR: pages are statically generated at build time, updated via revalidatePath() when content changes via webhook. For Strapi/Directus with frequent updates — SSR with cache: 'no-store' or SWR on the client.

Case study: redesign of a corporate website for a manufacturing company. Previous site: WordPress with ACF, 200+ pages, 4 languages. Problems: TTFB 3.8 s, editors complained about slow admin. Migrated to Strapi (self-hosted, PostgreSQL), Next.js App Router. Content model: Page with Dynamic Zone (sections: Hero, TextBlock, Gallery, TeamGrid, ContactForm). Localization via Strapi i18n plugin + next-intl on frontend. Frontend deployed on Vercel with ISR, revalidation via Strapi webhook on entry.publish. According to the client: TTFB dropped from 3.8 s to 180 ms (static with CDN) — a 21× improvement. Editors got a clean interface without 47 plugins. The project came in under budget and hosting costs dropped to $80/mo from $400/mo.

Implementation process broken into stages:

  1. Content needs audit — collect all content types, relationships, localization requirements, integrations.
  2. Data schema design — create models, fields, validation, access roles. Document in Swagger/OpenAPI.
  3. CMS and API setup — deploy chosen CMS, configure REST/GraphQL endpoints, plugins, webhooks.
  4. Frontend development — connect Next.js/Nuxt, configure ISR/SSR, section components, routing.
  5. Content migration (if legacy) — automated loading via API or scripts.
  6. Testing — check API endpoints, regression, load testing, Core Web Vitals.
  7. Deployment — configure CDN, SSL, CI/CD, monitoring.

How long does implementation take?

The standard path includes all stages. Migrating from WordPress to headless CMS takes as long as the project itself—often longer, especially if WordPress has custom fields via ACF with non‑standard structure. Our typical timelines:

Project Type Timeline
Simple site on Strapi + Next.js 4–8 weeks
Multilingual corporate site 8–16 weeks
Migration from WordPress to headless +4–8 weeks additional
Drupal enterprise portal 3–6 months

Cost is calculated individually after a brief. Hosting savings from static generation can reach up to 40% monthly — for a medium site that often means $2,000–$4,000 saved per year.

Non‑obvious considerations when choosing a headless CMS

  • Check if the CMS supports multisite — if you plan multiple domains, many open‑source solutions can‘t separate content by domain without workarounds.
  • Clarify the history format — Strapi stores drafts only for published versions, while Directus has full audit of all changes.
  • Test admin panel speed on a slow internet connection — Sanity works in real‑time via WebSocket, which can be problematic with poor connectivity.
  • Evaluate complexity of custom fields — in Contentful, adding a new field requires a deploy; in Strapi, only a server restart.
  • Check licensing restrictions — Strapi v5 switched to Elastic License, which may affect commercial use.

What is included

  • Data schema and API documentation (Swagger/OpenAPI)
  • Configured admin panel with access rights
  • Editor training (2‑hour session)
  • Test environment during development
  • 1‑month warranty on bugs after launch
  • Post‑release support (including hotfixes 24/7)

Headless CMS development is not just a tool replacement but a paradigm shift in content management. We help make this transition without downtime or data loss. Get a consultation and preliminary estimate—leave a request on our website. Order headless CMS implementation with guaranteed results.