Dhurgh commited on
Commit
3b52afd
·
1 Parent(s): 1b96d8b

docs(report): add final report draft, reproducibility guide, and GenAI disclosures

Browse files
Files changed (7) hide show
  1. FINAL-REPORT-W13.docx +0 -0
  2. FINAL-REPORT-W13.md +286 -0
  3. README.md +81 -0
  4. client.js +5 -0
  5. index.html +1 -0
  6. package.json +1 -1
  7. server.js +5 -0
FINAL-REPORT-W13.docx ADDED
Binary file (17.1 kB). View file
 
FINAL-REPORT-W13.md ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # FireTech Messager Server - Final Report and Design Document
2
+
3
+ Course deadline context: Week 13 (10 April)
4
+
5
+ Repository (public): https://github.com/dhurghamCreation/FireTech-Messager-Server
6
+ Live deployment target: https://firetech-messager-server.onrender.com
7
+
8
+ ---
9
+
10
+ ## Abstract
11
+
12
+ FireTech Messager Server is a real-time web chat application inspired by modern community chat platforms. The project provides authenticated user access, channel-based communication, direct messaging, profile editing, friend requests, a shop/inventory module, and responsive browser-based UI interactions. The backend uses Node.js, Express, Socket.IO, and Sequelize with PostgreSQL for persistence. The frontend is implemented with HTML, CSS, and vanilla JavaScript.
13
+
14
+ The main engineering objectives were:
15
+ - Deliver low-latency real-time messaging across clients.
16
+ - Keep account and message data persistent across restarts.
17
+ - Support deployment on cloud infrastructure and reproducible local/server execution.
18
+ - Provide a clean user interface across desktop/mobile form factors.
19
+
20
+ The delivered system is reproducible on Ubuntu servers, Raspberry Pi devices, and Render cloud deployment (with PostgreSQL configured).
21
+
22
+ ---
23
+
24
+ ## Methodology
25
+
26
+ ### 1) Development Method
27
+
28
+ An iterative implementation approach was used:
29
+ 1. Build baseline chat server/client.
30
+ 2. Add authentication and user profile management.
31
+ 3. Add persistent storage and schema design.
32
+ 4. Add social and gamification features (friends/shop/inventory).
33
+ 5. Improve deployment, HTTPS, and reliability.
34
+ 6. Validate with functional and non-functional checks.
35
+
36
+ ### 2) Block Diagram
37
+
38
+ ```text
39
+ [ Browser Client (index.html + client.js) ]
40
+ | HTTPS + REST + Socket.IO
41
+ v
42
+ [ Node.js + Express + Socket.IO (server.js) ]
43
+ | Sequelize ORM
44
+ v
45
+ [ PostgreSQL Database ]
46
+
47
+ Optional cloud runtime:
48
+ [ Render Web Service ] ----> [ Render/Managed PostgreSQL ]
49
+ ```
50
+
51
+ ### 3) Functional Requirements (FRD)
52
+
53
+ Implemented FRs:
54
+ 1. User registration/login with token-based authentication.
55
+ 2. Real-time channel messaging with Socket.IO.
56
+ 3. Persistent user/account/message data in PostgreSQL.
57
+ 4. Profile read/update APIs.
58
+ 5. Friend requests and friend list management.
59
+ 6. Shop listing, purchase flow, and inventory tracking.
60
+ 7. Media-enabled messaging support fields and upload handling.
61
+ 8. Deployment support for cloud hosting (Render) and local/server installs.
62
+
63
+ Partially met FRs:
64
+ 1. Voice/video calling support is scaffolded but full production-grade voice rooms are not fully complete end-to-end.
65
+ 2. Some advanced moderation/admin controls are limited.
66
+
67
+ Not fully met FRs:
68
+ 1. Advanced role-permission hierarchy per channel/server.
69
+ 2. Full message reaction/threading/search system.
70
+
71
+ ### 4) Non-Functional Requirements (NFR)
72
+
73
+ Implemented NFRs:
74
+ 1. Security: password hashing (bcrypt), token auth (JWT), environment variable secrets.
75
+ 2. Availability: startup retry for transient PostgreSQL connectivity failures.
76
+ 3. Performance: event-based real-time architecture with Socket.IO.
77
+ 4. Portability: runs on Windows, Ubuntu, Raspberry Pi, and Render cloud.
78
+ 5. Maintainability: modular endpoint/event structure and project documentation.
79
+
80
+ Partially met NFRs:
81
+ 1. Scalability: current design is suitable for small-medium loads; horizontal scaling strategy is not fully implemented.
82
+ 2. Observability: logs exist, but centralized monitoring/alerting is limited.
83
+
84
+ Not fully met NFRs:
85
+ 1. Automated integration/performance test suite coverage.
86
+ 2. Full CI/CD quality gates and load testing pipeline.
87
+
88
+ ---
89
+
90
+ ## Implementation
91
+
92
+ ### 1) Tools and Technology Stack
93
+
94
+ Backend:
95
+ - Node.js
96
+ - Express.js
97
+ - Socket.IO
98
+ - Sequelize ORM
99
+ - PostgreSQL
100
+ - bcryptjs, jsonwebtoken, multer, cors, dotenv
101
+
102
+ Frontend:
103
+ - HTML5
104
+ - CSS3
105
+ - Vanilla JavaScript
106
+ - Font Awesome icons
107
+
108
+ DevOps/Deployment:
109
+ - GitHub (version control/public repository)
110
+ - Render (web service deployment)
111
+ - render.yaml infrastructure blueprint
112
+
113
+ ### 2) Core Implementation Details
114
+
115
+ Authentication and security:
116
+ - Registration/login endpoints.
117
+ - Password hashing with bcrypt.
118
+ - JWT token generation and middleware verification.
119
+
120
+ Persistence and data model:
121
+ - Sequelize models include User, Channel, Message, ShopItem, Inventory, FriendRequest, DirectMessage.
122
+ - PostgreSQL connection via DATABASE_URL.
123
+ - Production check blocks startup when DATABASE_URL is missing.
124
+ - Retry mechanism handles transient DB startup errors.
125
+
126
+ Real-time system:
127
+ - Socket.IO for online presence, room membership, message delivery, and typing/member updates.
128
+
129
+ Deployment readiness:
130
+ - Dynamic port support via process.env.PORT.
131
+ - Render blueprint includes health check and DB binding options.
132
+ - Linux reproducibility steps added in README.
133
+
134
+ ### 3) Reproducibility Evidence (Ubuntu / Raspberry Pi)
135
+
136
+ From README reproducibility section:
137
+ 1. Install apt packages (Node dependencies + PostgreSQL).
138
+ 2. Clone public repo.
139
+ 3. Create PostgreSQL user/database.
140
+ 4. Configure .env with DATABASE_URL/JWT_SECRET.
141
+ 5. npm install + npm start.
142
+ 6. Validate `/api/version` endpoint.
143
+
144
+ This workflow supports both Ubuntu server and Raspberry Pi OS (Debian-based).
145
+
146
+ ### 4) Front Layout Figures/Screenshots (Required)
147
+
148
+ Insert these screenshots in the final Word report:
149
+ 1. Figure 1 - Login/Register page.
150
+ 2. Figure 2 - Main chat interface with channel list.
151
+ 3. Figure 3 - Friends modal.
152
+ 4. Figure 4 - Shop modal and inventory.
153
+ 5. Figure 5 - Mobile responsive view.
154
+ 6. Figure 6 - Render deployment live status/logs.
155
+
156
+ Suggested caption style: "Figure X. <Short description>"
157
+
158
+ ---
159
+
160
+ ## Team Participation and Management
161
+
162
+ Use this section for team-shared report part.
163
+
164
+ ### 1) Team Roles and Participation
165
+
166
+ Replace with your actual team details:
167
+
168
+ | Member | Role | Main Contributions |
169
+ |---|---|---|
170
+ | Member A | Backend Lead | API endpoints, DB schema, deployment fixes |
171
+ | Member B | Frontend Lead | UI screens, responsive layout, client logic |
172
+ | Member C | QA/Docs | Testing, README/report, screenshot preparation |
173
+
174
+ ### 2) Project Management Approach
175
+
176
+ - Used a requirement-driven approach with FR/NFR checkpoints.
177
+ - Split work into backend, frontend, deployment, and validation tasks.
178
+ - Conducted periodic merge/review updates through GitHub commits.
179
+
180
+ ### 3) Meetings and Progress Tracking (last two weeks)
181
+
182
+ Document your exact tools and cadence (example):
183
+ - Communication: WhatsApp/Discord/Telegram.
184
+ - Task tracking: GitHub Issues + shared checklist.
185
+ - Meeting schedule: 3 short sync meetings per week + daily chat updates.
186
+ - Progress evidence: commit timeline and feature completion log.
187
+
188
+ ### 4) FRDs Not Met
189
+
190
+ - Full production-grade voice/video calls with robust TURN enforcement and complete UX controls.
191
+ - Advanced threaded conversations and reactions.
192
+
193
+ ### 5) NFRs Not Met
194
+
195
+ - Comprehensive automated test coverage for all API/socket flows.
196
+ - Full observability stack (metrics dashboards, alerting, tracing).
197
+
198
+ ### 6) How the Application Was Improved
199
+
200
+ - Added production-safe DATABASE_URL validation.
201
+ - Added DB startup retry logic for transient network resets.
202
+ - Added Render deployment blueprint improvements.
203
+ - Added Ubuntu/Raspberry Pi reproducibility instructions.
204
+ - Added in-code GenAI usage disclosure comments.
205
+
206
+ ---
207
+
208
+ ## Reflection (Individual - must differ per member)
209
+
210
+ Important: this section must be written separately by each team member in their own words.
211
+
212
+ ### Template for Each Member
213
+
214
+ 1. Learning experience and self-learning:
215
+ - What technical concepts were learned (real-time events, auth, DB design, deployment).
216
+ - What was learned independently and how.
217
+
218
+ 2. How GenAI was used:
219
+ - Mention specific coding tasks where GenAI helped (scaffolding, debugging, refactoring, deployment fixes).
220
+ - Mention that report writing itself was done by the student, not GenAI, per course policy.
221
+
222
+ 3. How GenAI helped self-learning:
223
+ - Faster explanation of unfamiliar errors.
224
+ - Alternative implementation options.
225
+ - Clarifying architecture trade-offs.
226
+
227
+ 4. Where GenAI was not helpful:
228
+ - Cases where generated code was outdated/inaccurate for this codebase.
229
+ - Required manual verification from official docs, peers, or Stack Overflow.
230
+
231
+ 5. Previous programming experience:
232
+ - Describe prior exposure to JS/Node/web apps/databases.
233
+
234
+ 6. Why tools were chosen:
235
+ - Node/Express/Socket.IO for rapid real-time web app development.
236
+ - PostgreSQL + Sequelize for structured persistence.
237
+ - Render for simple deployment workflow.
238
+ - Mention whether choices came from self-learning, online docs, or GenAI suggestions.
239
+
240
+ ---
241
+
242
+ ## GenAI Compliance Statement
243
+
244
+ GenAI was used for selected coding support tasks only. Disclosures were added directly in code comments in:
245
+ - server.js
246
+ - client.js
247
+ - index.html
248
+
249
+ Each disclosure includes prompt summaries used to generate or improve those sections.
250
+
251
+ No claim is made that GenAI authored final report reflection content; each team member must provide an individual reflection.
252
+
253
+ ---
254
+
255
+ ## Submission Checklist
256
+
257
+ 1. Public GitHub repository link included.
258
+ 2. Reproducible Ubuntu/Raspberry Pi setup instructions included.
259
+ 3. Design and implementation details included.
260
+ 4. FR/NFR met and unmet points included.
261
+ 5. Team management/process section included.
262
+ 6. Individual reflection section prepared separately per member.
263
+ 7. Front layout screenshots inserted with captions.
264
+ 8. GenAI usage disclosures added in code comments.
265
+
266
+ ---
267
+
268
+ ## Appendix A - Key Runtime Variables
269
+
270
+ - PORT
271
+ - HOST
272
+ - NODE_ENV
273
+ - DATABASE_URL
274
+ - JWT_SECRET
275
+ - CORS_ORIGIN
276
+ - TURN_URLS (optional)
277
+ - TURN_USERNAME (optional)
278
+ - TURN_CREDENTIAL (optional)
279
+
280
+ ## Appendix B - Key Verification Endpoints
281
+
282
+ - GET /api/version
283
+ - POST /api/register
284
+ - POST /api/login
285
+ - GET /api/profile/:userId
286
+ - GET /api/rtc-config
README.md CHANGED
@@ -34,6 +34,7 @@ A modern, feature-rich real-time chat application built with Socket.IO, Express,
34
  ### Prerequisites
