From 51f1c6cb025b24a4cb413b418cf80a13cdbfa3ed Mon Sep 17 00:00:00 2001 From: Lhashwi05 <148397016+Lhashwi05@users.noreply.github.com> Date: Mon, 13 Apr 2026 14:49:48 -0400 Subject: [PATCH 1/2] Add installation guide for LexAI on macOS This document provides detailed system requirements and step-by-step instructions to build and install LexAI on macOS, including prerequisites and installation steps for necessary software. --- installation.md | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 installation.md diff --git a/installation.md b/installation.md new file mode 100644 index 0000000..3712c69 --- /dev/null +++ b/installation.md @@ -0,0 +1,58 @@ +Installation Guide: + +This document provides detailed system requirements and step-by-step instructions to build and install LexAI on macOS. + +System Requirements: +- **Operating System** | macOS 12.0 (Monterey) or newer | +- **Processor** | Apple Silicon (M1/M2/M3) | +- **Internet Connection** | Required for API calls and Firebase services | +- **Xcode** | 14.0+ | [Mac App Store](https://apps.apple.com/us/app/xcode/id497799835) +- **Python** | 3.9+ | [python.org](https://www.python.org/downloads) +- **Git** | Latest | [git-scm.com](https://git-scm.com) +- **Firebase Account** | Free tier | [firebase.google.com](https://firebase.google.com) + +Supported MacOS Versions: +- macOS 12 (Monterey) +- macOS 13 (Ventura) +- macOS 14 (Sonoma) +- macOS 15 (Sequoia) + +Pre-installations: +Step 1: Install Xcode +Step 2: Install node.js | https://nodejs.org/en/ +Step 3: Install git | https://git-scm.com/downloads +Step 4: Install python 3.9+ | python.org/downloads +Step 5: Request to be added as a FireBase project member and download the GoogleService-Info.plist + +Instructions to build and Install the Software +Step 1: Verify you have all prerequisite and pre-installations to build the project. +Step 2: Clone the repository | https://github.com/WSU-4110/LexAI.git +- In Command Prompt/Terminal + git clone https://github.com/WSU-4110/LexAI.git + cd LexAI +Step 3: Open XCode. +Step 4: Drop the GoogleService-Info.plist into the LexAI_IOS main folder +Step 5: Install Python Dependencies +# Navigate to backend directory +cd backend + +# Make an environment +python3 -m venv venv + +# Activate the virtual environment +source venv/bin/activate + +# Install required packages +pip3 install requests +pip3 install json5 +pip3 install PyPDF2 +pip3 install python-dotenv + +# If a requirements.txt file exists, use: +# pip3 install -r requirements.txt + +# Deactivate the virtual environment when done +deactivate + +Step 6: Locate the "Build" button on the top of the screen of XCode and press it to build the application. +Step 7: Locate the "Run" button on the top of the screen of XCode and press it to run the application. From ef5ef19604e70ebfb20f96696020d114b955b2da Mon Sep 17 00:00:00 2001 From: Leah Hashwi Date: Mon, 13 Apr 2026 17:29:43 -0400 Subject: [PATCH 2/2] [TASK] Documentation - Leah Fixes #90 --- LexAI_iOS/LexAI_iOS/Managers/ScanDocumentsView.swift | 8 ++++++++ LexAI_iOS/LexAI_iOS/Views/ChatView.swift | 8 +++++++- LexAI_iOS/LexAI_iOS/Views/HomeView.swift | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/LexAI_iOS/LexAI_iOS/Managers/ScanDocumentsView.swift b/LexAI_iOS/LexAI_iOS/Managers/ScanDocumentsView.swift index 94ab9c7..0b9e15b 100644 --- a/LexAI_iOS/LexAI_iOS/Managers/ScanDocumentsView.swift +++ b/LexAI_iOS/LexAI_iOS/Managers/ScanDocumentsView.swift @@ -17,17 +17,20 @@ struct ScanDocumentsView: UIViewControllerRepresentable { @Binding var isPresented: Bool var onTextAdded: ((String) -> Void)? + //Makes and configures the VNDocumentCameraViewController for document scanning func makeUIViewController(context: Context) -> VNDocumentCameraViewController { let scanner = VNDocumentCameraViewController() scanner.delegate = context.coordinator return scanner } + //Updates the view controller when SwiftUI state changes- keeps it currently empty as no updates are needed func updateUIViewController( _ uiViewController: VNDocumentCameraViewController, context: Context ) {} + //Makes a coordinator to handle delegate methods from the document camera view controller func makeCoordinator() -> Coordinator { Coordinator(self) } @@ -39,6 +42,7 @@ struct ScanDocumentsView: UIViewControllerRepresentable { self.parent = parent } + //Processes the scanned document pages, extracts text from each page and calls the onTextAdded callback with the combined text func documentCameraViewController( _ controller: VNDocumentCameraViewController, didFinishWith scan: VNDocumentCameraScan @@ -61,10 +65,12 @@ struct ScanDocumentsView: UIViewControllerRepresentable { parent.isPresented = false } + //Handles cancellation of the document scanner by dismissing the view func documentCameraViewControllerDidCancel(_ controller: VNDocumentCameraViewController) { parent.isPresented = false } + //Handles errors during document scanning by logging the error and dismissing the view func documentCameraViewController( _ controller: VNDocumentCameraViewController, didFailWithError error: Error @@ -73,6 +79,7 @@ struct ScanDocumentsView: UIViewControllerRepresentable { parent.isPresented = false } + //Extracts text from a given UIImage using Vision's text recognition private func extractText(from image: UIImage) -> String? { guard let cgImage = image.cgImage else { return nil } @@ -98,6 +105,7 @@ struct ScanDocumentsView: UIViewControllerRepresentable { struct ScanDocumentsPreviewWrapper: View { @State private var showScanner = true + //Gives a preview of the document scanner view for SwiftUI previews var body: some View { Text("Document Scanner Preview") .font(.title2) diff --git a/LexAI_iOS/LexAI_iOS/Views/ChatView.swift b/LexAI_iOS/LexAI_iOS/Views/ChatView.swift index 88764ee..bd284c2 100644 --- a/LexAI_iOS/LexAI_iOS/Views/ChatView.swift +++ b/LexAI_iOS/LexAI_iOS/Views/ChatView.swift @@ -16,6 +16,7 @@ struct ChatView: View { @Binding var selectedLanguage: String private let functions = Functions.functions() + //Defines the main chat interface layout, including the title, message list, and input bar. var body: some View { VStack(spacing: 0) { Text("LexAI") @@ -58,6 +59,7 @@ struct ChatView: View { } } + //Makes a scrollable list of chat messages with automatic scrolling to the bottom private var messageList: some View { ScrollViewReader { proxy in ScrollView { @@ -83,6 +85,7 @@ struct ChatView: View { .frame(maxWidth: .infinity, maxHeight: .infinity) } + //Makes the input bar with scan document button, text field, and send button private var inputBar: some View { VStack { HStack(alignment: .bottom, spacing: 12) { @@ -122,6 +125,7 @@ struct ChatView: View { } } + //Sends the user's message, validates input, and handles the AI response asynchronously private func sendMessage() { let text = ChatInputValidator.trimmedMessage(inputText) guard ChatInputValidator.shouldSendMessage(inputText) else { return } @@ -144,10 +148,11 @@ struct ChatView: View { } } + //Calls the Firebase function to generate an AI response based on the prompt and chat history private func generateAnswer(prompt: String, targetLanguage: String) async throws -> String { let callable = functions.httpsCallable("chat") - // Build chat history from previous messages (exclude the one we just added) + //Build chat history from previous messages (exclude the one we just added) let chatHistory: [[String: String]] = messages.dropLast().map { msg in ["role": msg.isFromUser ? "user" : "assistant", "content": msg.text] } @@ -177,6 +182,7 @@ private struct MessageBubbleView: View { let message: ChatMessage + //Defines the layout for displaying a single chat message bubble var body: some View { HStack(alignment: .top) { if message.isFromUser { Spacer(minLength: 48) } diff --git a/LexAI_iOS/LexAI_iOS/Views/HomeView.swift b/LexAI_iOS/LexAI_iOS/Views/HomeView.swift index ff070ad..a95afd3 100644 --- a/LexAI_iOS/LexAI_iOS/Views/HomeView.swift +++ b/LexAI_iOS/LexAI_iOS/Views/HomeView.swift @@ -9,6 +9,7 @@ struct HomeView: View { private let languages = ["English", "Spanish", "French", "Arabic", "German"] + //Defines the main view layout, including the chat view, sidebar, and language dropdown var body: some View { NavigationStack { ZStack {