Skip to content

Commit 8972d95

Browse files
committed
docs: Replace README with comprehensive CHANGELOG documentation
1 parent cea6285 commit 8972d95

2 files changed

Lines changed: 61 additions & 96 deletions

File tree

chat-app/CHANGELOG.md

Lines changed: 0 additions & 74 deletions
This file was deleted.

chat-app/README.md

Lines changed: 61 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,74 @@
1-
# Write and Deploy Chat Application Frontend and Backend
1+
## Changes Made
22

3-
### Link to the coursework
3+
### Backend Implementation (`backend/`)
44

5-
https://sdc.codeyourfuture.io/decomposition/sprints/2/prep/
5+
#### `server.js` (New)
6+
- Set up Express server with CORS middleware
7+
- Implemented **POST `/messages`** endpoint with input validation
8+
- Validates sender name and message text
9+
- Creates message objects with id, sender, text, likes, and dislikes
10+
- Returns 201 status on success, 400 on validation error
11+
- Triggers long polling callbacks to notify waiting clients
12+
13+
- Implemented **GET `/messages`** endpoint with long polling
14+
- Accepts `?since=` query parameter for incremental message loading
15+
- Returns only messages with id > sinceId
16+
- Holds client requests until new messages arrive (long polling)
17+
- Handles edge case where since=0 correctly
18+
19+
- Implemented **POST `/messages/:id/like`** endpoint
20+
- Increments like count for specified message
21+
- Notifies all waiting clients via long polling
22+
- Returns 200 on success, 404 if message not found
623

7-
You must complete and deploy a chat application. You have two weeks to complete this.
24+
#### `package.json` (New)
25+
- Configured as ES module project (`"type": "module"`)
26+
- Added Express 5.2.1 dependency
27+
- Added CORS 2.8.6 dependency
828

9-
It must support at least the following requirements:
29+
### Frontend Implementation (`frontend/`)
1030

11-
- As a user, I can send add a message to the chat.
12-
- As a user, when I open the chat I see the messages that have been sent by any user.
13-
- As a user, when someone sends a message, it gets added to what I see.
31+
#### `index.html` (New)
32+
- Semantic HTML structure with proper meta tags
33+
- Chat form with sender name and message inputs
34+
- Message container div for displaying chat history
35+
- Deferred JavaScript execution for proper DOM loading
1436

15-
It must also support at least one additional feature.
37+
#### `script.js` (New)
38+
- **`getAllMessages()`** async function
39+
- Fetches messages from backend with `?since=` parameter
40+
- Implements incremental message loading via `lastIdSeen` tracking
41+
- Updates existing message likes without re-rendering
42+
- Creates DOM elements for new messages with text, like count, and like button
43+
- Uses long polling with `setTimeout(getAllMessages, 0)` for real-time updates
44+
- Includes error handling with automatic retry on fetch failure
1645

17-
### Why are we doing this?
46+
- **Form submission handler**
47+
- Validates sender name and message text
48+
- Sends POST request with JSON payload
49+
- Clears input fields after successful submission
50+
- Includes try-catch error handling
1851

19-
Learning about deploying multiple pieces of software that interact.
52+
- **Like button functionality**
53+
- Sends POST request to `/messages/:id/like` endpoint
54+
- Extracts current like count from DOM
55+
- Provides immediate UI feedback (optimistic update)
56+
- Updates display instantly without waiting for server response
2057

21-
Designing and implementing working software that users can use.
58+
#### `styles.css` (New)
59+
- Styled message containers with border, padding, and rounded corners
60+
- Light gray background (#f9f9f9) for message boxes
61+
- Styled like buttons with blue background (#007bff) and white text
62+
- Proper spacing and cursor pointer for better UX
2263

23-
Exploring and understanding different ways of sending information between a client and server.
64+
## Testing Instructions
2465

25-
### Maximum time in hours
66+
### Setup
67+
```bash
68+
# Install backend dependencies
69+
cd backend
70+
npm install
2671

27-
16
72+
# Start backend server
73+
node server.js
2874

29-
### How to submit
30-
31-
- Fork the Module-Decomposition repository
32-
- Develop and deploy your chat app
33-
- Create a pull request back into the original Module-Decomposition repo, including:
34-
- A link to the deployed frontend on the CYF hosting environment
35-
- A link to the deployed backend on the CYF hosting environment

0 commit comments

Comments
 (0)