35
  - Node.js (v14 or higher)
36
  - npm or yarn
 
37
 
38
  ### Installation
39
 
@@ -62,6 +63,77 @@ npm run dev
62
  http://localhost:3000
63
  ```
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  ### Quick HTTPS Setup for LAN Access (Windows)
66
 
67
  Run this **one command** in PowerShell to set up HTTPS with automatic certificate generation and firewall configuration:
@@ -402,6 +474,15 @@ This project is open source and available for personal and commercial use.
402
 
403
  Created by Dhurgham Alsaadi using modern web technologies.
404
 
 
 
 
 
 
 
 
 
 
405
  ---
406
 
407
  **Enjoy chatting!**
 
34
  ### Prerequisites
35
  - Node.js (v14 or higher)
36
  - npm or yarn
37
+ - PostgreSQL (local) or managed PostgreSQL (Render/Railway/Neon/Supabase)
38
 
39
  ### Installation
40
 
 
63
  http://localhost:3000
64
  ```
65
 
66
+ ## Reproducible Setup (Ubuntu Server / Raspberry Pi)
67
+
68
+ This section is intended for assignment reproducibility requirements.
69
+
70
+ ### 1) Install system packages
71
+
72
+ ```bash
73
+ sudo apt update
74
+ sudo apt install -y curl git ca-certificates postgresql postgresql-contrib
75
+ ```
76
+
77
+ ### 2) Install Node.js LTS
78
+
79
+ ```bash
80
+ curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
81
+ sudo apt install -y nodejs
82
+ node -v
83
+ npm -v
84
+ ```
85
+
86
+ ### 3) Clone repository
87
+
88
+ ```bash
89
+ git clone https://github.com/dhurghamCreation/FireTech-Messager-Server.git
90
+ cd FireTech-Messager-Server
91
+ ```
92
+
93
+ ### 4) Create PostgreSQL database/user
94
+
95
+ ```bash
96
+ sudo -u postgres psql -c "CREATE USER firetech WITH PASSWORD 'change_this_password';"
97
+ sudo -u postgres psql -c "CREATE DATABASE firetech_db OWNER firetech;"
98
+ ```
99
+
100
+ ### 5) Configure environment variables
101
+
102
+ Create `.env`:
103
+
104
+ ```env
105
+ PORT=3000
106
+ HOST=0.0.0.0
107
+ NODE_ENV=production
108
+ DATABASE_URL=postgres://firetech:change_this_password@localhost:5432/firetech_db
109
+ JWT_SECRET=replace_with_long_random_secret
110
+ CORS_ORIGIN=*
111
+ ```
112
+
113
+ ### 6) Install dependencies and run
114
+
115
+ ```bash
116
+ npm install
117
+ npm start
118
+ ```
119
+
120
+ ### 7) Verify service is running
121
+
122
+ ```bash
123
+ curl http://localhost:3000/api/version
124
+ ```
125
+
126
+ Expected output includes the app version as JSON.
127
+
128
+ ### 8) (Optional) Run with PM2 for persistence
129
+
130
+ ```bash
131
+ sudo npm install -g pm2
132
+ pm2 start server.js --name firetech-chat
133
+ pm2 save
134
+ pm2 startup
135
+ ```
136
+
137
  ### Quick HTTPS Setup for LAN Access (Windows)
