How mizunie/nexar works
1. Repository shape
- This is a TypeScript SDK package, not an application server.
- The main deliverable is a library that consumers install from npm and use from their own runtime.
2. Public entry point
- src/index.ts is the package façade.
- The README shows the main entry as Nexar.init({ token, businessId, baseUrl? }), so the package exposes a root Nexar object that creates a configured client instance.
3. Core shared layer
- src/core/httpClient.ts is the shared transport abstraction.
- src/core/types.ts defines common SDK shapes such as the response envelope used across modules.
- This core layer is the boundary between typed SDK methods and raw HTTP calls to Nexar APIs.
4. Module-based client design
- The SDK is split into domain modules under src/modules/.
- There are at least two top-level service areas:
- whatsapp for messaging operations
- iawaba for the file/indexed-document API
- Each module has its own client implementation, which keeps API-specific behavior isolated from the transport and package entry point.
5. WhatsApp subsystem
- src/modules/whatsapp/client.ts and src/modules/whatsapp/types.ts define the WhatsApp API surface.
- From the README, this module supports:
- send text
- quick text
- templates
- interactive messages with buttons
- The data boundary here is mostly message payload construction and response typing.
6. IA WABA subsystem
- src/modules/iawaba/client.ts handles the indexed-document/file API.
- The README indicates operations for upload/update and soft delete, with automatic checksum generation handled by the SDK.
- This module represents a separate business workflow from WhatsApp: document lifecycle management rather than messaging.
7. Configuration and request flow
- The consumer provides token and businessId at initialization, plus optional baseUrl.
- That config flows into the shared HTTP client and then into each module client.
- All module methods ultimately call Nexar backend endpoints on the configured API host.
8. API contract and responses
- The SDK standardizes responses around an ApiResponse<T>-style envelope with fields like code, msg, data, errorDetail, and optional pagination.
- This means the library is not just a thin fetch wrapper; it normalizes backend responses into a typed SDK contract.
9. Runtime and portability
- The README states support for Node.js 18+, Bun, Deno, Edge runtimes, and browsers if CORS is enabled.
- Architecturally, that implies the SDK is designed around runtime-neutral HTTP access rather than Node-only APIs.
10. External integration boundary
- All outbound communication goes to Nexar services, primarily the default API base https://back.nexar.com.co or a custom baseUrl.
- The IA WABA endpoint is explicitly called out as POST /iawaba/api-receptor/{businessId}, showing that business identity is part of the request path, not just headers.
11. Packaging and release
- .github/workflows/publish.yml indicates automated publishing to npm.
- That workflow is part of the library distribution boundary rather than runtime behavior, but it is relevant to the overall architecture of how the SDK ships.
12. How to diagram it
- A clean architecture diagram would show:
- the consumer app at the edge
- the Nexar initialization layer
- shared core/httpClient
- module clients for whatsapp and iawaba
- outbound calls to Nexar REST APIs
- The key separation is between configuration + typed module methods on the inside, and HTTP/API endpoints on the outside.
Main entry points: index.ts Nexar init · whatsapp/client.ts WhatsApp client · httpClient.ts HTTP client · iawaba/client.ts IA WABA client
Components 14
Public API
Package entry and consumer-facing initialization
- Consumer App · Host application using the Nexar SDK
- Nexar init · Root package entry that creates a configured client
src/index.ts - Client config · Token, businessId, and optional baseUrl passed into the SDK
src/index.ts - Multi-runtime · Node.js, Bun, Deno, edge, and browser-friendly HTTP access
Core
Shared transport and SDK contract layer
- HTTP client · Shared runtime-neutral request layer
src/core/httpClient.ts - API types · Common response envelope and shared SDK shapes
src/core/types.ts
Modules
Domain-specific service clients
- WhatsApp client · Messaging operations for WhatsApp
src/modules/whatsapp/client.ts - WhatsApp types · WhatsApp message and response typing
src/modules/whatsapp/types.ts - IA WABA client · Indexed-document and file lifecycle operations
src/modules/iawaba/client.ts - Send flow · Text, quick text, templates, and interactive messages
- Doc flow · Upload, update, checksum handling, and soft delete
External APIs
Nexar backend endpoints consumed by the SDK
- WhatsApp API · Nexar messaging service endpoints
- IA WABA API · Nexar indexed-document endpoint on the business-scoped path
Release
Packaging and publish automation
- Publish workflow · GitHub workflow that publishes the package to npm
.github/workflows/publish.yml
Connections 15
- Consumer App → Nexar init: imports · Application code calls the package entry point
- Nexar init → Client config: creates · Initializes a client from token, businessId, and baseUrl
- Nexar init → HTTP client: wires · Passes configuration into the shared transport layer
- Nexar init → WhatsApp client: exposes · Makes WhatsApp operations available on the client
- Nexar init → IA WABA client: exposes · Makes IA WABA operations available on the client
- HTTP client → API types: normalizes · Wraps backend responses in a shared typed envelope
- WhatsApp client → WhatsApp types: uses · Builds and validates WhatsApp payloads
- WhatsApp client → HTTP client: calls · Sends module requests through the shared transport
- IA WABA client → HTTP client: calls · Sends file workflow requests through the shared transport
- WhatsApp client → Send flow: implements · Supports text, quick text, templates, and interactive messages
- IA WABA client → Doc flow: implements · Supports upload, update, checksum, and soft delete flows
- Send flow → WhatsApp API: targets · Routes messaging requests to Nexar WhatsApp endpoints
- Doc flow → IA WABA API: targets · Routes document requests to the business-scoped IA WABA endpoint
- Client config → Multi-runtime: supports · Designed to work across Node, Bun, Deno, edge, and browsers
- Publish workflow → Nexar init: ships · Automated release publishes the package entry and modules to npm