From 9de79d20431346c6447408a1760f6c6e0cfd766a Mon Sep 17 00:00:00 2001 From: Golden_Eagle07 Date: Wed, 8 Jul 2026 16:51:22 +0530 Subject: [PATCH 1/3] updated docs --- README.md | 21 -- docs/API_CONTRACTS.md | 708 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 689 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index ea19717..c06ad3f 100644 --- a/README.md +++ b/README.md @@ -102,27 +102,6 @@ go run main.go Make sure PostgreSQL is running and reachable using the values in your `.env` file (`POSTGRES_HOST`, `POSTGRES_PORT`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_DB`). -### Running database migrations - -```bash -cd server -psql "postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@$POSTGRES_HOST:$POSTGRES_PORT/$POSTGRES_DB" \ -for migration in /app/migrations/*_up.sql; do - filename=$(basename "$migration") - already_applied=$(psql "${DB_URL}" -tAc \ - "SELECT COUNT(*) FROM schema_migrations WHERE filename = '${filename}'") - if [ "$already_applied" = "0" ]; then - echo "Applying ${filename}..." - psql "${DB_URL}" -f "$migration" - psql "${DB_URL}" -c \ - "INSERT INTO schema_migrations (filename) VALUES ('${filename}')" - echo "${filename} applied." - else - echo "${filename} already applied, skipping." - fi -done -``` - ### Running the mobile app ```bash diff --git a/docs/API_CONTRACTS.md b/docs/API_CONTRACTS.md index ddf2c08..3cfe8ab 100644 --- a/docs/API_CONTRACTS.md +++ b/docs/API_CONTRACTS.md @@ -19,11 +19,23 @@ | GET | [/api/users/me](#1-user-me) | Get the authenticated user's profile | | GET | [/api/users/:id](#2-search-user-by-id) | Search users by username or display name | | GET | [/api/users/search?q=&page=&limit=](#3-search-user-by-username-and-display-name) | Get a public user profile | -| GET | [/ws](#websocket-endpoints) | WebSocket upgrade endpoint (JWT required) | +| GET | [/ws](#1-connect-to-websocket) | WebSocket upgrade endpoint (JWT required) | +| WS | [Client to Server](#2-client-to-server-messages) | Client to Server Websocket | +| WS | [Server to Client](#3-server-to-client-messages) | Server to Client Websocket | | POST | [/api/messages](#1-send-message) | Send a message (REST fallback) | | GET | [/api/messages?with=&before=&limit=](#2-message-history) | Paginated message history | +| GET | [/api/messages/conversations](#3-conversations) | Get user conversatiosn | +| POST | [/api/messages/read](#4-read) | Get read mark | +| POST | [/api/groups/](#1-create-group) | Create Group | +| GET | [/api/groups/](#2-get-groups) | Get all groups of user | +| GET | [/api/group/{id}](#3-get-group-by-group-id) | Get group by group id | +| GET | [/api/groups/{id}/messages](#4-get-messages-of-group) | Get message of a group | +| GET | [/api/groups/{id}/members](#5-group-members) | Get group members | +| POST | [/api/groups/{id}/leave](#6-leave-group) | Leave a group | +| PATCH | [/api/groups/{id}/](#7-update-group-details) | Update Group Details | +| POST | [/api/groups/{id}/members](#8-add-member-to-group) | Add members to group | +| DELETE | [/api/groups/{id}/members/{user_id}](#9-remove-user-from-group) | Remove member from group | -All endpoints except `/api/health`, `/api/auth/register`, and `/api/auth/login` require a `Bearer` token in the `Authorization` header. ## Health Endpoint @@ -45,7 +57,7 @@ Returned when the server runtime is healthy and can successfully execute a ping "success": true, "data": { "postgres": "up", - "timestamp": "