TechnologyBackend
[Backend] eureka-chats-api
Serverless real-time chat microservice with WebSocket integration. serverless backend API service for real-time chat applications.
eureka-chats-api
Serverless real-time chat microservice with WebSocket integration.
Summary
- serverless backend API service for real-time chat applications.
- This project is a sample chat boilerplate based on AWS Lambda and Node.js.
- Key features include WebSocket-based real-time messaging through integration with the
eureka-sockets-apimicroservice, chat room management, and user session handling. - Note: To use this project, you must first deploy the
eureka-sockets-apimicroservice to the cloud.
Getting Started
- Pre requirements (or installations) before starting.
-
- aws-cli with api-key
-
- (optional) httpie
-
- (optional) wscat
-
- Fork(or clone), develop and deploy the serverless api.
# clone the code.
$ git clone https://github.com/lemoncloud-io/eureka-sockets-api.git
# STEP.1 install the dependecies.
$ npm ci
# STEP.2 run the server locally.
$ npm run express
# STEP.3 make request and develop locally.
$ http :8832/hello
# STEP.4 deploy into your AWS cloud (`AWS-Key` is required).
$ npm run deploy
# (example) try to connect to a WebSocket
$ wscat -c wss://a5jxmksfa2.execute-api.ap-northeast-2.amazonaws.com/dev
# STEP.5 check the deploy info
$ npm run info
# STEP.6 remove(or uninstall)
$ npm run removeArchitecture and Modeling
Infrastructure Components
Data Modeling
Chat Flow Architecture
Module Structure
src/
├── cores/ # Common architecture
│ ├── abstract-controllers.ts # CRUD controller base
│ ├── abstract-services.ts # Service layer base
│ └── types.ts # Common types
├── modules/ # Business modules
│ ├── chats/ # Chat service (core module)
│ │ ├── api-chats.ts # Chat API controller
│ │ ├── api-rooms.ts # Chat room API controller
│ │ ├── model.ts # Chat data model
│ │ ├── service.ts # Chat business logic
│ │ ├── proxy.ts # Chat data access
│ │ ├── transformer.ts # Data transformation
│ │ ├── types.ts # Chat type definitions
│ │ └── views.ts # Chat view models
│ ├── callback/ # External callback handling
│ │ ├── api-callback.ts
│ │ ├── model.ts
│ │ ├── service.ts
│ │ └── ...
│ ├── mock/ # Test mock data
│ │ ├── api-mocks.ts
│ │ ├── api-tests.ts
│ │ └── ...
│ └── search/ # Search functionality
│ ├── api-search.ts
│ ├── model.ts
│ └── service.ts
├── service/ # Core services
│ ├── backend-service.ts # Main service
│ ├── backend-proxy.ts # Data access layer
│ └── backend-model.ts # Data models
└── api/ # API endpoints
├── hello-api.ts # Health check
└── crons-api.ts # Scheduled tasksKey Features
Chat Service Support
- Chat Room Management (Rooms)
- `GET /rooms` - List chat rooms
- `GET /rooms/{id}` - Get room details
- `POST /rooms/0` - Create new chat room
- `PUT /rooms/{id}` - Update room information
- `DELETE /rooms/{id}` - Delete chat room- Chat Messages (Chats)
- `GET /chats` - List messages (with pagination)
- `GET /chats/{id}` - Get message details
- `POST /chats/0/start-chat` - Join chat room
- `POST /chats/0/chat` - Send message
- `POST /chats/{nodeId}/leave-chat` - Leave chat roomUsage Examples
# Create chat room
POST /rooms/0
{
"name": "ChatRoom 1",
"isPrivate": false
}
# Join chat room
POST /chats/0/start-chat
{
"roomId": "room123",
"name": "guest",
"connectionId": "QXaagd6MIE0CFtw="
}
# Send new message
POST /chats/0/chat
{
"roomId": "room123",
"nodeId": "node123",
"message": "hello world"
}
# Leave chat room
POST /chats/<node-id>/leave-chatRelated Repositories
- eureka-sockets-api - WebSocket real-time messaging service (required)
- lemon-core - Common utility library
- eureka-hello-api - Serverless API boilerplate
- lemon-model - DynamoDB modeling framework
LICENSE
VERSION INFO
Version History
| Version | Description |
|---|---|
| 0.25.818 | implements chat-service. |
| 0.25.808 | optimized lemon-core@4.0.6 initially. |