Skip to content

Commit 0e2c62d

Browse files
committed
Update README files
1 parent f9d14ac commit 0e2c62d

3 files changed

Lines changed: 231 additions & 21 deletions

File tree

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
11
# Coursework
22

33
Exercises to practice and solidify your understanding of the Decomposition module of the Software Development Course.
4+
5+
# Write and Deploy Chat Application Frontend and Backend
6+
7+
### Link to the coursework
8+
9+
https://sdc.codeyourfuture.io/decomposition/sprints/2/prep/
10+
11+
You must complete and deploy a chat application. You have two weeks to complete this.
12+
13+
It must support at least the following requirements:
14+
* As a user, I can send add a message to the chat.
15+
* As a user, when I open the chat I see the messages that have been sent by any user.
16+
* As a user, when someone sends a message, it gets added to what I see.
17+
18+
It must also support at least one additional feature.
19+
20+
### Why are we doing this?
21+
22+
Learning about deploying multiple pieces of software that interact.
23+
24+
Designing and implementing working software that users can use.
25+
26+
Exploring and understanding different ways of sending information between a client and server.
27+
28+
### Maximum time in hours
29+
30+
16
31+
32+
### How to submit
33+
34+
* Fork the Module-Decomposition repository
35+
* Develop and deploy your chat app
36+
* Create a pull request back into the original Module-Decomposition repo, including:
37+
* A link to the deployed frontend on the CYF hosting environment
38+
* A link to the deployed backend on the CYF hosting environment

chat-app/README.md

Lines changed: 160 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,173 @@
1-
# Write and Deploy Chat Application Frontend and Backend
1+
# Chat Application
22

3-
### Link to the coursework
3+
A full-stack chat application built with React and Express.
44

5-
https://sdc.codeyourfuture.io/decomposition/sprints/2/prep/
5+
Users can:
6+
- join the chat with a username
7+
- send messages
8+
- see messages from all users
9+
- receive new messages automatically
10+
- see timestamps for messages
611

7-
You must complete and deploy a chat application. You have two weeks to complete this.
12+
---
813

9-
It must support at least the following requirements:
10-
* As a user, I can send add a message to the chat.
11-
* As a user, when I open the chat I see the messages that have been sent by any user.
12-
* As a user, when someone sends a message, it gets added to what I see.
14+
# Technologies Used
1315

14-
It must also support at least one additional feature.
16+
## Frontend
17+
- React
18+
- Vite
19+
- CSS
20+
- Fetch API
1521

16-
### Why are we doing this?
22+
## Backend
23+
- Node.js
24+
- Express
25+
- CORS
1726

18-
Learning about deploying multiple pieces of software that interact.
27+
---
1928

20-
Designing and implementing working software that users can use.
29+
# Features
2130

22-
Exploring and understanding different ways of sending information between a client and server.
31+
- Username selection
32+
- Send messages
33+
- Display all chat messages
34+
- Automatic message updates with polling
35+
- Additional Feature: Timestamps on messages
2336

24-
### Maximum time in hours
37+
---
2538

26-
16
39+
# Project Structure
2740

28-
### How to submit
41+
```txt
42+
chat-app/
43+
├── frontend/
44+
└── backend/
45+
```
2946

30-
* Fork the Module-Decomposition repository
31-
* Develop and deploy your chat app
32-
* Create a pull request back into the original Module-Decomposition repo, including:
33-
* A link to the deployed frontend on the CYF hosting environment
34-
* A link to the deployed backend on the CYF hosting environment
47+
---
48+
49+
# Setup Instructions
50+
51+
## 1. Clone the repository
52+
53+
```bash
54+
git clone https://github.com/trngdothuy/chat-app
55+
```
56+
57+
---
58+
59+
## 2. Install frontend dependencies
60+
61+
```bash
62+
cd frontend
63+
npm install
64+
```
65+
66+
---
67+
68+
## 3. Install backend dependencies
69+
70+
Open a second terminal:
71+
72+
```bash
73+
cd backend
74+
npm install
75+
```
76+
77+
---
78+
79+
# Running the Application
80+
81+
## Start the backend server
82+
83+
Inside `backend/`:
84+
85+
```bash
86+
node server.js
87+
```
88+
89+
The backend runs on:
90+
91+
```txt
92+
http://localhost:3000
93+
```
94+
95+
---
96+
97+
## Start the frontend
98+
99+
Inside `frontend/`:
100+
101+
```bash
102+
npm run dev
103+
```
104+
105+
The frontend runs on:
106+
107+
```txt
108+
http://localhost:5173
109+
```
110+
111+
---
112+
113+
# API Endpoints
114+
115+
## GET /messages
116+
117+
Returns all chat messages.
118+
119+
Example response:
120+
121+
```json
122+
[
123+
{
124+
"id": 1,
125+
"username": "System",
126+
"text": "Welcome!",
127+
"createdAt": "2026-05-21T20:00:00.000Z"
128+
}
129+
]
130+
```
131+
132+
---
133+
134+
## POST /messages
135+
136+
Creates a new message.
137+
138+
Example request body:
139+
140+
```json
141+
{
142+
"username": "ABC",
143+
"text": "Hello everyone"
144+
}
145+
```
146+
147+
---
148+
149+
# Deployment
150+
151+
## Frontend Deployment
152+
Deploy using:
153+
- Coolify
154+
155+
## Backend Deployment
156+
Deploy using:
157+
- Coolify
158+
159+
---
160+
161+
# Future Improvements
162+
163+
- Authentication
164+
- Database storage
165+
- WebSockets for real-time updates
166+
- Message editing/deleting
167+
- Improved styling
168+
169+
---
170+
171+
# Author
172+
173+
**Trang Do Thuy** - Created as part of the CodeYourFuture coursework.

chat-app/backend/server.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,42 @@ const app = express();
66
app.use(cors());
77
app.use(express.json());
88

9+
let messages = [
10+
{
11+
id: 1,
12+
username: "System",
13+
text: "Welcome to the server chat",
14+
createdAt: new Date().toISOString(),
15+
},
16+
];
17+
18+
app.get("/messages", (req, res) => {
19+
res.json(messages);
20+
});
21+
22+
app.post("/messages", (req, res) => {
23+
const { username, text } = req.body;
24+
25+
if (!username || !text) {
26+
return res.status(400).json({
27+
error: "Username and text are required",
28+
});
29+
}
30+
31+
const newMessage = {
32+
id: Date.now(),
33+
username,
34+
text,
35+
createdAt: new Date().toISOString(),
36+
};
37+
38+
console.log(newMessage)
39+
40+
messages.push(newMessage);
41+
42+
res.status(201).json(newMessage);
43+
});
44+
945
app.get("/health", (req, res) => {
1046
res.json({ status: "ok" });
1147
});

0 commit comments

Comments
 (0)