> For the complete documentation index, see [llms.txt](https://faisalaffan.gitbook.io/design-system/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://faisalaffan.gitbook.io/design-system/id/01-memulai/architecture.md).

# Arsitektur

## Desain Tingkat Tinggi

```mermaid
%%{init: {"theme": "base", "themeVariables": {"background": "#ffffff"}}}%%
flowchart TB
    subgraph "Batch 1 -- Core"
        US["url-shortener :8080"]
        RL["rate-limiter :8081"]
    end
    subgraph "Batch 2 -- Data"
        ID["unique-id-generator :8084"]
        KV["key-value-store :8085"]
        AC["search-autocomplete :8086"]
    end
    subgraph "Batch 3 -- Realtime"
        CS["chat-system :8082"]
        NS["notification-system :8083"]
    end
    subgraph "Batch 4 -- Scale"
        NF["news-feed :8087"]
        WC["web-crawler :8088"]
    end
    subgraph "Batch 5 -- Storage"
        YT["youtube :8089"]
        GD["google-drive :8090"]
    end
    subgraph "Shared"
        KIT["pkg/kit"]
        CH["pkg/consistenthash"]
    end
    US --> KIT
    RL --> KIT
    ID --> KIT
    KV --> KIT
    KV --> CH
    AC --> KIT
    CS --> KIT
    NS --> KIT
    NF --> KIT
    WC --> KIT
    YT --> KIT
    GD --> KIT
```

## Paket Bersama

### pkg/kit

Gin factory, config loader, helper respons JSON, tipe AppError, dan middleware (recovery, logging, rate-limit bridge).

### pkg/consistenthash

Hash ring dengan 150 virtual node per physical node. Hashing `crc32`. Digunakan oleh key-value-store untuk pemetaan shard-ke-node.

## Filosofi Desain

* **Interface-first**: setiap layanan mendefinisikan interface `Storage`. Default in-memory, dapat diganti ke Redis/Postgres.
* **Modul tunggal**: satu `go.mod` di root. Semua layanan berbagi versi dependensi yang sama.
* **Graceful shutdown**: setiap layanan menangani SIGINT/SIGTERM dengan timeout 5 detik.
* **Gin Gonic**: framework HTTP yang konsisten di semua layanan.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://faisalaffan.gitbook.io/design-system/id/01-memulai/architecture.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
