tomalex04 commited on
Commit
b3046d9
·
1 Parent(s): 700863c

updated readme

Browse files
Files changed (5) hide show
  1. README.md +18 -3
  2. needed_links +0 -2
  3. static/front.html +0 -25
  4. static/script.js +0 -81
  5. static/style.css +0 -188
README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Fake News Detection (GDELT + Gemini) with Minimal UI
2
 
3
  This app takes a user query, builds robust GDELT queries via Gemini, fetches articles, analyzes outlet bias, ranks articles with local embeddings, and returns a concise, multi‑perspective summary. The UI renders exactly what the backend returns (no extra formatting or hardcoded values).
4
 
@@ -69,5 +69,20 @@ Notes:
69
  - When false, all domains are considered.
70
 
71
  ## Frontend
72
- - static/ contains a minimal JS client.
73
- - It outputs exactly the summary string received from backend (no hardcoded counts/colors/extra text; no horizontal scrolling).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Fake News Detection (GDELT + Gemini)
2
 
3
  This app takes a user query, builds robust GDELT queries via Gemini, fetches articles, analyzes outlet bias, ranks articles with local embeddings, and returns a concise, multi‑perspective summary. The UI renders exactly what the backend returns (no extra formatting or hardcoded values).
4
 
 
69
  - When false, all domains are considered.
70
 
71
  ## Frontend
72
+ - Primary UI: Flutter app in `misinformationui/`.
73
+ - Optional debug client: `static/` minimal JS page (useful for quick backend checks only).
74
+
75
+ ### Run the Flutter UI
76
+ 1) Start the backend (see Run section below) so it listens on http://localhost:5000
77
+
78
+ 2) In a separate terminal, run the Flutter app:
79
+ - cd misinformationui
80
+ - flutter pub get
81
+ - Choose a target:
82
+ - Web (Chrome): flutter run -d chrome
83
+ - Linux desktop: flutter run -d linux (ensure Linux desktop is enabled in Flutter)
84
+ - Android emulator: flutter run -d emulator
85
+ - Update the API URL in `misinformationui/lib/chat_screen.dart` from `http://localhost:5000` to `http://10.0.2.2:5000` for Android emulators, or use your machine's LAN IP for real devices.
86
+ - iOS simulator: `http://localhost:5000` should work; real devices need your machine's LAN IP.
87
+
88
+ Note: The legacy `static/` page is kept for quick smoke tests; the production UX is the Flutter app.
needed_links DELETED
@@ -1,2 +0,0 @@
1
- https://console.cloud.google.com/
2
- https://programmablesearchengine.google.com/
 
 
 
