Community Platform
The HIL community platform is where builders share projects, ask questions, and talk hardware in real time. It powers the Community page on the website and the social features of the HIL mobile app.
Features
| Feature | Description |
|---|---|
| Posts | Share builds with markdown-friendly text (10 000 chars), up to 6 images, project links, and video URLs. Hashtags (#tag) and mentions (@user) are extracted automatically. |
| Reactions | Five reaction types per post: 👍 like, ❤️ love, 😂 haha, 🥰 care, 😡 angry. One active reaction per user; reacting again toggles it off or switches type. |
| Comments | Threaded under each post, deletable by their author. |
| Hashtags | Auto-extracted from post content with trending counts and a per-tag feed endpoint. |
| Follows | Follow/unfollow builders; authenticated users get a personalized /feed of followed authors. |
| Live chat | Room-based WebSocket messaging (general, help, showcase, hardware, lisp) with typing indicators and broadcast fan-out. |
| Search | Unified full-text search across posts, users, and hashtags. |
Quick start
Register and log in
API=https://hil.mediahubnetwork.net/community/api
# Create an account
curl -s -X POST $API/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"maker_jane","email":"jane@example.com","password":"s3cret-pass"}'
# → {"success":true,"token":"eyJ...","user":{...}}
# Log in later (username OR email works)
curl -s -X POST $API/auth/login \
-H "Content-Type: application/json" \
-d '{"identifier":"maker_jane","password":"s3cret-pass"}'
All authenticated endpoints accept the token as an Authorization: Bearer <token> header.
Post with hashtags
TOKEN="eyJ..."
curl -s -X POST $API/posts \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"content":"My NeoPixel matrix is alive! #neopixel #showcase @hil_admin"}'
The service extracts #neopixel and #showcase into the hashtag index and resolves @hil_admin into structured mentions.
REST API reference
Base URL: https://hil.mediahubnetwork.net/community/api (same-origin path /community/api when served from the site).
Health & stats
| Method | Path | Description |
|---|---|---|
| GET | /health | Service health, store sizes, configured limits. |
Auth
| Method | Path | Body | Notes |
|---|---|---|---|
| POST | /auth/register | {username, email, password} | Rate-limited; returns {token, user}. |
| POST | /auth/login | {identifier, password} | identifier may be username or email. |
| POST | /auth/logout | – | Invalidates the session server-side. |
Posts
| Method | Path | Query / body | Notes |
|---|---|---|---|
| GET | /posts | page, limit, sort=latest|likes, tag | Paginated feed. |
| GET | /posts/:id | – | Returns {post, comments[]}. |
| POST | /posts | {content, images?, projectId?} | Auth required. Images are data-URLs (≤4 MB) or HTTPS links. |
| DELETE | /posts/:id | – | Author only. |
| POST | /posts/:id/like | {type} | type ∈ {like, love, haha, care, angry}; toggles. |
| POST | /posts/:id/comment | {content} | Auth required. |
| DELETE | /comments/:id | – | Comment author only. |
A serialized post looks like:
{
"id": "b1946ac9…",
"authorId": "83e9954a…",
"authorName": "maker_jane",
"content": "My NeoPixel matrix is alive!",
"images": [],
"hashtags": ["neopixel", "showcase"],
"mentions": ["hil_admin"],
"reactions": {"like": 3, "love": 1, "haha": 0, "care": 0, "angry": 0},
"comments": 2,
"createdAt": 1787581494450,
"updatedAt": 1787581600123
}
Hashtags, feed & users
| Method | Path | Notes |
|---|---|---|
| GET | /hashtags | Trending tags {name, count, posts} sorted by recency-weighted usage. |
| GET | /hashtags/:tag/posts?page=&limit= | Chronological posts carrying that tag. |
| GET | /feed?page= | Auth required — posts from followed users. |
| GET | /users/:id | Public profile. |
| GET | /users/:id/posts?page= | A builder's posts. |
| POST | /users/:id/follow | Auth required — toggles follow state. |
Search
| Method | Path | Response |
|---|---|---|
| GET | /search?q= | {posts[], users[], hashtags[]} |
Live chat protocol
Connect to the WebSocket at wss://hil.mediahubnetwork.net/community/ws (proxied to the community service). All frames are JSON.
Client → server
type | Payload | Effect |
|---|---|---|
auth | {token} | Associates the socket with your user; required to send. |
join_room | {roomId} | Subscribes the socket to room broadcasts. |
leave_room | {roomId} | Unsubscribes. |
send_message | {roomId, content} | Requires auth; content ≤ 2000 chars. Broadcast as chat_message. |
typing / stopped_typing | {roomId, userName} | Relayed to other room members only. |
reaction | {payload} | Broadcast to everyone. |
Server → client
type | Payload |
|---|---|
connected | {clientId} handshake confirmation. |
auth_ok / auth_error | {userId, username} / error message. |
joined_room | {roomId} confirmation. |
chat_message | {roomId, data:{id, roomId, userId, userName, content, timestamp}}. |
typing / stopped_typing | {roomId, userName, userId}. |
error | Human-readable failure message. |
Minimal browser client:
const ws = new WebSocket('wss://hil.mediahubnetwork.net/community/ws');
ws.onopen = () => ws.send(JSON.stringify({type:'join_room', roomId:'showcase'}));
ws.onmessage = (ev) => {
const msg = JSON.parse(ev.data);
if (msg.type === 'chat_message') console.log(`${msg.data.userName}: ${msg.data.content}`);
};
function say(text) {
ws.send(JSON.stringify({type:'send_message', roomId:'showcase', content:text}));
}
Limits & safety
- Post content ≤ 10 000 chars; chat messages ≤ 2 000 chars.
- Up to 6 images per post, each ≤ 4 MB (base64 data URLs).
- Rate limits: 300 requests/min/IP general, tighter budget on auth endpoints (default 10/min), configurable via
RATE_LIMIT_*env vars. - Passwords are salted-hashed before storage; sessions are signed tokens validated on every request.
- Stores are in-memory by design (community is ephemeral); swap in Redis behind the same interface for persistence.
Deployment
The community service ships in the microservices stack:
cd microservices
docker compose up -d hil-community-service # listens on :5010
Or run directly with pm2 (as on this host):
cd microservices/community && PORT=5010 pm2 start index.js --name hil-community
The site server transparently proxies /community/api/* (HTTP) and /community/ws (WebSocket upgrade, raw TCP pass-through) so browsers never need a second origin.
References
- Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., Leach, P., & Berners-Lee, T. (1999). Hypertext Transfer Protocol -- HTTP/1.1 (RFC 2616). IETF. https://doi.org/10.17487/RFC2616
- Fette, I., & Melnikov, A. (2011). The WebSocket Protocol (RFC 6455). IETF. https://doi.org/10.17487/RFC6455
- Jones, M., Bradley, J., & Sakimura, N. (2015). JSON Web Token (JWT) (RFC 7519). IETF. https://doi.org/10.17487/RFC7519