Backend Development

Backend Roadmap

Connect Go fundamentals to a production-style service without skipping the engineering boundaries.

What you will learn

By the end of this lesson, you will be able to:

  • identify the main boundaries in a backend service;
  • separate transport, business, and storage concerns;
  • explain why production readiness includes more than endpoint code;
  • plan a service in vertical slices;
  • choose a sensible order for the remaining backend lessons.

Mental model: a backend is a long-running coordinator

A backend accepts work from outside the process, validates it, applies business rules, reads or changes state, and returns a result. It must keep doing that while requests overlap, dependencies fail, deployments replace the process, and invalid or hostile input arrives.

The HTTP handler is only the outer edge.

client
  ↓
HTTP transport
  ↓
application service
  ↓
repository or external client
  ↓
database / remote service

Cross-cutting concerns surround the flow:

  • configuration;
  • logging, metrics, and tracing;
  • authentication and authorization;
  • cancellation and timeouts;
  • graceful startup and shutdown;
  • tests and security checks.

Start with one vertical slice

Do not create dozens of empty packages before implementing a feature. Begin with one small use case, such as creating and listing lessons:

POST /lessons
GET  /lessons

Implement the complete path:

  1. Parse the request.
  2. Validate its shape.
  3. Apply business rules.
  4. Store or retrieve data.
  5. Map the result to an HTTP response.
  6. Test success and failure.

Then extract boundaries that have demonstrated a reason to exist.

A practical package shape

cmd/api/main.go
internal/
  lesson/
    lesson.go
    service.go
    repository.go
  httpapi/
    routes.go
    lessons.go
    middleware.go
  postgres/
    lessons.go

This is an example, not a required standard.

  • cmd/api wires dependencies and owns process lifetime.
  • lesson contains domain concepts and use cases.
  • httpapi translates HTTP into application calls.
  • postgres implements storage details.

Keep package names short, concrete, and based on responsibility. Avoid catch-all packages named utils, common, or helpers when a more specific home exists.

Dependency direction

Inner application code should not need to know HTTP status codes or SQL driver details.

type LessonRepository interface {
    Create(ctx context.Context, lesson Lesson) error
    List(ctx context.Context) ([]Lesson, error)
}

type Service struct {
    repository LessonRepository
}

The service declares the behaviour it needs. A database adapter implements that behaviour. The command chooses the implementation and connects them.

Do not create an interface automatically for every struct. Add one at a consumer boundary when multiple implementations, testing isolation, or architectural separation provides real value.

Production questions to answer

Before calling a service production-ready, ask:

  • How are timeouts set at the server, request, database, and external-client levels?
  • What happens when the client disconnects?
  • Which operations can be retried safely?
  • How are secrets provided and protected?
  • What is logged, measured, and traced?
  • How does the process signal readiness and health?
  • How are schema changes deployed?
  • How does shutdown stop new work and drain current work?
  • How can a failed release be rolled back?

These are design inputs, not cleanup tasks for the final day.

Learning sequence

Follow this section in order:

  1. HTTP API design
  2. Middleware
  3. Validation
  4. Application wiring and configuration
  5. Observability
  6. database/sql
  7. Transactions
  8. Authentication and authorization
  9. Graceful shutdown
  10. Production checklist

Common mistakes

  • Beginning with a framework: framework knowledge cannot replace understanding HTTP, context, ownership, and errors.
  • Designing every future layer first: unused abstractions make change harder.
  • Letting handlers contain all business logic: reuse and focused testing become difficult.
  • Passing database rows directly to clients: storage schema changes become API changes.
  • Calling a service production-ready because it starts: operability and safe failure are part of correctness.

Practice

Sketch the request path for creating a lesson. Name the data type at each boundary, which layer validates it, which layer owns the business rule, and how cancellation reaches storage.

Summary

  • A backend coordinates transport, application rules, storage, and operations.
  • Build one complete vertical slice before introducing many abstractions.
  • Keep HTTP and SQL details out of core business rules.
  • Interfaces belong at useful consumer boundaries, not everywhere.
  • Production behaviour includes cancellation, security, observability, and lifecycle management.

Ready to wrap up?

Mark this complete when you can explain the main idea and finish the practice task.

Copyright © 2026