static/front.html DELETED
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Fake News Detection Chatbot</title>
7
- <link rel="stylesheet" href="style.css">
8
- </head>
9
-
10
- <body>
11
- <div class="chat-container" id="chat"></div>
12
-
13
- <div class="input-area">
14
- <input type="text" id="query" placeholder="Type news to verify..." />
15
- <button id="sendBtn">Send</button>
16
- </div>
17
-
18
- <div class="chat-background" id="chat-background">
19
- <p id="p1">Hey,</p>
20
- <p id="p2">Discover misinformations around you,</p>
21
- </div>
22
-
23
- <script src="script.js"></script>
24
- </body>
25
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/script.js DELETED
@@ -1,81 +0,0 @@
1
- const chat = document.getElementById('chat');
2
- const input = document.getElementById('query');
3
- const sendBtn = document.getElementById('sendBtn');
4
-
5
- function addMessage(text, sender, isPre = false) {
6
- const msg = document.createElement('div');
7
- msg.classList.add('message', sender);
8
-
9
- // Add special class for pre-formatted messages to style them properly
10
- if (isPre) {
11
- msg.classList.add('pre-formatted');
12
-
13
- // For pre-formatted text (terminal output)
14
- const pre = document.createElement('pre');
15
- pre.textContent = text;
16
-
17
- // No inline styles - all styling comes from CSS
18
- msg.appendChild(pre);
19
- } else {
20
- msg.textContent = text;
21
- }
22
-
23
- chat.appendChild(msg);
24
-
25
- // Smooth scroll to new message
26
- setTimeout(() => {
27
- msg.scrollIntoView({ behavior: 'smooth', block: 'end' });
28
- }, 100);
29
-
30
- return msg;
31
- }
32
-
33
- function extractValuesFromJson(jsonObj) {
34
- if (!jsonObj) return "No data received";
35
-
36
- // Just output the summary value without any processing
37
- if (jsonObj.summary) {
38
- return jsonObj.summary;
39
- }
40
-
41
- // If no summary field exists, output everything as-is
42
- return JSON.stringify(jsonObj);
43
- }
44
-
45
- async function sendMessage() {
46
- const query = input.value.trim();
47
- if (!query) return;
48
-
49
- const bg = document.getElementById('chat-background');
50
- if (bg && !bg.classList.contains('blurred')) {
51
- bg.classList.add('blurred');
52
- }
53
-
54
- addMessage(query, 'user');
55
- input.value = '';
56
-
57
- const loader = addMessage('Processing...', 'bot');
58
-
59
- try {
60
- const response = await fetch('/api/detect', {
61
- method: 'POST',
62
- headers: { 'Content-Type': 'application/json' },
63
- body: JSON.stringify({ query: query })
64
- });
65
-
66
- const data = await response.json();
67
- loader.remove();
68
-
69
- // Simply extract and display raw values from the JSON response
70
- const rawOutput = extractValuesFromJson(data);
71
- addMessage(rawOutput, 'bot', true);
72
- } catch (e) {
73
- loader.remove();
74
- addMessage("Error checking news: " + e.message, 'bot');
75
- }
76
- }
77
-
78
- sendBtn.addEventListener('click', sendMessage);
79
- input.addEventListener('keypress', (e) => {
80
- if (e.key === 'Enter') sendMessage();
81
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static/style.css DELETED
@@ -1,188 +0,0 @@
1
- body {
2
- font-family: Arial, sans-serif;
3
- margin: 0;
4
- padding: 0;
5
- height: 100vh;
6
- display: flex;
7
- flex-direction: column;
8
- overflow: hidden;
9
- }
10
-
11
- /* Blurred background image */
12
- body::before {
13
- content: "";
14
- position: fixed;
15
- top: 0;
16
- left: 0;
17
- width: 100vw;
18
- height: 100vh;
19
- z-index: -1;
20
- background: rgb(23, 23, 23);
21
- }
22
-
23
- .chat-container {
24
- flex: 1;
25
- display: flex;
26
- flex-direction: column;
27
- padding: 15px;
28
- overflow-y: auto;
29
- overflow-x: hidden; /* prevent horizontal scrolling */
30
- margin-bottom: 70px;
31
- background: transparent;
32
- width: 100%;
33
- max-width: 95%; /* wider to accommodate terminal output */
34
- margin-left: auto; /* center align */
35
- margin-right: auto; /* center align */
36
- scroll-behavior: smooth; /* Smooth scrolling */
37
- height: calc(100vh - 70px); /* Full height minus input area */
38
- }
39
-
40
- .message {
41
- width: fit-content; /* shrink to text */
42
- max-width: 100%; /* allow full width for terminal output */
43
- margin-bottom: 12px;
44
- padding: 12px 15px;
45
- border-radius: 15px;
46
- line-height: 1.4;
47
- }
48
-
49
- /* Special styling for bot messages with pre-formatted text */
50
- .message.bot.pre-formatted {
51
- width: 100%; /* full width for terminal output */
52
- max-width: 100%; /* no width restriction */
53
- white-space: pre-wrap; /* wrap text to prevent horizontal scroll */
54
- overflow-wrap: break-word; /* break long words if needed */
55
- }
56
-
57
- .user {
58
- align-self: flex-end; /* right side */
59
- background: #414141;
60
- color: #fff;
61
- border-bottom-right-radius: 5px;
62
- }
63
-
64
- .bot {
65
- align-self: flex-start; /* left side */
66
- background: transparent;
67
- color: #ffffff;
68
- border-bottom-left-radius: 5px;
69
- }
70
-
71
- /* Terminal output style - matching exactly what appears in the terminal */
72
- .message.bot pre {
73
- font-family: monospace;
74
- background-color: transparent; /* No background color */
75
- color: inherit; /* Use the same text color as the parent */
76
- padding: 0;
77
- border: none;
78
- width: 100%;
79
- max-height: none; /* No height limit */
80
- overflow-x: visible; /* No horizontal scrolling */
81
- white-space: pre-wrap; /* Wrap text to prevent horizontal scrolling */
82
- font-size: inherit;
83
- line-height: 1.4;
84
- }
85
-
86
-
87
-
88
- .input-area {
89
- position: fixed;
90
- bottom: 1rem;
91
- left: 50%;
92
- transform: translateX(-50%);
93
- width: 100%;
94
- max-width: 95%; /* Match the width of chat container */
95
- display: flex;
96
- padding: 10px;
97
- background: rgba(54, 54, 54, 0.7); /* make input area semi-transparent */
98
- box-shadow: 0 -2px 5px rgba(0,0,0,0.05);
99
- border-radius: 30px;
100
- z-index: 10; /* Ensure input stays on top */
101
- }
102
-
103
- .input-area input {
104
- flex: 1;
105
- padding: 14px 18px;
106
- border: 1px solid #1b1b1b;
107
- box-shadow: #414141;
108
- border-radius: 25px;
109
- outline: none;
110
- font-size: 1rem;
111
- }
112
-
113
- .input-area button {
114
- margin-left: 10px;
115
- padding: 0 20px;
116
- border: none;
117
- background: #1f1f1f;
118
- color: white;
119
- border-radius: 25px;
120
- cursor: pointer;
121
- font-size: 1rem;
122
- transition: background 0.2s ease;
123
- }
124
-
125
- .input-area button:hover {
126
- background: #6a6a6a;
127
- }
128
-
129
- .loader {
130
- font-size: 0.9rem;
131
- color: gray;
132
- margin: 5px 0;
133
- }
134
- .chat-background{
135
- position: fixed;
136
- font-family: 'Courier New', Courier, monospace;
137
- top: 40%;
138
- left: 50%;
139
- transform: translate(-50%, -50%);
140
- font-weight: bold;
141
- color: rgba(255, 255, 255, 0.8); /* semi-transparent */
142
- text-align: center;
143
- z-index: 0; /* below chat messages */
144
- pointer-events: none; /* makes it "untouchable" */
145
- transition: all 0.4s ease;
146
- }
147
- .chat-background{
148
- display: inline-block;
149
- text-align: left;
150
- }
151
- .chat-background #p1 {
152
- font-size: 4rem;
153
- }
154
-
155
- .chat-background #p2 {
156
- font-size: 3rem;
157
- }
158
-
159
- /* When blurred */
160
- .chat-background.blurred {
161
- filter: blur(12px); /* strong blur */
162
- opacity: 0.4; /* fade slightly for readability */
163
- transition: all 0.4s ease;
164
- }
165
-
166
- @media (max-width: 600px) {
167
- .message {
168
- max-width: 85%;
169
- }
170
-
171
- .chat-container {
172
- padding: 10px;
173
- max-width: 100%;
174
- }
175
-
176
- .input-area {
177
- max-width: 95%;
178
- bottom: 0.5rem;
179
- }
180
-
181
- .chat-background #p1 {
182
- font-size: 3rem;
183
- }
184
-
185
- .chat-background #p2 {
186
- font-size: 2rem;
187
- }
188
- }