-
-
Notifications
You must be signed in to change notification settings - Fork 61
London | 226-SDC-Mar | Beko | Sprint 2 | Chat App both frontend and backend #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
74f2bd0
frontend chat app
Abubakar-Meigag 5fc6130
create the backend for the chat app
Abubakar-Meigag 55b4de4
connect frontend to server with REST and WebSocket
Abubakar-Meigag 23e2d57
add message count display as additional feature
Abubakar-Meigag a30ec08
Merge pull request #1 from Abubakar-Meigag/beko-chat-app
Abubakar-Meigag 0588a35
fix: update server and websocket URLs to deployed domain
Abubakar-Meigag 3652b22
Merge pull request #2 from Abubakar-Meigag/fix/server-url
Abubakar-Meigag d2b1e52
specify node engine version for deployment
Abubakar-Meigag 262eec3
Update README.md
Abubakar-Meigag 1837065
Create README.md for client with project details
Abubakar-Meigag 898444b
Create README.md for server documentation
Abubakar-Meigag 172f76b
update code review feedback
Abubakar-Meigag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,50 @@ | ||
| # Coursework | ||
|
|
||
| Exercises to practice and solidify your understanding of the Decomposition module of the Software Development Course. | ||
|
|
||
| --- | ||
|
|
||
| # Beeko Chat App | ||
|
|
||
| A real-time chat application where users can send and receive messages instantly without refreshing the page. | ||
|
|
||
| ## Project Structure | ||
|
|
||
| ``` | ||
| chat-app/ | ||
| client/ - Vite + React + TypeScript frontend | ||
| server/ - Node.js + Express backend | ||
| ``` | ||
|
|
||
| ## Features | ||
|
|
||
| - Send a message to the chat | ||
| - See all messages when opening the chat | ||
| - New messages appear instantly for all connected users | ||
| - Message count display | ||
| - Username persisted across sessions | ||
|
|
||
| ## How It Works | ||
|
|
||
| The frontend loads existing messages from the server on page load via a REST API. When a user sends a message, it is posted to the server which saves it and broadcasts it to all connected clients over a WebSocket channel. Every connected user receives the new message instantly without needing to refresh. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| **Backend** | ||
| ```bash | ||
| cd server | ||
| npm install | ||
| node index.js | ||
| ``` | ||
|
|
||
| **Frontend** | ||
| ```bash | ||
| cd client | ||
| npm install | ||
| npm run dev | ||
| ``` | ||
|
|
||
| ## Deployment | ||
|
|
||
| - Backend is deployed as a Docker container | ||
| - Frontend is deployed as a static site via Nixpacks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
| lerna-debug.log* | ||
|
|
||
| node_modules | ||
| dist | ||
| dist-ssr | ||
| *.local | ||
|
|
||
| # Editor directories and files | ||
| .vscode/* | ||
| !.vscode/extensions.json | ||
| .idea | ||
| .DS_Store | ||
| *.suo | ||
| *.ntvs* | ||
| *.njsproj | ||
| *.sln | ||
| *.sw? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # Frontend (`client/`) | ||
|
|
||
| Built with **Vite + React + TypeScript** | ||
|
|
||
| ## Technologies | ||
|
|
||
| - **Vite** - build tool and dev server | ||
| - **React 19** - UI library | ||
| - **TypeScript** - type safety across all components | ||
|
|
||
| ## Structure | ||
|
|
||
| ``` | ||
| src/ | ||
| types.ts - shared Message interface | ||
| App.tsx / App.css - root component, state, API calls | ||
| components/ | ||
| MessageList.tsx / .css - scrollable list of messages | ||
| MessageForm.tsx / .css - name input, message textarea, send button | ||
| ``` | ||
|
|
||
| ## Implementation | ||
|
|
||
| `types.ts` | ||
|
|
||
| - Defines the `Message` interface with `id`, `name`, `text`, and `timestamp` | ||
|
|
||
| `App.tsx` | ||
|
|
||
| - Fetches all messages from `GET /messages` on page load | ||
| - Opens a WebSocket connection to listen for new messages in real time | ||
| - Persists the username in `localStorage` so it survives page refresh | ||
| - Passes `handleSend` down to `MessageForm` which calls `POST /messages` | ||
|
|
||
| `MessageList.tsx` | ||
|
|
||
| - Receives messages as props and renders each one with name, timestamp, and text | ||
| - Auto-scrolls to the latest message using a `ref` on the bottom of the list | ||
|
|
||
| `MessageForm.tsx` | ||
|
|
||
| - Controlled inputs for name and message | ||
| - Name is remembered between sessions, message clears after sending | ||
| - Send button is disabled if either field is empty | ||
| - Displays total message count as an additional feature | ||
|
|
||
| ## What I Learned | ||
|
|
||
| Building this project showed how the frontend and backend need a clear contract to work together, the REST endpoints handle loading and sending data, while WebSocket handles the real-time layer, and understanding when to use each was the key challenge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <link rel="stylesheet" href="/src/App.css" /> | ||
| <title>Beeko Chat App</title> | ||
| </head> | ||
| <body> | ||
| <div id="app"></div> | ||
| <script type="module" src="/src/main.tsx"></script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the Validation Bot is not expecting this file to be modified. Can you do the following?
chat-app/README.mdUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the feedback comments are done, including this one. I moved the content and did revert the changes
Thanks you @cjyuan