138
 
139
  Run this **one command** in PowerShell to set up HTTPS with automatic certificate generation and firewall configuration:
 
474
 
475
  Created by Dhurgham Alsaadi using modern web technologies.
476
 
477
+ ## GenAI Usage Disclosure
478
+
479
+ GenAI assistance was used for selected coding tasks. In-code disclosure comments are included in:
480
+ - `server.js`
481
+ - `client.js`
482
+ - `index.html`
483
+
484
+ Prompt summaries used are documented in those file comments as required.
485
+
486
  ---
487
 
488
  **Enjoy chatting!**
client.js CHANGED
@@ -1,4 +1,9 @@
1
  let socket;
 
 
 
 
 
2
  let currentUser = null;
3
  let currentToken = null;
4
 
 
1
  let socket;
2
+ // GenAI disclosure: Parts of this frontend logic were generated/improved with GenAI assistance.
3
+ // Main prompts used:
4
+ // 1) "Create a Discord-like real-time chat frontend with Socket.IO, auth flow, channel list, and responsive UI behavior."
5
+ // 2) "Add profile, friends, and shop modal interactions with clean state updates and error handling."
6
+ // 3) "Add internationalized UI dictionaries and live language switching for common labels and settings."
7
  let currentUser = null;
8
  let currentToken = null;
