Skip to content

Commit 2edc4ad

Browse files
author
Mohammad Hamdan
committed
Add README.md File
1 parent b386216 commit 2edc4ad

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Real-Time Item Tracking Service
2+
3+
A Go-based real-time tracking service using **WebSocket**, **gRPC**, and **Redis** for persistent geolocation data.
4+
5+
## Features
6+
7+
- **WebSocket API** to receive live position updates from clients.
8+
- **gRPC API** for backend services to retrieve current positions.
9+
- **Redis** storage for fast reads and writes.
10+
- Thread-safe client connection management.
11+
- Basic error handling and logging.
12+
13+
## Requirements
14+
15+
- Go 1.21+
16+
- Redis 7+
17+
- Protocol Buffers Compiler (`protoc`)
18+
19+
## Installation
20+
21+
```bash
22+
git clone https://github.com/<your-username>/<your-repo>.git
23+
cd <your-repo>
24+
go mod tidy
25+
```
26+
27+
## Configuration
28+
29+
Set the required environment variables:
30+
31+
```bash
32+
export REDIS_ADDR="localhost:6379"
33+
export REDIS_PASSWORD="yourpassword"
34+
export GRPC_PORT="50051"
35+
export WS_PORT="8080"
36+
```
37+
38+
## Running the Service
39+
40+
```bash
41+
go run cmd/server/main.go
42+
```
43+
44+
## WebSocket Usage
45+
46+
1. Connect to: `ws://localhost:8080/ws`
47+
2. Send handshake JSON:
48+
49+
```json
50+
{
51+
"item_id": "your-item-id"
52+
}
53+
```
54+
55+
3. Send position updates:
56+
57+
```json
58+
{
59+
"latitude": 35.6895,
60+
"longitude": 139.6917
61+
}
62+
```
63+
64+
## gRPC Usage
65+
66+
The gRPC service exposes:
67+
68+
- **GetCurrentPosition** — Retrieve the latest position for an item.
69+
70+
Example gRPC call in Go:
71+
72+
```go
73+
resp, err := client.GetCurrentPosition(ctx, &pb.ItemRequest{ItemId: "your-item-id"})
74+
if err != nil {
75+
log.Fatal(err)
76+
}
77+
fmt.Println(resp)
78+
```
79+
80+
## Versioning
81+
82+
Current release: **v0.1.0**
83+
Following [Semantic Versioning](https://semver.org/).
84+
85+
## License
86+
87+
MIT License

0 commit comments

Comments
 (0)