|
1 | | -# Credit Safe Harbor |
| 1 | +# CodeAlpha_StudentSupportFAQChatbot |
2 | 2 |
|
3 | | -CRITICAL: CREDIT LIMIT AND FINAL REPORT |
| 3 | +   |
4 | 4 |
|
5 | | -Before reaching any usage or credit limit, you must: |
| 5 | +**CodeAlpha_StudentSupportFAQChatbot** is a browser-based FAQ chatbot that answers common student questions about admissions, fees, attendance, exams, results, scholarships, the library, the LMS, registration, timetables and student support. It uses classic Natural Language Processing — text preprocessing, TF-IDF vectorization and cosine similarity — to find the stored FAQ closest to the user's question. |
6 | 6 |
|
7 | | -1. Save and preserve all completed work. |
| 7 | +> **Disclaimer:** the FAQ answers are demonstration content only. They are generic guidance, not the official policy of any university. |
8 | 8 |
|
9 | | -2. Stop starting new features when credits are running low. |
| 9 | +## Features |
10 | 10 |
|
11 | | -3. Generate a detailed progress report in your latest response. |
| 11 | +- **36 FAQs across 12 topics**, each with several alternate phrasings. |
| 12 | +- **NLP preprocessing:** lowercasing, accent and contraction normalization, punctuation removal, tokenization, abbreviation expansion, stop-word removal, Porter stemming and Levenshtein spelling correction. |
| 13 | +- **TF-IDF + cosine similarity** matching, implemented from scratch with smoothed IDF and L2-normalized vectors. |
| 14 | +- **Confidence threshold (0.30):** below it the bot does not guess; it shows a fallback with "Did you mean" suggestions. |
| 15 | +- **Separate fallbacks** for empty, too-short and unrelated questions. |
| 16 | +- **Chat interface:** welcome message, suggested questions, topic sidebar, quick chips, typing indicator, match percentage and category on answers, related questions, repeated-question note, Clear Chat, Enter to send (Shift + Enter for a new line) and a Send button. |
| 17 | +- **Session history** kept in the browser tab. |
| 18 | +- **Responsive** layout for phones, tablets and desktops. |
12 | 19 |
|
13 | | -4. Clearly list completed tasks and remaining tasks. |
| 20 | +## How matching works |
14 | 21 |
|
15 | | -5. Explain exactly how to complete each remaining task. |
| 22 | +```text |
| 23 | +question -> normalize -> tokenize -> remove stop words -> spell-correct -> stem |
| 24 | + -> TF-IDF vector -> cosine similarity vs every stored phrasing |
| 25 | + -> best score >= 0.30 ? answer : fallback + suggestions |
| 26 | +``` |
16 | 27 |
|
17 | | -6. Mention modified files and the exact point where development stopped. |
| 28 | +Settings such as the threshold live in `src/lib/nlp/config.ts`. |
18 | 29 |
|
19 | | -7. Provide a continuation prompt so I can resume later without rebuilding anything. |
| 30 | +## Tech stack |
20 | 31 |
|
21 | | -Never wait until credits are completely exhausted to report progress. Prioritize saving the project and reporting its status. |
| 32 | +React 19, TypeScript, Tailwind CSS v4, Vite, Vitest, and the `stopword`, `stemmer` and `fastest-levenshtein` libraries. |
22 | 33 |
|
23 | | -This project was built with [Lovable](https://lovable.dev). |
| 34 | +## Project structure |
24 | 35 |
|
25 | | -## Build with Lovable |
| 36 | +```text |
| 37 | +src/ |
| 38 | + data/faqs.json FAQ dataset |
| 39 | + lib/nlp/ preprocess, tfidf, faqMatcher, config |
| 40 | + components/chat/ chat interface |
| 41 | + pages-main.tsx entry for the static GitHub Pages build |
| 42 | + test/faqMatcher.test.ts matcher tests |
| 43 | +pages/index.html GitHub Pages HTML shell |
| 44 | +vite.pages.config.ts GitHub Pages build config |
| 45 | +.github/workflows/deploy-pages.yml |
| 46 | +``` |
26 | 47 |
|
27 | | -Continue developing this project in the [Lovable editor](https://lovable.dev/projects/d9a4c729-710d-44e3-9635-4d0932e0ef63). |
| 48 | +## Getting started |
28 | 49 |
|
29 | | -- **Ship faster**: describe what you want to build and Lovable handles the code. |
30 | | -- **Stay in sync**: every change made in Lovable is committed straight to this repository. |
31 | | -- **Full ownership**: this code is yours. Push to `main` on GitHub and your changes sync back into Lovable, ready for your next prompt. |
| 50 | +```sh |
| 51 | +npm install |
| 52 | +npm run dev # local development |
| 53 | +npm test # run the test suite |
| 54 | +npm run build:pages # static build in dist-pages/ |
| 55 | +``` |
32 | 56 |
|
33 | | -## Development |
| 57 | +## Deployment (GitHub Pages) |
34 | 58 |
|
35 | | -Prefer working locally? You need Node.js and npm — [install with nvm](https://github.com/nvm-sh/nvm#installing-and-updating). |
| 59 | +1. Push to `main`. |
| 60 | +2. In the repository, open **Settings → Pages** and set **Source** to **GitHub Actions**. |
| 61 | +3. The **Deploy to GitHub Pages** workflow runs the tests, builds and publishes the site to: |
| 62 | + `https://<your-username>.github.io/CodeAlpha_StudentSupportFAQChatbot/` |
36 | 63 |
|
37 | | -```sh |
38 | | -git clone <this-repository-url> |
39 | | -cd <repository-name> |
40 | | -npm i |
41 | | -npm run dev |
42 | | -``` |
| 64 | +## Testing |
| 65 | + |
| 66 | +28 automated tests cover correct answers, alternate wordings, misspellings, unrelated questions, empty and too-short input, the similarity threshold and the TF-IDF/cosine math. |
| 67 | + |
| 68 | +## Customizing the FAQs |
| 69 | + |
| 70 | +Add entries to `src/data/faqs.json` with `id`, `category`, `question`, `alternates` and `answer`. The index rebuilds automatically. |
| 71 | + |
| 72 | +## About |
| 73 | + |
| 74 | +CodeAlpha_StudentSupportFAQChatbot was built as Task 2 of the CodeAlpha internship. |
0 commit comments