create-featurebased-architecture 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -9
- package/dist/index.js +4 -2
- package/package.json +2 -2
- package/templates/ollama-chatbot-backend/.env.example +9 -0
- package/templates/ollama-chatbot-backend/README.md +132 -0
- package/templates/ollama-chatbot-backend/package.json +21 -0
- package/templates/ollama-chatbot-backend/src/config/database.ts +4 -0
- package/templates/ollama-chatbot-backend/src/config/env.ts +8 -0
- package/templates/ollama-chatbot-backend/src/config/index.ts +3 -0
- package/templates/ollama-chatbot-backend/src/config/ollama.ts +14 -0
- package/templates/ollama-chatbot-backend/src/features/chat/controller.ts +49 -0
- package/templates/ollama-chatbot-backend/src/features/chat/index.ts +5 -0
- package/templates/ollama-chatbot-backend/src/features/chat/routes.ts +7 -0
- package/templates/ollama-chatbot-backend/src/features/chat/schema.ts +13 -0
- package/templates/ollama-chatbot-backend/src/features/chat/service.ts +91 -0
- package/templates/ollama-chatbot-backend/src/features/chat/types.ts +22 -0
- package/templates/ollama-chatbot-backend/src/features/conversations/controller.ts +114 -0
- package/templates/ollama-chatbot-backend/src/features/conversations/index.ts +6 -0
- package/templates/ollama-chatbot-backend/src/features/conversations/repository.ts +61 -0
- package/templates/ollama-chatbot-backend/src/features/conversations/routes.ts +11 -0
- package/templates/ollama-chatbot-backend/src/features/conversations/schema.ts +9 -0
- package/templates/ollama-chatbot-backend/src/features/conversations/service.ts +28 -0
- package/templates/ollama-chatbot-backend/src/features/conversations/types.ts +23 -0
- package/templates/ollama-chatbot-backend/src/index.ts +22 -0
- package/templates/ollama-chatbot-backend/src/routes/index.ts +10 -0
- package/templates/ollama-chatbot-backend/src/shared/index.ts +2 -0
- package/templates/ollama-chatbot-backend/src/shared/types/index.ts +16 -0
- package/templates/ollama-chatbot-backend/src/shared/utils/index.ts +1 -0
- package/templates/ollama-chatbot-backend/src/shared/utils/response.ts +10 -0
- package/templates/ollama-chatbot-backend/tsconfig.json +22 -0
- package/templates/ollama-chatbot-frontend/.env.example +1 -0
- package/templates/ollama-chatbot-frontend/README.md +65 -0
- package/templates/ollama-chatbot-frontend/index.html +12 -0
- package/templates/ollama-chatbot-frontend/package.json +23 -0
- package/templates/ollama-chatbot-frontend/src/App.tsx +17 -0
- package/templates/ollama-chatbot-frontend/src/config/env.ts +1 -0
- package/templates/ollama-chatbot-frontend/src/config/index.ts +1 -0
- package/templates/ollama-chatbot-frontend/src/features/chat/components/ChatPage.tsx +94 -0
- package/templates/ollama-chatbot-frontend/src/features/chat/components/index.ts +1 -0
- package/templates/ollama-chatbot-frontend/src/features/chat/hooks/index.ts +1 -0
- package/templates/ollama-chatbot-frontend/src/features/chat/hooks/useChat.ts +149 -0
- package/templates/ollama-chatbot-frontend/src/features/chat/index.ts +4 -0
- package/templates/ollama-chatbot-frontend/src/features/chat/services/chatService.ts +81 -0
- package/templates/ollama-chatbot-frontend/src/features/chat/services/index.ts +1 -0
- package/templates/ollama-chatbot-frontend/src/features/chat/types.ts +33 -0
- package/templates/ollama-chatbot-frontend/src/index.css +281 -0
- package/templates/ollama-chatbot-frontend/src/main.tsx +13 -0
- package/templates/ollama-chatbot-frontend/src/shared/components/Sidebar.tsx +56 -0
- package/templates/ollama-chatbot-frontend/src/shared/components/index.ts +1 -0
- package/templates/ollama-chatbot-frontend/tsconfig.json +27 -0
- package/templates/ollama-chatbot-frontend/tsconfig.node.json +11 -0
- package/templates/ollama-chatbot-frontend/vite.config.ts +12 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
* {
|
|
2
|
+
margin: 0;
|
|
3
|
+
padding: 0;
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:root {
|
|
8
|
+
--bg-primary: #1a1a2e;
|
|
9
|
+
--bg-secondary: #16213e;
|
|
10
|
+
--bg-tertiary: #0f3460;
|
|
11
|
+
--text-primary: #eaeaea;
|
|
12
|
+
--text-secondary: #a0a0a0;
|
|
13
|
+
--accent: #e94560;
|
|
14
|
+
--accent-hover: #ff6b6b;
|
|
15
|
+
--user-bubble: #0f3460;
|
|
16
|
+
--assistant-bubble: #16213e;
|
|
17
|
+
--border: #2a2a4a;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
body {
|
|
21
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
22
|
+
background: var(--bg-primary);
|
|
23
|
+
color: var(--text-primary);
|
|
24
|
+
line-height: 1.6;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.app-container {
|
|
28
|
+
display: flex;
|
|
29
|
+
height: 100vh;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.main-content {
|
|
33
|
+
flex: 1;
|
|
34
|
+
display: flex;
|
|
35
|
+
flex-direction: column;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/* Sidebar */
|
|
40
|
+
.sidebar {
|
|
41
|
+
width: 280px;
|
|
42
|
+
background: var(--bg-secondary);
|
|
43
|
+
border-right: 1px solid var(--border);
|
|
44
|
+
display: flex;
|
|
45
|
+
flex-direction: column;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.sidebar-header {
|
|
49
|
+
padding: 1rem;
|
|
50
|
+
border-bottom: 1px solid var(--border);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.new-chat-btn {
|
|
54
|
+
width: 100%;
|
|
55
|
+
padding: 0.75rem 1rem;
|
|
56
|
+
background: var(--accent);
|
|
57
|
+
color: white;
|
|
58
|
+
border: none;
|
|
59
|
+
border-radius: 8px;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
display: flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
gap: 0.5rem;
|
|
65
|
+
font-size: 0.9rem;
|
|
66
|
+
transition: background 0.2s;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.new-chat-btn:hover {
|
|
70
|
+
background: var(--accent-hover);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.conversations-list {
|
|
74
|
+
flex: 1;
|
|
75
|
+
overflow-y: auto;
|
|
76
|
+
padding: 0.5rem;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.conversation-item {
|
|
80
|
+
padding: 0.75rem 1rem;
|
|
81
|
+
border-radius: 8px;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
display: flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
gap: 0.5rem;
|
|
86
|
+
margin-bottom: 0.25rem;
|
|
87
|
+
transition: background 0.2s;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.conversation-item:hover,
|
|
91
|
+
.conversation-item.active {
|
|
92
|
+
background: var(--bg-tertiary);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.conversation-item .title {
|
|
96
|
+
flex: 1;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
text-overflow: ellipsis;
|
|
99
|
+
white-space: nowrap;
|
|
100
|
+
font-size: 0.9rem;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.conversation-item .delete-btn {
|
|
104
|
+
opacity: 0;
|
|
105
|
+
background: none;
|
|
106
|
+
border: none;
|
|
107
|
+
color: var(--text-secondary);
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
padding: 0.25rem;
|
|
110
|
+
transition: opacity 0.2s, color 0.2s;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.conversation-item:hover .delete-btn {
|
|
114
|
+
opacity: 1;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.conversation-item .delete-btn:hover {
|
|
118
|
+
color: var(--accent);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* Chat */
|
|
122
|
+
.chat-container {
|
|
123
|
+
flex: 1;
|
|
124
|
+
display: flex;
|
|
125
|
+
flex-direction: column;
|
|
126
|
+
max-width: 900px;
|
|
127
|
+
margin: 0 auto;
|
|
128
|
+
width: 100%;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.chat-messages {
|
|
132
|
+
flex: 1;
|
|
133
|
+
overflow-y: auto;
|
|
134
|
+
padding: 1.5rem;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.message {
|
|
138
|
+
display: flex;
|
|
139
|
+
gap: 1rem;
|
|
140
|
+
margin-bottom: 1.5rem;
|
|
141
|
+
max-width: 100%;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.message.user {
|
|
145
|
+
flex-direction: row-reverse;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.message-avatar {
|
|
149
|
+
width: 36px;
|
|
150
|
+
height: 36px;
|
|
151
|
+
border-radius: 50%;
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
justify-content: center;
|
|
155
|
+
flex-shrink: 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.message.user .message-avatar {
|
|
159
|
+
background: var(--accent);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.message.assistant .message-avatar {
|
|
163
|
+
background: var(--bg-tertiary);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.message-content {
|
|
167
|
+
max-width: 70%;
|
|
168
|
+
padding: 1rem 1.25rem;
|
|
169
|
+
border-radius: 16px;
|
|
170
|
+
line-height: 1.5;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.message.user .message-content {
|
|
174
|
+
background: var(--user-bubble);
|
|
175
|
+
border-bottom-right-radius: 4px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.message.assistant .message-content {
|
|
179
|
+
background: var(--assistant-bubble);
|
|
180
|
+
border-bottom-left-radius: 4px;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/* Input */
|
|
184
|
+
.chat-input-container {
|
|
185
|
+
padding: 1rem 1.5rem 1.5rem;
|
|
186
|
+
border-top: 1px solid var(--border);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.chat-input-wrapper {
|
|
190
|
+
display: flex;
|
|
191
|
+
gap: 0.75rem;
|
|
192
|
+
background: var(--bg-secondary);
|
|
193
|
+
border: 1px solid var(--border);
|
|
194
|
+
border-radius: 12px;
|
|
195
|
+
padding: 0.5rem;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.chat-input {
|
|
199
|
+
flex: 1;
|
|
200
|
+
background: none;
|
|
201
|
+
border: none;
|
|
202
|
+
color: var(--text-primary);
|
|
203
|
+
font-size: 1rem;
|
|
204
|
+
padding: 0.5rem;
|
|
205
|
+
resize: none;
|
|
206
|
+
outline: none;
|
|
207
|
+
font-family: inherit;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.chat-input::placeholder {
|
|
211
|
+
color: var(--text-secondary);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.send-btn {
|
|
215
|
+
background: var(--accent);
|
|
216
|
+
border: none;
|
|
217
|
+
border-radius: 8px;
|
|
218
|
+
color: white;
|
|
219
|
+
width: 40px;
|
|
220
|
+
height: 40px;
|
|
221
|
+
display: flex;
|
|
222
|
+
align-items: center;
|
|
223
|
+
justify-content: center;
|
|
224
|
+
cursor: pointer;
|
|
225
|
+
transition: background 0.2s;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.send-btn:hover:not(:disabled) {
|
|
229
|
+
background: var(--accent-hover);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.send-btn:disabled {
|
|
233
|
+
opacity: 0.5;
|
|
234
|
+
cursor: not-allowed;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/* Loading */
|
|
238
|
+
.typing-indicator {
|
|
239
|
+
display: flex;
|
|
240
|
+
gap: 0.3rem;
|
|
241
|
+
padding: 0.5rem;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.typing-indicator span {
|
|
245
|
+
width: 8px;
|
|
246
|
+
height: 8px;
|
|
247
|
+
background: var(--text-secondary);
|
|
248
|
+
border-radius: 50%;
|
|
249
|
+
animation: bounce 1.4s infinite ease-in-out both;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
|
|
253
|
+
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
|
|
254
|
+
|
|
255
|
+
@keyframes bounce {
|
|
256
|
+
0%, 80%, 100% { transform: scale(0); }
|
|
257
|
+
40% { transform: scale(1); }
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/* Empty state */
|
|
261
|
+
.empty-state {
|
|
262
|
+
display: flex;
|
|
263
|
+
flex-direction: column;
|
|
264
|
+
align-items: center;
|
|
265
|
+
justify-content: center;
|
|
266
|
+
height: 100%;
|
|
267
|
+
color: var(--text-secondary);
|
|
268
|
+
text-align: center;
|
|
269
|
+
padding: 2rem;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.empty-state-icon {
|
|
273
|
+
font-size: 4rem;
|
|
274
|
+
margin-bottom: 1rem;
|
|
275
|
+
opacity: 0.5;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.empty-state h2 {
|
|
279
|
+
margin-bottom: 0.5rem;
|
|
280
|
+
color: var(--text-primary);
|
|
281
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom/client";
|
|
3
|
+
import { BrowserRouter } from "react-router-dom";
|
|
4
|
+
import { App } from "./App";
|
|
5
|
+
import "./index.css";
|
|
6
|
+
|
|
7
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
8
|
+
<React.StrictMode>
|
|
9
|
+
<BrowserRouter>
|
|
10
|
+
<App />
|
|
11
|
+
</BrowserRouter>
|
|
12
|
+
</React.StrictMode>
|
|
13
|
+
);
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useNavigate, useParams } from "react-router-dom";
|
|
2
|
+
import { IoAdd, IoTrash, IoChatbubbles } from "react-icons/io5";
|
|
3
|
+
import { useChat } from "../../features/chat/hooks/useChat";
|
|
4
|
+
|
|
5
|
+
export function Sidebar() {
|
|
6
|
+
const navigate = useNavigate();
|
|
7
|
+
const { conversationId } = useParams();
|
|
8
|
+
const { conversations, deleteConversation, startNewChat, loadMessages } = useChat();
|
|
9
|
+
|
|
10
|
+
const handleNewChat = () => {
|
|
11
|
+
startNewChat();
|
|
12
|
+
navigate("/");
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const handleSelectConversation = (id: string) => {
|
|
16
|
+
loadMessages(id);
|
|
17
|
+
navigate(`/chat/${id}`);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const handleDelete = (e: React.MouseEvent, id: string) => {
|
|
21
|
+
e.stopPropagation();
|
|
22
|
+
if (confirm("Delete this conversation?")) {
|
|
23
|
+
deleteConversation(id);
|
|
24
|
+
if (id === conversationId) {
|
|
25
|
+
navigate("/");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<aside className="sidebar">
|
|
32
|
+
<div className="sidebar-header">
|
|
33
|
+
<button className="new-chat-btn" onClick={handleNewChat}>
|
|
34
|
+
<IoAdd size={20} />
|
|
35
|
+
New Chat
|
|
36
|
+
</button>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div className="conversations-list">
|
|
40
|
+
{conversations.map((conv) => (
|
|
41
|
+
<div
|
|
42
|
+
key={conv.id}
|
|
43
|
+
className={`conversation-item ${conv.id === conversationId ? "active" : ""}`}
|
|
44
|
+
onClick={() => handleSelectConversation(conv.id)}
|
|
45
|
+
>
|
|
46
|
+
<IoChatbubbles size={16} />
|
|
47
|
+
<span className="title">{conv.title}</span>
|
|
48
|
+
<button className="delete-btn" onClick={(e) => handleDelete(e, conv.id)}>
|
|
49
|
+
<IoTrash size={14} />
|
|
50
|
+
</button>
|
|
51
|
+
</div>
|
|
52
|
+
))}
|
|
53
|
+
</div>
|
|
54
|
+
</aside>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Sidebar";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"jsx": "react-jsx",
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
"baseUrl": ".",
|
|
19
|
+
"paths": {
|
|
20
|
+
"@/*": ["src/*"],
|
|
21
|
+
"@/features/*": ["src/features/*"],
|
|
22
|
+
"@/shared/*": ["src/shared/*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"include": ["src"],
|
|
26
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
27
|
+
}
|