-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepomix-output.txt
2011 lines (1769 loc) · 55.7 KB
/
repomix-output.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
This file is a merged representation of the entire codebase, combining all repository files into a single document.
Generated by Repomix on: 2024-12-06T17:55:47.703Z
================================================================
File Summary
================================================================
Purpose:
--------
This file contains a packed representation of the entire repository's contents.
It is designed to be easily consumable by AI systems for analysis, code review,
or other automated processes.
File Format:
------------
The content is organized as follows:
1. This summary section
2. Repository information
3. Repository structure
4. Multiple file entries, each consisting of:
a. A separator line (================)
b. The file path (File: path/to/file)
c. Another separator line
d. The full contents of the file
e. A blank line
Usage Guidelines:
-----------------
- This file should be treated as read-only. Any changes should be made to the
original repository files, not this packed version.
- When processing this file, use the file path to distinguish
between different files in the repository.
- Be aware that this file may contain sensitive information. Handle it with
the same level of security as you would the original repository.
Notes:
------
- Some files may have been excluded based on .gitignore rules and Repomix's
configuration.
- Binary files are not included in this packed representation. Please refer to
the Repository Structure section for a complete list of file paths, including
binary files.
Additional Info:
----------------
For more information about Repomix, visit: https://github.com/yamadashy/repomix
================================================================
Repository Structure
================================================================
backend/
JobReadyAI.API/
Controllers/
ChatController.cs
Models/
ChatRequest.cs
Properties/
launchSettings.json
Services/
OpenAIService.cs
appsettings.Development.json
appsettings.json
JobReadyAI.API.csproj
JobReadyAI.API.http
Program.cs
frontend/
job-ready-ai-client/
src/
app/
core/
models/
chat.model.ts
services/
chat.service.ts
features/
chat/
components/
message/
message.component.html
message.component.ts
message-input/
message-input.component.html
message-input.component.ts
chat.component.html
chat.component.ts
app.component.html
app.component.spec.ts
app.component.ts
app.config.ts
app.routes.ts
environments/
environment.development.ts
environment.ts
_redirects
env.js
index.html
main.ts
styles.scss
.editorconfig
.gitignore
angular.json
netlify.toml
package.json
postcss.config.js
README.md
tailwind.config.js
tsconfig.app.json
tsconfig.json
tsconfig.spec.json
.gitignore
JobReadyAI.sln
README.md
================================================================
Repository Files
================================================================
================
File: backend/JobReadyAI.API/Controllers/ChatController.cs
================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using JobReadyAI.API.Models;
using JobReadyAI.API.Services;
using Microsoft.AspNetCore.Cors;
using OpenAI.Chat;
namespace JobReadyAI.API.Controllers
{
[ApiController]
[Route("api/[controller]")]
[EnableCors("AllowAngular")]
public class ChatController : ControllerBase
{
private readonly IOpenAIService _openAIService;
public ChatController(IOpenAIService openAIService)
{
_openAIService = openAIService;
}
public class ChatRequest
{
public string Message { get; set; }
public List<MessageHistory> ConversationHistory { get; set; } = new List<MessageHistory>();
}
public class MessageHistory
{
public string Role { get; set; }
public string Content { get; set; }
}
[HttpPost]
public async Task<IActionResult> GetResponse([FromBody] ChatRequest request)
{
try
{
if (request == null || string.IsNullOrEmpty(request.Message))
{
return BadRequest("Message cannot be empty");
}
var messages = new List<ChatMessage>();
foreach (var msg in request.ConversationHistory ?? new List<MessageHistory>())
{
messages.Add(msg.Role == "user"
? new UserChatMessage(msg.Content)
: new AssistantChatMessage(msg.Content));
}
messages.Add(new UserChatMessage(request.Message));
var response = await _openAIService.GetChatResponseAsync(messages);
return Ok(new { response });
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
return BadRequest(new { error = ex.Message });
}
}
}
}
================
File: backend/JobReadyAI.API/Models/ChatRequest.cs
================
namespace JobReadyAI.API.Models
{
public class ChatRequest
{
public string Message { get; set; }
public List<MessageHistory> ConversationHistory { get; set; } = new List<MessageHistory>();
}
public class MessageHistory
{
public string Role { get; set; }
public string Content { get; set; }
}
}
================
File: backend/JobReadyAI.API/Properties/launchSettings.json
================
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51977",
"sslPort": 44341
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7108;http://localhost:5001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
================
File: backend/JobReadyAI.API/Services/OpenAIService.cs
================
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using OpenAI;
using OpenAI.Chat;
using OpenAI.Models;
namespace JobReadyAI.API.Services
{
public interface IOpenAIService
{
Task<string> GetChatResponseAsync(List<ChatMessage> conversationHistory);
}
public class OpenAIService : IOpenAIService
{
private readonly ChatClient _chatClient;
private readonly string _systemPrompt = @"You are an experienced recruiter and interview specialist with expertise in creating targeted interview questions for a variety of roles and industries. Your task is to generate high-quality interview questions based on the job description provided by the user.
### Instructions:
1. Analyze the job description thoroughly to identify key skills, responsibilities, and qualifications.
2. Generate interview questions in the following categories:
- **Technical Questions**: Assess the candidate's job-specific technical skills.
- **Behavioral Questions**: Evaluate the candidate's soft skills, such as teamwork, leadership, and communication.
- **Situational Questions**: Explore how the candidate would handle specific challenges or scenarios related to the role.
3. Provide a brief explanation for each question to clarify its relevance to the role.
4. If the user provides additional preferences (e.g., focus on leadership or coding skills), customize the questions accordingly.
### Important Rules:
- **Relevance**: Refuse to answer queries unrelated to job interviews or question generation. Respond politely and inform the user of the tool's intended purpose.
- **Format**: Deliver the output in a clear and organized format, categorized by question type.
- **Customization**: Be flexible to refine the questions based on user feedback or specific role requirements.";
public OpenAIService(string apiKey)
{
_chatClient = new ChatClient("gpt-4", apiKey);
}
public async Task<string> GetChatResponseAsync(List<ChatMessage> conversationHistory)
{
var messages = new List<ChatMessage>
{
// Add system message first
new SystemChatMessage(_systemPrompt)
};
// Add the conversation history
messages.AddRange(conversationHistory);
ChatCompletion completion = await _chatClient.CompleteChatAsync(messages);
return completion.Content[0].Text;
}
}
}
================
File: backend/JobReadyAI.API/appsettings.Development.json
================
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
================
File: backend/JobReadyAI.API/appsettings.json
================
{
"OpenAI": {
"ApiKey": "your-api-key-here"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
================
File: backend/JobReadyAI.API/JobReadyAI.API.csproj
================
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>acec3be8-b9ef-4e7b-a9fc-f9bc43895333</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.4" />
<PackageReference Include="OpenAI" Version="2.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
</Project>
================
File: backend/JobReadyAI.API/JobReadyAI.API.http
================
@JobReadyAI.API_HostAddress = http://localhost:5001
GET {{JobReadyAI.API_HostAddress}}/weatherforecast/
Accept: application/json
###
================
File: backend/JobReadyAI.API/Program.cs
================
using JobReadyAI.API.Services;
using Microsoft.AspNetCore.Cors;
var builder = WebApplication.CreateBuilder(args);
// Add CORS first
builder.Services.AddCors(options =>
{
options.AddPolicy("AllowAngular", builder =>
{
builder.WithOrigins("http://localhost:4200")
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials(); // Add this if you're using cookies/authentication
});
});
// Add other services
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
// Register OpenAI Service
builder.Services.AddSingleton<IOpenAIService>(provider =>
new OpenAIService(builder.Configuration["OpenAI:ApiKey"]!));
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
// Add CORS before routing and after any authentication/authorization middleware
app.UseCors("AllowAngular");
app.UseHttpsRedirection();
app.MapControllers();
// Add some logging middleware to debug CORS issues
app.Use(async (context, next) =>
{
Console.WriteLine($"Request from: {context.Request.Headers["Origin"]}");
Console.WriteLine($"Method: {context.Request.Method}");
Console.WriteLine($"Path: {context.Request.Path}");
await next();
});
app.Run();
================
File: frontend/job-ready-ai-client/src/app/core/models/chat.model.ts
================
export interface ChatMessage {
id: string;
content: string;
timestamp: Date;
isUser: boolean;
status?: 'sending' | 'sent' | 'error';
}
export interface ChatRequest {
message: string;
conversationHistory: MessageHistory[];
}
export interface MessageHistory {
role: 'user' | 'assistant';
content: string;
}
export interface ChatResponse {
response: string;
}
================
File: frontend/job-ready-ai-client/src/app/core/services/chat.service.ts
================
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, BehaviorSubject, throwError } from 'rxjs';
import { tap, catchError } from 'rxjs/operators';
import { ChatMessage, ChatRequest, ChatResponse, MessageHistory } from '../models/chat.model';
import { environment } from '../../../environments/environment';
import jsPDF from 'jspdf';
@Injectable({
providedIn: 'root'
})
export class ChatService {
private apiUrl = `${environment.apiUrl}/api/chat`;
private messagesSubject = new BehaviorSubject<ChatMessage[]>([]);
messages$ = this.messagesSubject.asObservable();
constructor(private http: HttpClient) {}
sendMessage(content: string): Observable<ChatResponse> {
const messageId = crypto.randomUUID();
const userMessage: ChatMessage = {
id: messageId,
content,
timestamp: new Date(),
isUser: true,
status: 'sent'
};
this.addMessage(userMessage);
const conversationHistory: MessageHistory[] = this.messagesSubject.value.map(msg => ({
role: msg.isUser ? 'user' as const : 'assistant' as const,
content: msg.content
}));
const request: ChatRequest = {
message: content,
conversationHistory: conversationHistory.slice(0, -1)
};
return this.http.post<ChatResponse>(this.apiUrl, request).pipe(
tap(response => {
const aiMessage: ChatMessage = {
id: crypto.randomUUID(),
content: response.response,
timestamp: new Date(),
isUser: false,
status: 'sent'
};
this.addMessage(aiMessage);
}),
catchError(error => {
this.updateMessageStatus(messageId, 'error');
return throwError(() => error);
})
);
}
clearChat(): void {
this.messagesSubject.next([]);
}
exportChatAsPDF(): void {
const doc = new jsPDF();
const messages = this.messagesSubject.value;
let yPos = 20;
doc.setFontSize(16);
doc.text('Chat Export', 20, yPos);
yPos += 10;
doc.setFontSize(12);
messages.forEach((message) => {
const sender = message.isUser ? 'You' : 'AI';
const timestamp = message.timestamp.toLocaleString();
const content = `${sender} (${timestamp}): ${message.content}`;
const lines = doc.splitTextToSize(content, 170);
if (yPos + (lines.length * 7) > 280) {
doc.addPage();
yPos = 20;
}
doc.text(lines, 20, yPos);
yPos += (lines.length * 7) + 5;
});
doc.save('chat-export.pdf');
}
exportChatAsText(): string {
const messages = this.messagesSubject.value;
let textContent = 'Chat Export\n\n';
messages.forEach((message) => {
const sender = message.isUser ? 'You' : 'AI';
const timestamp = message.timestamp.toLocaleString();
textContent += `${sender} (${timestamp}):\n${message.content}\n\n`;
});
return textContent;
}
private addMessage(message: ChatMessage): void {
const currentMessages = this.messagesSubject.value;
this.messagesSubject.next([...currentMessages, message]);
}
private updateMessageStatus(messageId: string, status: 'sending' | 'sent' | 'error'): void {
const currentMessages = this.messagesSubject.value;
const updatedMessages = currentMessages.map(msg =>
msg.id === messageId ? { ...msg, status } : msg
);
this.messagesSubject.next(updatedMessages);
}
}
================
File: frontend/job-ready-ai-client/src/app/features/chat/components/message/message.component.html
================
<div class="message" [ngClass]="{'user-message': message.isUser, 'ai-message': !message.isUser}">
<div class="message-content">
{{ message.content }}
</div>
<div class="message-timestamp">
{{ message.timestamp | date:'short' }}
</div>
<div *ngIf="message.status" class="message-status">
{{ message.status }}
</div>
</div>
================
File: frontend/job-ready-ai-client/src/app/features/chat/components/message/message.component.ts
================
import { Component, Input, OnChanges } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ChatMessage } from '../../../../core/models/chat.model';
import { marked } from 'marked';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Component({
selector: 'app-message',
standalone: true,
imports: [CommonModule],
template: `
<div class="message" [ngClass]="{'user-message': message.isUser, 'ai-message': !message.isUser}">
<div class="message-content" [innerHTML]="parsedContent"></div>
<div class="message-timestamp">{{ message.timestamp | date:'short' }}</div>
</div>
`,
styles: [`
.message {
max-width: 80%;
margin: 0.5rem 0;
padding: 0.75rem;
border-radius: 8px;
&.user-message {
margin-left: auto;
background: #007bff;
color: white;
}
&.ai-message {
margin-right: auto;
background: white;
border: 1px solid #dee2e6;
::ng-deep {
p { margin-bottom: 0.5rem; }
strong { font-weight: 600; }
ul, ol { margin: 0.5rem 0; padding-left: 1.5rem; }
li { margin-bottom: 0.25rem; }
h3 { font-size: 1.1rem; font-weight: 600; margin: 1rem 0 0.5rem; }
em {
font-style: italic;
color: #666;
display: block;
margin-top: 0.25rem;
margin-left: 1rem;
font-size: 0.9rem;
}
h2, h3, h4 {
font-weight: 600;
color: #2c3e50;
margin-top: 1rem;
}
/* Style for the question categories */
h4 {
border-bottom: 2px solid #e9ecef;
padding-bottom: 0.5rem;
margin-bottom: 1rem;
}
}
}
}
.message-timestamp {
font-size: 0.75rem;
opacity: 0.7;
margin-top: 0.25rem;
}
`]
})
export class MessageComponent implements OnChanges {
@Input() message!: ChatMessage;
parsedContent: SafeHtml = '';
constructor(private sanitizer: DomSanitizer) {
marked.setOptions({
breaks: true, // Adds <br> on single line breaks
gfm: true // GitHub Flavored Markdown
});
}
ngOnChanges(): void {
if (this.message && !this.message.isUser) {
// Convert markdown to HTML synchronously
const htmlContent = marked.parse(this.message.content);
// Ensure we're working with a string
if (typeof htmlContent === 'string') {
this.parsedContent = this.sanitizer.bypassSecurityTrustHtml(htmlContent);
} else {
// Handle the case where htmlContent is a Promise
this.parsedContent = this.sanitizer.bypassSecurityTrustHtml(this.message.content);
}
} else {
this.parsedContent = this.message.content;
}
}
}
================
File: frontend/job-ready-ai-client/src/app/features/chat/components/message-input/message-input.component.html
================
<div class="message-input-container">
<input
type="text"
[formControl]="messageControl"
placeholder="Type your message..."
(keyup.enter)="sendMessage()">
<button
(click)="sendMessage()"
[disabled]="!messageControl.valid">
Send
</button>
</div>
================
File: frontend/job-ready-ai-client/src/app/features/chat/components/message-input/message-input.component.ts
================
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-message-input',
standalone: true,
imports: [CommonModule, FormsModule],
template: `
<div class="message-input-container">
<textarea
[(ngModel)]="messageText"
[disabled]="disabled"
(keyup.enter)="sendMessage()"
placeholder="Paste your job description here..."
rows="3"
class="input-textarea">
</textarea>
<button
(click)="sendMessage()"
[disabled]="!messageText?.trim() || disabled"
class="send-button">
Analyze Job Description
</button>
</div>
`,
styles: [`
.message-input-container {
padding: 1rem;
border-top: 1px solid #dee2e6;
display: flex;
flex-direction: column;
gap: 0.75rem;
}
.input-textarea {
flex: 1;
padding: 0.75rem;
border: 1px solid #dee2e6;
border-radius: 4px;
resize: vertical;
min-height: 80px;
font-family: inherit;
font-size: 0.95rem;
line-height: 1.5;
&:focus {
outline: none;
border-color: #007bff;
box-shadow: 0 0 0 2px rgba(0,123,255,0.1);
}
&:disabled {
background-color: #e9ecef;
cursor: not-allowed;
}
&::placeholder {
color: #6c757d;
font-style: italic;
}
}
.send-button {
padding: 0.75rem 1rem;
background: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-weight: 500;
transition: background-color 0.2s;
&:hover:not(:disabled) {
background: #0056b3;
}
&:disabled {
background: #6c757d;
cursor: not-allowed;
}
}
`]
})
export class MessageInputComponent {
@Input() disabled = false;
@Output() messageSent = new EventEmitter<string>();
messageText = '';
sendMessage(): void {
if (this.messageText?.trim() && !this.disabled) {
this.messageSent.emit(this.messageText);
this.messageText = '';
}
}
}
================
File: frontend/job-ready-ai-client/src/app/features/chat/chat.component.html
================
<div class="chat-container" #scrollContainer>
<div class="messages-container">
<app-message
*ngFor="let message of messages$ | async"
[message]="message">
</app-message>
</div>
<app-message-input
[disabled]="isLoading"
(messageSent)="onMessageSent($event)">
</app-message-input>
</div>
================
File: frontend/job-ready-ai-client/src/app/features/chat/chat.component.ts
================
import { Component, ViewChild, ElementRef, AfterViewChecked, OnInit, ChangeDetectorRef } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { ChatService } from '../../core/services/chat.service';
import { Observable, finalize } from 'rxjs';
import { ChatMessage } from '../../core/models/chat.model';
import { marked } from 'marked';
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
@Component({
selector: 'app-chat',
standalone: true,
imports: [CommonModule, FormsModule],
template: `
<div class="flex flex-col h-[100vh] overflow-hidden">
<div class="flex-none py-3">
<div class="max-w-3xl mx-auto px-4">
<div class="flex justify-center items-center">
<h1 class="text-3xl font-semibold text-gray-800">
JobReadyAI Interview Assistant
</h1>
</div>
</div>
</div>
<!-- Messages area -->
<div class="flex-1 overflow-y-auto" #scrollContainer>
<!-- Welcome Message -->
<div *ngIf="(messages$ | async)?.length === 0"
class="h-full flex items-center justify-center p-4">
<div class="text-center max-w-2xl">
<div class="mb-6">
<div class="w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto">
<svg class="w-8 h-8 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M8 10h.01M12 10h.01M16 10h.01M9 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-5l-5 5v-5z"/>
</svg>
</div>
</div>
<h2 class="text-2xl font-semibold mb-2 text-gray-800">Welcome to JobReadyAI</h2>
<p class="text-gray-600">
Enter a job description below to get tailored interview questions.
</p>
</div>
</div>
<!-- Messages -->
<div class="w-full">
<ng-container *ngFor="let message of messages$ | async">
<!-- User Message -->
<div *ngIf="message.isUser" class="bg-white">
<div class="max-w-3xl mx-auto px-4 py-6 flex gap-4">
<div class="w-7 h-7 shrink-0 rounded-sm flex items-center justify-center bg-blue-600 text-white">
<span class="text-xs">You</span>
</div>
<div class="flex-1 whitespace-pre-wrap text-sm">
{{ message.content }}
</div>
</div>
</div>
<!-- AI Message -->
<div *ngIf="!message.isUser" class="bg-gray-50">
<div class="max-w-3xl mx-auto px-4 py-6 flex gap-4">
<div class="w-7 h-7 shrink-0 rounded-sm flex items-center justify-center bg-teal-600 text-white">
<span class="text-xs">AI</span>
</div>
<div class="flex-1">
<div class="prose prose-sm max-w-none">
<div [innerHTML]="parseMarkdown(message.content)"></div>
</div>
</div>
</div>
</div>
</ng-container>
<!-- Loading Indicator -->
<div *ngIf="isLoading" class="bg-gray-50">
<div class="max-w-3xl mx-auto px-4 py-6 flex gap-4">
<div class="w-7 h-7 shrink-0 rounded-sm flex items-center justify-center bg-teal-600 text-white">
<span class="text-xs">AI</span>
</div>
<div class="flex gap-2">
<div class="w-2 h-2 bg-gray-400 rounded-full animate-bounce"></div>
<div class="w-2 h-2 bg-gray-400 rounded-full animate-bounce [animation-delay:-0.15s]"></div>
<div class="w-2 h-2 bg-gray-400 rounded-full animate-bounce [animation-delay:-0.3s]"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Input area -->
<div class="flex-none p-4 bg-white">
<div class="max-w-3xl mx-auto">
<form (ngSubmit)="sendMessage()" class="relative">
<textarea
[(ngModel)]="newMessage"
name="message"
rows="2"
[disabled]="isLoading"
(keydown)="handleEnterKey($event)"
class="w-full resize-none rounded-lg border border-gray-200 bg-white pr-32 pl-4 py-3 text-sm focus:border-blue-600 focus:outline-none focus:ring-1 focus:ring-blue-600 disabled:bg-gray-100"
placeholder="Paste your job description here..."
></textarea>
<div class="absolute right-2 bottom-2 flex gap-2">
<!-- Clear Chat Button -->
<button
type="button"
(click)="clearChat()"
class="p-1.5 rounded-md text-gray-500 hover:bg-gray-100 group relative"
title="Clear chat"
>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-5 h-5">
<path fill-rule="evenodd" d="M16.5 4.478v.227a48.816 48.816 0 013.878.512.75.75 0 11-.256 1.478l-.209-.035-1.005 13.07a3 3 0 01-2.991 2.77H8.084a3 3 0 01-2.991-2.77L4.087 6.66l-.209.035a.75.75 0 01-.256-1.478A48.567 48.567 0 017.5 4.705v-.227c0-1.564 1.213-2.9 2.816-2.951a52.662 52.662 0 013.369 0c1.603.051 2.815 1.387 2.815 2.951zm-6.136-1.452a51.196 51.196 0 013.273 0C14.39 3.05 15 3.684 15 4.478v.113a49.488 49.488 0 00-6 0v-.113c0-.794.609-1.428 1.364-1.452zm-.355 5.945a.75.75 0 10-1.5.058l.347 9a.75.75 0 101.499-.058l-.346-9zm5.48.058a.75.75 0 10-1.498-.058l-.347 9a.75.75 0 001.5.058l.345-9z" clip-rule="evenodd" />
</svg>
<span class="absolute bottom-full mb-2 w-auto min-w-max bg-gray-900 text-white text-xs px-2 py-1 rounded-md invisible group-hover:visible">
Clear chat history
</span>
</button>
<!-- Export Button -->
<div class="relative">
<button
type="button"
(click)="toggleExportMenu($event)"
class="p-1.5 rounded-md text-gray-500 hover:bg-gray-100 group relative"
title="Export chat"
>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-5 h-5">
<path fill-rule="evenodd" d="M12 2.25a.75.75 0 01.75.75v11.69l3.22-3.22a.75.75 0 111.06 1.06l-4.5 4.5a.75.75 0 01-1.06 0l-4.5-4.5a.75.75 0 111.06-1.06l3.22 3.22V3a.75.75 0 01.75-.75zm-9 13.5a.75.75 0 01.75.75v2.25a1.5 1.5 0 001.5 1.5h13.5a1.5 1.5 0 001.5-1.5V16.5a.75.75 0 011.5 0v2.25a3 3 0 01-3 3H5.25a3 3 0 01-3-3V16.5a.75.75 0 01.75-.75z" clip-rule="evenodd" />
</svg>
<span class="absolute bottom-full mb-2 w-auto min-w-max bg-gray-900 text-white text-xs px-2 py-1 rounded-md invisible group-hover:visible">
Export chat
</span>
</button>
<!-- Export dropdown menu -->
<div *ngIf="showExportMenu"
class="absolute bottom-full right-0 mb-2 w-32 bg-white rounded-md shadow-lg z-50 border border-gray-200">
<div class="py-1">
<button
type="button"
(click)="exportAsPDF()"
class="w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 text-left"
>
Export as PDF
</button>
<button
type="button"
(click)="exportAsText()"
class="w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 text-left"
>
Export as Text
</button>
</div>
</div>
</div>
<!-- Send Button -->
<button
type="submit"
[disabled]="!newMessage.trim() || isLoading"
class="p-1.5 rounded-md text-gray-500 hover:bg-gray-100 disabled:hover:bg-transparent disabled:opacity-40 group relative"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="currentColor"
class="w-5 h-5"
>
<path d="M3.478 2.404a.75.75 0 00-.926.941l2.432 7.905H13.5a.75.75 0 010 1.5H4.984l-2.432 7.905a.75.75 0 00.926.94 60.519 60.519 0 0018.445-8.986.75.75 0 000-1.218A60.517 60.517 0 003.478 2.404z" />
</svg>
<span class="absolute bottom-full mb-2 w-auto min-w-max bg-gray-900 text-white text-xs px-1 py-1 rounded-md invisible group-hover:visible">
Send
</span>
</button>