9
 
index.html CHANGED
@@ -1,4 +1,5 @@
1
  <!DOCTYPE html>
 
2
  <html lang="en">
3
  <head>
4
  <meta charset="UTF-8">
 
1
  <!DOCTYPE html>
2
+ <!-- GenAI disclosure: parts of this UI structure and styling were created/refined with GenAI prompts for responsive layout, accessibility, and Discord-like interaction design. -->
3
  <html lang="en">
4
  <head>
5
  <meta charset="UTF-8">
package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "discord-like-app",
3
- "version": "3.2.12",
4
  "main": "server.js",
5
  "scripts": {
6
  "dev": "nodemon server.js",
 
1
  {
2
  "name": "discord-like-app",
3
+ "version": "3.2.13",
4
  "main": "server.js",
5
  "scripts": {
6
  "dev": "nodemon server.js",
server.js CHANGED
@@ -1,4 +1,9 @@
1
  const express = require('express');
 
 
 
 
 
2
  const fs = require('fs');
3
  const os = require('os');
4
  const path = require('path');
 
1
  const express = require('express');
2
+ // GenAI disclosure: Parts of this backend were developed/refined with GenAI assistance.
3
+ // Main prompts used:
4
+ // 1) "Build a Node.js + Express + Socket.IO chat backend with JWT auth, profile APIs, friends, shop items, and PostgreSQL models using Sequelize."
5
+ // 2) "Add Render deployment compatibility: dynamic PORT, production DATABASE_URL checks, and secure SSL options for managed Postgres."
6
+ // 3) "Improve reliability by retrying database connection/sync on transient ECONNRESET/ECONNREFUSED startup failures."
7
  const fs = require('fs');
8
  const os = require('os');
9
  const path = require('path');