Skip to content

Commit b99be44

Browse files
authored
Merge pull request #24 from Unity-Lab-AI/codex/refactor-project-directory-for-cleanliness
Refactor project layout and organize scripts
2 parents 732d065 + 747aed2 commit b99be44

18 files changed

Lines changed: 143 additions & 232 deletions

README.md

Lines changed: 2 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,4 @@
1-
# Unity Chat\n\n[![Deploy GitHub Pages](https://github.com/Unity-Lab-AI/Chat/actions/workflows/deploy-pages.yml/badge.svg)](https://github.com/Unity-Lab-AI/Chat/actions/workflows/deploy-pages.yml)\n\n## Environment Setup
1+
# Unity Chat
22

3-
Configure a `POLLINATIONS_TOKEN` secret in the repository settings.
4-
The deployment injects this value into `window.POLLINATIONS_TOKEN`,
5-
so the static site can access it directly without local files or storage.
3+
See [docs/README.md](docs/README.md) for project documentation.
64

7-
Here's a comprehensive breakdown of your web app's functionality based on the provided files:
8-
9-
---
10-
11-
## **General Overview**
12-
13-
Your web application, titled **"Unity Chat U1 6.6"**, provides an interactive chat interface integrating multiple sophisticated features to enhance user interaction with AI models, manage conversations, personalize experiences, and dynamically handle multimedia elements like voice synthesis, speech recognition, and automated image generation via Pollinations.
14-
15-
---
16-
17-
## **Core Features**
18-
19-
### **1. Chat Interface**
20-
- **Real-time Conversations:**
21-
Allows users to communicate with AI-powered models, facilitating dynamic, real-time interactions.
22-
23-
- **Speech Integration:**
24-
- **Speech Synthesis:** Converts AI responses into spoken audio with selectable voice preferences (`Google UK English Female`, `Microsoft Zira`, etc.).
25-
- **Speech Recognition:** Users can dictate messages through voice input, which captures speech and translates it into textual inputs in real-time.
26-
27-
- **Message Handling:**
28-
- **Markdown Support:** AI-generated responses utilize Markdown, enhanced with syntax highlighting (via PrismJS) for clarity in code snippets.
29-
- **Image Embedding:** Automatically embeds images generated by Pollinations based on AI conversation content.
30-
- **Editing and Regeneration:** Users can edit their messages or regenerate AI responses conveniently from within the chat interface.
31-
32-
- **Session Management:**
33-
- **Dynamic Session Handling:** Users can create, rename, delete, and switch between multiple chat sessions, each independently maintaining its conversation history.
34-
- **Automatic Title Generation:** Sessions automatically generate concise titles based on initial exchanges for easier identification.
35-
36-
### **2. Personalization & Memory**
37-
- **Memory Management:**
38-
- Integration with `memory-api.js` provides persistent memory storage, allowing users to store, manage, edit, and delete memories within the interface.
39-
- Prevents duplicate entries, ensuring organized memory storage.
40-
41-
- **Personalization Options:**
42-
- Users can specify their name, interests, preferred AI behaviors, and additional information. These details are stored locally and leveraged by the AI to tailor responses uniquely to the user's profile.
43-
44-
### **3. Screensaver Module**
45-
- An integrated dynamic screensaver feature powered by Pollinations, capable of generating visually appealing images based on user-defined prompts.
46-
- Users have control over settings:
47-
- **Prompt:** Textual descriptions to generate specific imagery.
48-
- **Aspect Ratios:** Supports widescreen, square, and portrait modes.
49-
- **Timing Control:** Interval customization for image rotation.
50-
- **Privacy Options:** Controls image visibility on public feeds.
51-
52-
- Provides direct download, save, and copy-to-clipboard functionalities for displayed screensaver images.
53-
54-
### **4. Backend Server**
55-
- **Express Server (`server.js`):**
56-
- Provides APIs for:
57-
- **User Registration:** Registers and tracks unique user IDs, storing them persistently (`userData.json`).
58-
- **Visitor Counting:** Returns real-time visitor statistics.
59-
60-
- **Ubuntu Deployment Guide:**
61-
- Comprehensive server setup instructions (`Server setup.txt`), guiding deployment using Node.js, npm, PM2 (for process management), firewall setup (`ufw`), and optional reverse proxy configurations via Nginx/Apache.
62-
63-
### **5. Storage & Persistence (`storage.js`)**
64-
- Manages session data, memory entries, and user personalization details locally (`localStorage`), ensuring persistent state across user sessions.
65-
- Implements fallback mechanisms in case server-side persistence is unavailable, ensuring robustness and offline capability.
66-
67-
### **6. UI & Themes**
68-
- **Customizable UI:**
69-
- Employs Bootstrap 5, custom stylesheets (`styles.css` and `light.css`), and Font Awesome for iconography.
70-
- Supports dynamic theme switching (e.g., light, dark, hacker, etc.), catering to varied user aesthetics and readability preferences.
71-
72-
- **Responsive Design:**
73-
- Ensures usability across various screen sizes (mobile, tablet, desktop), maintaining optimal user experience irrespective of device.
74-
75-
### **7. Utilities & Enhancements**
76-
- **Clipboard Functionality:**
77-
Allows easy copying of cryptocurrency addresses, images, and text snippets directly from the interface.
78-
79-
- **Donation Integration:**
80-
- Direct integration of donation mechanisms supporting cryptocurrencies like BTC, ETH, DOGE, and XMR, accessible through intuitive modals.
81-
82-
- **Visitor Counter:**
83-
- Displays a live count of unique visitors through periodic server API polling, defaulting gracefully in case of network issues.
84-
85-
- **Error Handling & Notifications:**
86-
- User-friendly toast notifications (`showToast`) provide real-time feedback on interactions like successful copying, memory updates, errors, etc.
87-
88-
---
89-
90-
## **Technical Stack & Dependencies**
91-
- **Frontend:** HTML, CSS, JavaScript, Bootstrap 5, Font Awesome, PrismJS, Marked.js
92-
- **Backend:** Node.js (Express), cors, fs for file operations
93-
- **Speech & Multimedia:** Web Speech API for speech synthesis and recognition
94-
- **Persistent Storage:** Local Storage and server-side JSON file storage (`userData.json`)
95-
- **Deployment Tools:** Ubuntu server, Node.js, npm, PM2 for daemonization, ufw firewall configurations
96-
97-
---
98-
99-
## **Usage Workflow**
100-
101-
- **Launching:**
102-
- User connects via the web interface hosted on the Node.js Express server.
103-
- Automatic unique ID generation and session initialization occur upon first load.
104-
105-
- **Interacting:**
106-
- Engage via text or voice, manage sessions, personalize AI interactions, and explore dynamically generated imagery.
107-
108-
- **Administration & Maintenance:**
109-
- Administer sessions, clear memory or chat history, configure UI preferences, monitor user statistics, and manage server through provided server scripts.
110-
111-
---
112-
113-
## **Security & Privacy**
114-
115-
- Persistent data is stored securely on local storage or server-side JSON files.
116-
- API endpoints (`/api/registerUser`, `/api/visitorCount`) include basic validation to ensure data integrity and minimize malicious usage.
117-
118-
---
119-
120-
## **Extensibility & Future Considerations**
121-
122-
- The modular architecture facilitates easy integration of additional AI models or APIs.
123-
- Potential expansions might include enhanced security measures, comprehensive backend database integration, more complex personalization features, or further multimedia interactions.
124-
125-
---
126-
127-
This detailed breakdown encapsulates your application's extensive functionality, highlighting a robust and user-centric design that seamlessly integrates advanced AI interactions with user experience enhancements, comprehensive storage, personalization, multimedia features, and robust backend capabilities.

