linekit follows a modular architecture to ensure separation of concerns and flexibility.
- Responsibility: Foundation logic that is framework-agnostic.
- Components:
Webhook: Middleware for signature verification and body parsing.Router: Dispatches normalized events to handlers.Context: Wraps the raw LINE event and provides convenience methods (reply, push).Types: Shared TypeScript definitions.
- Responsibility: Wrapper around LINE Messaging API.
- Components:
Client:fetch-based HTTP client.Methods:reply,push,multicast,richMenu.- Dependency: Used by
Coreto implementContextmethods.
- Responsibility: OIDC and OAuth flow.
- Independent: Can be used without Core/Messaging (e.g., for a login-only site).
- Responsibility: Glue code between
Coreand web frameworks. - Components:
@linekit/express: Adapts Expressreq/resto Core's middleware signature.
- Responsibility: LIFF management (Server-side) and types.
- Components:
Client: CRUD operations for LIFF Apps.Types: Type definitions for LIFF View.
graph TD
UserCode[User Application]
subgraph "@linekit/core"
Webhook
Router
Context
end
subgraph "@linekit/messaging"
MsgClient[Client]
end
subgraph "@linekit/login"
OAuth
TokenVerify
end
subgraph "@linekit/liff"
LiffClient
end
UserCode --> Webhook
UserCode --> Router
Router --> Context
Context --> MsgClient
UserCode --> LiffClient
UserCode --> OAuth
- LINE Platform sends POST request to your server.
- Adapter (e.g. Express) receives request.
- Webhook Middleware (
@linekit/core) validatesX-Line-Signature. - Router (
@linekit/core) iterates overeventsarray. - Context is created for each event.
- Handler (User code) is executed with
ctx. - Response (200 OK) is sent back to LINE.