Skip to content

icoder-new/order_api

Repository files navigation

Order Processing System

Go MSSQL

A REST API for order management with background processing, built with Go and MSSQL.

Key Features

  • REST API:
    • Create orders with items
    • Get order details
    • List all orders
  • Background Processing:
    • Automatic status transitions: CreatedProcessingCompleted
    • Each transition takes 5 seconds
  • Database:
    • MSSQL storage
    • Automatic table creation
  • Production-Ready:
    • Graceful shutdown
    • Health checks
    • Structured logging

API Endpoints

Method Endpoint Description
POST /orders Create new order
GET /orders/{id} Get order by ID
GET /orders List all orders
GET /health System health check

System Architecture

┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│   API Layer │ →  │  Service    │ →  │ Repository  │ →  │  MSSQL DB   │
└─────────────┘    │ (Business   │    │ (Data Access│    └─────────────┘
                   │  Logic)     │    │  Layer)     │
                   └─────────────┘    └─────────────┘

Getting Started

Prerequisites

  • Go 1.21+
  • MSSQL Server 2019+
  • Docker (optional)

With Docker

docker-compose up --build -d

Configuration (.env)

DB_SERVER=db
DB_USERID=sa
DB_PASSWORD=YourStrong!Passw0rd
DB_DATABASE=master

Development

# Start locally
go run .

Original Task Requirements

We implemented:

  • ✔️ REST API for order management
  • ✔️ Background order processing
  • ✔️ MSSQL database integration
  • ✔️ Graceful shutdown
  • ✔️ Health check endpoint
  • ✔️ Structured logging to file

About

Order Processing System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published