Server setup.txt

Lines changed: 0 additions & 93 deletions
This file was deleted.
File renamed without changes.

docs/README.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Unity Chat\n\n[![Deploy GitHub Pages](https://github.com/Unity-Lab-AI/Chat/actions/workflows/deploy-pages.yml/badge.svg)](https://github.com/Unity-Lab-AI/Chat/actions/workflows/deploy-pages.yml)\n\n## Environment Setup
2+
3+
Configure a `POLLINATIONS_TOKEN` secret in the repository settings.
4+
The deployment injects this value into `window.POLLINATIONS_TOKEN`,
5+
so the static site can access it directly without local files or storage.
6+
7+
Here's a comprehensive breakdown of your web app's functionality based on the provided files:
8+
9+
---
10+
11+
## **General Overview**
12+
13+
Your web application, titled **"Unity Chat U1 6.6"**, provides an interactive chat interface integrating multiple sophisticated features to enhance user interaction with AI models, manage conversations, personalize experiences, and dynamically handle multimedia elements like voice synthesis, speech recognition, and automated image generation via Pollinations.
14+
15+
---
16+
17+
## **Core Features**
18+
19+
### **1. Chat Interface**
20+
- **Real-time Conversations:**
21+
Allows users to communicate with AI-powered models, facilitating dynamic, real-time interactions.
22+
23+
- **Speech Integration:**
24+
- **Speech Synthesis:** Converts AI responses into spoken audio with selectable voice preferences (`Google UK English Female`, `Microsoft Zira`, etc.).
25+
- **Speech Recognition:** Users can dictate messages through voice input, which captures speech and translates it into textual inputs in real-time.
26+
27+
- **Message Handling:**
28+
- **Markdown Support:** AI-generated responses utilize Markdown, enhanced with syntax highlighting (via PrismJS) for clarity in code snippets.
29+
- **Image Embedding:** Automatically embeds images generated by Pollinations based on AI conversation content.
30+
- **Editing and Regeneration:** Users can edit their messages or regenerate AI responses conveniently from within the chat interface.
31+
32+
- **Session Management:**
33+
- **Dynamic Session Handling:** Users can create, rename, delete, and switch between multiple chat sessions, each independently maintaining its conversation history.
34+
- **Automatic Title Generation:** Sessions automatically generate concise titles based on initial exchanges for easier identification.
35+
36+
### **2. Personalization & Memory**
37+
- **Memory Management:**
38+
- Integration with `../js/storage/memory-api.js` provides persistent memory storage, allowing users to store, manage, edit, and delete memories within the interface.
39+
- Prevents duplicate entries, ensuring organized memory storage.
40+
41+
- **Personalization Options:**
42+
- Users can specify their name, interests, preferred AI behaviors, and additional information. These details are stored locally and leveraged by the AI to tailor responses uniquely to the user's profile.
43+
44+
### **3. Screensaver Module**
45+
- An integrated dynamic screensaver feature powered by Pollinations, capable of generating visually appealing images based on user-defined prompts.
46+
- Users have control over settings:
47+
- **Prompt:** Textual descriptions to generate specific imagery.
48+
- **Aspect Ratios:** Supports widescreen, square, and portrait modes.
49+
- **Timing Control:** Interval customization for image rotation.
50+
- **Privacy Options:** Controls image visibility on public feeds.
51+
52+
- Provides direct download, save, and copy-to-clipboard functionalities for displayed screensaver images.
53+
54+
### **4. Backend Server**
55+
- **Express Server (`server.js`):**
56+
- Provides APIs for:
57+
- **User Registration:** Registers and tracks unique user IDs, storing them persistently (`userData.json`).
58+
- **Visitor Counting:** Returns real-time visitor statistics.
59+
60+
- **Ubuntu Deployment Guide:**
61+
- Comprehensive server setup instructions guiding deployment using Node.js, npm, PM2 (for process management), firewall setup (`ufw`), and optional reverse proxy configurations via Nginx/Apache.
62+
63+
### **5. Storage & Persistence (`../js/storage/storage.js`)**
64+
- Manages session data, memory entries, and user personalization details locally (`localStorage`), ensuring persistent state across user sessions.
65+
- Implements fallback mechanisms in case server-side persistence is unavailable, ensuring robustness and offline capability.
66+
67+
### **6. UI & Themes**
68+
- **Customizable UI:**
69+
- Employs Bootstrap 5, custom stylesheets (`../js/ui/styles.css` and `light.css`), and Font Awesome for iconography.
70+
- Supports dynamic theme switching (e.g., light, dark, hacker, etc.), catering to varied user aesthetics and readability preferences.
71+
72+
- **Responsive Design:**
73+
- Ensures usability across various screen sizes (mobile, tablet, desktop), maintaining optimal user experience irrespective of device.
74+
75+
### **7. Utilities & Enhancements**
76+
- **Clipboard Functionality:**
77+
Allows easy copying of cryptocurrency addresses, images, and text snippets directly from the interface.
78+
79+
- **Donation Integration:**
80+
- Direct integration of donation mechanisms supporting cryptocurrencies like BTC, ETH, DOGE, and XMR, accessible through intuitive modals.
81+
82+
- **Visitor Counter:**
83+
- Displays a live count of unique visitors through periodic server API polling, defaulting gracefully in case of network issues.
84+
85+
- **Error Handling & Notifications:**
86+
- User-friendly toast notifications (`showToast`) provide real-time feedback on interactions like successful copying, memory updates, errors, etc.
87+
88+
---
89+
90+
## **Technical Stack & Dependencies**
91+
- **Frontend:** HTML, CSS, JavaScript, Bootstrap 5, Font Awesome, PrismJS, Marked.js
92+
- **Backend:** Node.js (Express), cors, fs for file operations
93+
- **Speech & Multimedia:** Web Speech API for speech synthesis and recognition
94+
- **Persistent Storage:** Local Storage and server-side JSON file storage (`userData.json`)
95+
- **Deployment Tools:** Ubuntu server, Node.js, npm, PM2 for daemonization, ufw firewall configurations
96+
97+
---
98+
99+
## **Usage Workflow**
100+
101+
- **Launching:**
102+
- User connects via the web interface hosted on the Node.js Express server.
103+
- Automatic unique ID generation and session initialization occur upon first load.
104+
105+
- **Interacting:**
106+
- Engage via text or voice, manage sessions, personalize AI interactions, and explore dynamically generated imagery.
107+
108+
- **Administration & Maintenance:**
109+
- Administer sessions, clear memory or chat history, configure UI preferences, monitor user statistics, and manage server through provided server scripts.
110+
111+
---
112+
113+
## **Security & Privacy**
114+
115+
- Persistent data is stored securely on local storage or server-side JSON files.
116+
- API endpoints (`/api/registerUser`, `/api/visitorCount`) include basic validation to ensure data integrity and minimize malicious usage.
117+
118+
---
119+
120+
## **Extensibility & Future Considerations**
121+
122+
- The modular architecture facilitates easy integration of additional AI models or APIs.
123+
- Potential expansions might include enhanced security measures, comprehensive backend database integration, more complex personalization features, or further multimedia interactions.
124+
125+
---
126+
127+
This detailed breakdown encapsulates your application's extensive functionality, highlighting a robust and user-centric design that seamlessly integrates advanced AI interactions with user experience enhancements, comprehensive storage, personalization, multimedia features, and robust backend capabilities.

index.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
88
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
99
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css">
10-
<link rel="stylesheet" href="styles.css">
11-
<link rel="stylesheet" href="stylesScreensaver.css">
10+
<link rel="stylesheet" href="js/ui/styles.css">
11+
<link rel="stylesheet" href="js/ui/stylesScreensaver.css">
1212
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
1313
<script defer src="polliLib/polliLib-web.global.js"></script>
1414
<script defer>
@@ -457,20 +457,20 @@ <h3 class="modal-title">Voice Chat</h3>
457457
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-json.min.js" defer></script>
458458
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js" defer></script>
459459
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-markup.min.js" defer></script>
460-
<script defer src="screensaver.js"></script>
461-
<script defer src="storage.js"></script>
462-
<script defer src="memory-api.js"></script>
460+
<script defer src="js/ui/screensaver.js"></script>
461+
<script defer src="js/storage/storage.js"></script>
462+
<script defer src="js/storage/memory-api.js"></script>
463463

464464
<!-- chat-core FIRST so PolliLib's default client helpers are available -->
465-
<script defer src="chat-core.js"></script>
465+
<script defer src="js/chat/chat-core.js"></script>
466466

467467
<!-- UI now safely uses PolliLib's default client -->
468-
<script defer src="ui.js"></script>
468+
<script defer src="js/ui/ui.js"></script>
469469

470-
<script defer src="polli-utils.js"></script>
471-
<script defer src="chat-storage.js"></script>
472-
<script defer src="chat-init.js"></script>
473-
<script defer src="simple.js"></script>
470+
<script defer src="js/chat/polli-utils.js"></script>
471+
<script defer src="js/chat/chat-storage.js"></script>
472+
<script defer src="js/chat/chat-init.js"></script>
473+
<script defer src="js/ui/simple.js"></script>
474474
</body>
475475

476476
</html>

0 commit comments

Comments
 (0)