sequenceDiagram
actor User
participant App as Mobile App
participant Server as Auth Server
participant Google as Google OAuth
%% Basic Flow
User->>App: Enter Email & Password
User->>App: Tap Sign In
App->>App: Validate Input Fields
alt Valid Input
App->>Server: Send Auth Request
Server->>Server: Verify Credentials
Server->>App: Return Auth Token
App->>App: Store Token Securely
App->>User: Show Dashboard
else Invalid Input
App->>User: Show Error Message
end
%% Alternative Flow (Google)
rect rgb(240, 240, 240)
Note over User,Google: Alternative Flow - Google Sign In
User->>App: Select "Sign up with Google"
App->>Google: Initialize OAuth Flow
Google->>User: Show Google Login
User->>Google: Authenticate
Google->>App: Return OAuth Token
App->>Server: Verify Google Token
Server->>App: Return App Auth Token
App->>App: Store Token Securely
App->>User: Show Dashboard
end
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
this is the sample of sequence diagram
UC-12: Review Past Conversations
Use Case UC-13
Use case name Review Past Conversations
Description User reviews past lesson conversations.
Actor(s) User
Priority Nice to have
Pre-condition(s) • User is logged in
• User has finished at least one lesson
Basic Flow Step Action
1 Opens "Lesson history" page
2 Shows completed lessons
3 Selects a lesson
4 Shows conversation details
5 Views conversation parts
Alternative Flow 4a (If no history) Shows "No data" message
4a (If no history) Returns to lesson list
Post-Condition(s) • User can review their performance in past lessons
this is my use case, based on this generate for me the sequence diagram
Assistant
Based on the provided Use Case (UC-13: Review Past Conversations), I'll create a sequence diagram for you. Here's the result:
sequenceDiagram
actor User
participant App as Mobile App
participant Server as Application Server
participant DB as Database
%% Basic Flow
Note over User,App: Pre-condition: User is logged in & has finished at least one lesson
User->>App: Tap "Lesson history" button
App->>Server: Request Lesson History (Auth Token included)
Server->>DB: Retrieve Completed Lessons for User
DB->>Server: Return List of Completed Lessons
Server->>App: Send Lesson History Data
App->>User: Display Completed Lessons List
User->>App: Select a Lesson from the List
App->>Server: Request Conversation Details for Selected Lesson (Lesson ID & Auth Token)
Server->>DB: Retrieve Conversation Parts for Lesson ID
DB->>Server: Return Conversation Details
Server->>App: Send Conversation Data
App->>User: Show Conversation Details (parts, messages, etc.)
User->>App: Scroll/View Conversation Parts
%% Alternative Flow (No History)
alt No Lesson History Found
Server->>App: Return "No Data" Response
App->>User: Display "No lesson history found" Message
User->>App: Tap "Back" or "OK"
App->>App: Navigate Back to Lesson List
end
%% Post-Condition
Note over User,App: Post-condition: User reviewed past lesson conversations
Let me explain the decisions I made while creating this sequence diagram:
Participants:
User: The actor interacting with the system.
App (Mobile App): The frontend interface where the user interacts.
Server (Application Server): Handles business logic, validates auth tokens, and communicates with the database.
DB (Database): Stores lesson history, conversation details, and user data.
Pre-condition:
The note at the beginning emphasizes that the user must be logged in (implicitly sending an Auth Token with requests) and must have completed at least one lesson (ensuring data exists in the database).
Basic Flow:
Step 1 (Opens "Lesson history" page): User taps "Lesson history" in the app.
Step 2 (Shows completed lessons):
App -> Server: Requests lesson history (auth token is implicitly included in the request headers, e.g., Authorization: Bearer <token>).
User
UC-13: Level Up After Completion
Use Case UC-14
Use case name Level Up After Completion
Description User moves to the next level after finishing the last conversation at the current level
Actor(s) User, Virtual Teacher
Priority Must have
Pre-condition(s) • User has completed all conversations at current level
Basic Flow Step Action
1 Checks if user finished 70% conversations at
Level
2 User finished the last conversation and pass it
3 Shows "Congratulations! You have leveled up."
4 Unlocks next level lessons
5 Starts new lessons at the next level
Alternative Flow 2a (If not passed) Show notification message
Post-Condition(s) • User can access new lessons at the next level
and keep doing for this usecase
Assistant
Based on the provided Use Case (UC-14: Level Up After Completion), I'll create a sequence diagram for you. Here's the result:
sequenceDiagram
actor User
participant App as Mobile App
participant Server as Application Server
participant DB as Database
participant VirtualTeacher as Virtual Teacher Service
%% Basic Flow
Note over User,App: Pre-condition: User completed all conversations at current level
User->>VirtualTeacher: Finish Last Conversation at Current Level
VirtualTeacher->>App: Notify "Conversation Completed" (with score)
App->>Server: Send "Conversation Passed" Request (User ID, Level ID, Score)
Server->>DB: Check Progress: Has User Finished 70% Conversations at Level?
DB->>Server: Return User's Level Progress Data
alt User Finished 70%+ Conversations at Level
Server->>Server: Verify Last Conversation Passed (Score Threshold Check)
alt Passed the Last Conversation
Server->>App: Return "Level Up Eligible" Response
App->>User: Show "Congratulations! You have leveled up." Popup
Server->>DB: Update User Level (Increment Level, Unlock Next Level Lessons)
DB->>Server: Confirm Level Update & Lesson Unlocking
Server->>App: Send New Level Data (Unlocked Lessons List)
App->>User: Unlock Next Level Lessons in UI
App->>User: Start New Lessons at Next Level Automatically
else Not Passed (Alternative Flow 2a)
Server->>App: Return "Level Up Not Eligible: Conversation Failed"
App->>User: Show Notification: "Keep practicing! You didn't pass this conversation."
Note over App,User: User stays at the same level, no lessons unlocked
end
else Not Finished 70% Conversations
Server->>App: Return "Level Up Not Eligible: Incomplete Level Progress"
App->>User: Show Message: "Finish more conversations to level up!"
Note over App,User: User stays at the same level, no lessons unlocked
end
%% Post-Condition
Note over User,App: Post-condition: User accesses new lessons at the next level
Let me walk you through the decisions made in this sequence diagram:
Participants:
User: Interacts with the app and the virtual teacher.
App (Mobile App): The frontend where the user sees feedback and UI updates.
Server (Application Server): Handles logic like progress tracking, level validation, and DB updates.
DB (Database): Stores user progress, level details, and lesson unlock status.
VirtualTeacher (Virtual Teacher Service): Manages real-time conversations and scores the user's performance.
Pre-condition:
The user at the current level (e.g., 10/10 conversations done).
User
UC-14: Select Virtual Teacher
Use Case UC-15
Use case name Select Virtual Teacher
Description User selects a different Virtual Teacher to personalize their learning experience.
Actor(s) User
Priority Must have
Pre-condition(s) • User is logged in
• Teacher options are available
Basic Flow Step Action
1 Navigates to the “Virtual Teacher Selection” page
2 Displays the list of available virtual teachers
3 Preview the teacher accent
4 Confirms the selection by clicking “Update”
5 Checks the selected teacher
6 Saves the new teacher selection
7 Saves changes
Alternative Flow
Post-Condition(s) • User profile is updated with the selected virtual teacher
• Future lessons will use the new virtual teacher
and keep doing for this usecase
Assistant
Based on the provided Use Case (UC-15: Select Virtual Teacher), I'll create a sequence diagram for you. Here's the result:
sequenceDiagram
actor User
participant App as Mobile App
participant Server as Application Server
participant DB as Database
participant VTService as Virtual Teacher Service
%% Basic Flow
Note over User,App: Pre-condition: User is logged in & teacher options are available
User->>App: Tap "Virtual Teacher Selection" Menu Item
App->>Server: Request Available Virtual Teachers List (Auth Token)
Server->>DB: Fetch Virtual Teacher Profiles (ID, Name, Accent, Avatar)
DB->>Server: Return List of Virtual Teachers
Server->>App: Send Virtual Teachers Data (JSON)
App->>User: Display Virtual Teacher List with Previews
Note over App,User: Each teacher shows: Name, Accent Sample (Audio), Avatar
User->>App: Preview Teacher Accent (Play Audio Sample)
App->>User: Play Accent Audio for Selected Teacher
User->>App: Select a Virtual Teacher & Tap "Update"
App->>Server: Send Update Request (User ID, Selected Teacher ID)
Server->>DB: Validate Teacher ID & User Permissions
Server->>DB: Update User Profile with New Teacher ID
DB->>Server: Confirm Profile Update
alt Update Successful
Server->>App: Return Success Response (Updated Teacher Details)
App->>User: Show Confirmation: "Virtual Teacher updated to [Name]!"
App->>User: Start Using New Virtual Teacher in Next Lesson
else Update Fails (Alternative Flow)
Server->>App: Return Error (e.g., "Teacher Unavailable" or "DB Error")
App->>User: Show Error Message: "Failed to update teacher. Try again."
Note over App,User: User remains with the previous virtual teacher
end
%% Post-Condition
Note over User,App: Post-condition: User profile updated, future lessons use new virtual teacher
Let me walk you through the decisions made in this sequence diagram:
Participants:
User: Interacts with the app to change their virtual teacher.
App (Mobile App): The frontend UI where the user browses and selects teachers.
Server (Application Server): Handles requests, validates data, and updates the database.
DB (Database): Stores user profiles, virtual teacher details, and mappings.
VTService (Virtual Teacher Service): Not directly involved in this flow (assumed to fetch audio samples offline).
Pre-condition:
The user is logged in (auth token is included in requests).
Virtual teacher options are available in the system (e.g., 5–10 teacher profiles exist in the DB).
User
UC-15: Translate Conversation Text
Use Case UC-16
Use case name Translate Conversation Text
Description User translates a message during an ongoing conversation with the Virtual Teacher to better understand the content.
Actor(s) User, Virtual Teacher
Priority Good to have
Pre-condition(s) • User is in an active conversation
• A message from Virtual Teacher is displayed
• Translate feature is enabled
Basic Flow Step Action
1 Taps the "Translate" button next to the message
2 Detects the original language of the message
3 Translates the message into the user's preferred language
4 Displays the translated text below the original message
Alternative Flow 3a (If translation fails) shows an error message “Translation not available.”
4a Chooses to retry or continue the conversation without translation
and for this
Assistant
Based on the provided Use Case (UC-16: Translate Conversation Text), I'll create a sequence diagram for you. Here's the result:
sequenceDiagram
actor User
participant App as Mobile App
participant Server as Application Server
participant TranslationService as Google/Microsoft Translation API
participant VirtualTeacher as Virtual Teacher Service
%% Basic Flow
Note over User,App: Pre-condition: User is in an active conversation with Virtual Teacher
VirtualTeacher->>App: Send Message in Original Language (e.g., "Bonjour, comment ça va?")
App->>User: Display Virtual Teacher's Message
User->>App: Tap "Translate" Button Next to the Message
App->>Server: Request Translation (Message Text, User's Preferred Language)
Note over App,Server: Preferred Language stored in User Profile (e.g., "en" for English)
Server->>TranslationService: Detect Original Language & Translate Text
TranslationService->>Server: Return Translated Text (e.g., "Hello, how are you?")
alt Translation Successful
Server->>App: Send Translated Text (Original Language + Translated Text)
App->>User: Display:
1. Original Message: "Bonjour, comment ça va?" (French)
2. Translated Text: "Hello, how are you?" (English)
Note over App,User: Translated text shown below the original message with a subtle label ("Translated to English")
else Translation Fails (Alternative Flow 3a)
TranslationService->>Server: Return Error (e.g., "Language pair not supported")
Server->>App: Send Error Response: "Translation not available."
App->>User: Show Error Message: "Translation not available. Try again?"
alt User Chooses to Retry (4a)
User->>App: Tap "Retry"
App->>Server: Re-send Translation Request
Note over App,Server: Retry logic with exponential backoff (e.g., wait 1s, then 2s, then 4s)
else User Continues Without Translation (4a)
User->>App: Tap "Continue"
App->>User: Hide Translation Error & Focus on Conversation
Note over App,User: Conversation continues without translation feature
end
end
%% Post-Condition
Note over User,App: Post-condition: User understands the message in their preferred language
Let me walk you through the decisions made in this sequence diagram:
Participants:
User: Interacts with the app during a conversation.
Server (Application Server): Bridges the app with the translation service.
TranslationService (Google/Microsoft Translation API): Detects language and translates text.
VirtualTeacher (Virtual Teacher Service): Sends messages in the original language (e.g., French, Spanish).
User
Let's take all information You have been given to me, you need to generate for me the description of each sequence.
Assistant
Based on the sequence diagrams I created for the 7 Use Cases (UC-12 to UC-16), I'll provide a detailed description of each sequence diagram. These descriptions explain the flow, decisions, and interactions in a narrative format.
UC-12: Review Past Conversations
Sequence Diagram Description:
This sequence outlines how a user reviews their past lesson conversations in the app. The flow ensures the user can reflect on previous interactions with the Virtual Teacher.
Initialization:
The user, already logged in and having completed at least one lesson, taps the "Lesson History" button in the app. This action triggers the app to send a request to the server (App → Server: Request Lesson History), including the user's authentication token for validation.
Fetching Lesson History:
The server (Server) receives the request and queries the server's database (DB) to fetch the list of completed lessons for the authenticated user. The database responds with lesson details (e.g., lesson IDs, names, timestamps).
Displaying Lesson History:
The server sends the lesson history data back to the app (Server → App), which renders the list in the UI (e.g., a scrollable list of lessons like "French Basics" or "Spanish Verbs").
The user selects a lesson from the list, triggering the app to request conversation details for that specific lesson (App → Server: Request Conversation Details).
Fetching Conversation Details:
The server queries the database again (Server → DB) to retrieve all conversation parts (messages, timestamps, speaker roles) for the selected lesson.
Example data:
Displaying Conversation:
The server sends this data to the app (Server → App), which renders the conversation in a chat-like interface. The user can now scroll through and review their past interactions.
Server -> DB: Fetches completed lessons for the authenticated user (e.g., SELECT * FROM lessons WHERE user_id = ? AND status = 'completed').
DB -> Server: Returns the list of lessons (e.g., lesson IDs, names, timestamps).
Server -> App: Sends the lesson history data (e.g., JSON response).
App -> User: Displays the list in the UI (e.g., a RecyclerView or ListView).
User picks a lesson, and the app requests conversation details from the server (sending lesson_id and the auth_token).
The server queries the DB for parts of the conversation (e.g., messages, timestamps, speaker roles).
The DB responds with conversation data (e.g., [{ "speaker": "user", "text": "Hello", "timestamp": "12:34" }, ...]).
The server forwards this to the app, which renders it (e.g., a chat-like interface).
Alternative Flow (4a: No History):
If the DB returns no records (i.e., [] or null), the server responds with a "No Data" status (e.g., HTTP 204 or a { "data": null } JSON object).
The app interprets this and shows a friendly message: "No lesson history found."
The user acknowledges (taps "OK" or "Back"), and the app navigates back to the lesson list (or home screen).
Post-Condition:
The final note highlights that the user successfully reviewed their past lesson conversations, fulfilling the use case goal.
Key Assumptions:
Authentication: The auth token is validated by the server silently (not shown as a separate step for brevity). If the token is invalid, the server would return an 401 Unauthorized response, and the app would redirect the user to the login screen (not covered in this flow).
Data Format: Responses from the server are assumed to be JSON. For example:
If the DB update fails (e.g., due to a conflict), the Server retries or returns an error (e.g., "Try again later").
Network failures between App and Server show a "Sync failed. Retry?" dialog.
Example JSON Responses:
// Server → App: Level Up Eligible
{
"status": "level_up",
"new_level": 4,
"message": "Congratulations! You have leveled up.",
"unlocked_lessons": [
{ "id": 11, "name": "Level 4 - Part 1" },
{ "id": 12, "name": "Level 4 - Part 2" }
]
}
// Server → App: Level Up Not Eligible (Failed Conversation)
{
"status": "fail",
"message": "Keep practicing! You didn't pass this conversation.",
"next_attempt": "Retry Lesson 10"
}
// Server → App: Incomplete Progress
{
"status": "incomplete",
"message": "Finish more conversations to level up!",
"progress": "7/10 conversations completed"
}
Optional Enhancements:
Add Gamification: Show stars, badges, or XP points alongside the "Level Up" message.
Motivational Quotes: Display random quotes (e.g., "Your hard work is paying off!") on level-up success.
Analytics: Track "Level Up" events in the backend for insights (e.g., "How many users level up within 1 week?").
This sequence diagram covers the Must-Have logic for UC-14. Let me know if you'd like adjustments (e.g., adding caching, WebSocket updates, or Firebase notifications)! 😊
Basic Flow:
User Opens Teacher Selection Page:
User taps "Virtual Teacher Selection" in the app menu.
The App sends a request to the Server to fetch the list of available virtual teachers (e.g., GET /virtual-teachers with Authorization: Bearer <token>).
Server Retrieves Teacher Data:
The Server queries the DB for teacher profiles:
Fetches teacher_id, name, accent_description, avatar_url, and accent_audio_sample_url (pre-recorded audio clips).
Invalid auth tokens: Redirect user to login screen.
Optional: Real-Time Features:
If you want live teacher availability status (e.g., "Teacher offline"), integrate WebSockets or Firebase Messaging.
Example UI Screens:
Teacher Selection List:
Avatar
Name
Accent
Action
👸
Luna (British)
UK English
✅ Preview
😎
Mateo (American)
US English
✅ Preview
🌸
Sakura (Japanese)
JP English
✅ Preview
Accent Preview:
User taps "Preview" → Plays 5-second audio: "Hello! I'm Mateo, your new virtual teacher."
Confirmation Dialog:
"Switch to Mateo (American)?" → Cancel / Update
Nice-to-Have Enhancements:
Teacher Ratings & Reviews:
Add ⭐️ ratings (e.g., 4.5/5) and user testimonials below each teacher profile.
Recommended Teachers:
Algorithm suggests teachers based on the user's learning history (e.g., "Users who chose Luna also liked Sakura").
Teacher Specialties:
Tag teachers (e.g., "Luna: Expert in Pronunciation", "Mateo: Great for Business English").
Undo/Reset Option:
Allow users to revert to their previous teacher within 24 hours.
This sequence diagram covers the Must-Have flow for UC-15. Let me know if you'd like tweaks (e.g., adding caching, push notifications for teacher updates, or A/B testing for teacher recommendations)! 😊
Pre-condition:
The user is in an active conversation with the Virtual Teacher.
A message from the Virtual Teacher is displayed in the chat UI.
The "Translate" feature is enabled (configurable via app settings or server flags).
Basic Flow:
Virtual Teacher Sends a Message:
VirtualTeacher → App: Sends text (e.g., "Bonjour, comment ça va?" in French).
App → User: Displays the message in the chat bubble.
User Requests Translation:
User taps the "Translate" button next to the message.
App → Server: Sends translation request with:
Message text: "Bonjour, comment ça va?"
Target language: User's preferred language (e.g., "en" for English, stored in their profile).
Server Calls Translation API:
Server → TranslationService: Request includes:
Text: "Bonjour, comment ça va?"
Target language: "en"
Optional: Original language hint (if known, e.g., "fr").
The TranslationService:
Detects the original language (if not provided).
Translates the text (e.g., to "Hello, how are you?").
Translated Text is Displayed:
TranslationService → Server: Returns translated text with metadata (e.g., detected source language).
Server → App: Forwards the response:
{
"original_text": "Bonjour, comment ça va?",
"original_language": "fr",
"translated_text": "Hello, how are you?",
"target_language": "en"
}
App → User: Renders both texts:
Original: "Bonjour, comment ça va?" (French)
Translated: "Hello, how are you?" (English)
Labeled subtly: "Translated to English".
Alternative Flow (Translation Fails):
TranslationService Returns Error:
Scenarios:
Unsupported language pair (e.g., Kurdish to Swahili).
Quota exceeded (e.g., too many requests to the API).
Network timeout.
Response example:
{
"error": "Language pair not supported",
"code": 400
}
Server → App: Forwards the error message: "Translation not available."
User Sees Error & Decides:
App → User: Displays:
Error message: "Translation not available. Try again?"
Two buttons: "Retry" / "Continue".
If "Retry":
User taps "Retry".
App → Server: Re-sends the translation request.
Retry logic: Server waits (e.g., 1s, 2s, 4s) before retrying (to avoid API rate limits).
If "Continue":
User taps "Continue".
App: Hides the translation error and focuses back on the conversation.
No further translation attempts.
Post-Condition:
The user understands the Virtual Teacher's message in their preferred language.
If translation succeeded, the conversation continues with both original and translated text visible.
If translation failed, the user either retries or continues without translation.
Key Assumptions:
Translation API:
Uses Google Cloud Translation API or Microsoft Azure Translator.
Supports ~100 languages (check API docs for limitations).
User Language Preferences:
Stored in the user_profile table (e.g., user.language_preference = "en").
Editable in app settings (e.g., "Change Language" menu).
Error Handling:
Rate limits: If the API returns 429 Too Many Requests, the server retries after a delay.
Invalid text: If translation fails due to gibberish input, show "Could not understand the message."
Example UI States:
Before Translation:
Virtual Teacher Message: "Bonjour, comment ça va?" 🗣️ Translate
After Successful Translation:
Virtual Teacher Message: "Bonjour, comment ça va?" (French) "Hello, how are you?" (Translated to English) 🗣️
Translation Error:
Virtual Teacher Message: "Bonjour, comment ça va?" ⚠️ Translation not available. Try again?
🔄 Retry 🔹 Continue
Nice-to-Have Enhancements:
Real-Time Translation:
Use WebSockets: Translate text as the Virtual Teacher speaks (like Google Meet live captions).
Multi-Language Support:
Allow users to switch languages on the fly (e.g., English ⇄ Spanish during the same convo).
TTS (Text-to-Speech):
Add a 🔊 button: "Listen to translation" (uses device TTS or API-driven audio).
History of Translations:
Save translated messages in the chat history (e.g., labeled "Translated on Nov 10, 2024").
User Feedback Mechanism:
⭐️ Rate translations (e.g., "Was this translation helpful? Yes/No") to improve the API.
This sequence diagram covers the Good-to-Have feature for UC-16. Let me know if you'd like adjustments (e.g., adding caching for frequently translated phrases, offline translation support, or A/B testing for different translation engines)! 😊
Alternative Flow (No Lesson History):
If the database returns no completed lessons (DB → Server: []), the server informs the app (Server → App: "No Data").
The app displays: "No lesson history found."
The user taps "OK" or "Back", and the app navigates back to the lesson list.
Post-Condition:
The user has successfully reviewed their past lesson conversations, fulfilling the use case goal. The app remains in the "Lesson History" screen unless the user exits.
UC-13: Level Up After Completion
Sequence Diagram Description:
This sequence handles the level-up logic when a user completes all required conversations at their current level. It ensures gamified progression in the app.
Trigger: Last Conversation Finished:
The user concludes their last conversation at the current level (e.g., Level 3).
The VirtualTeacher service notifies the app (VirtualTeacher → App: "Conversation Completed"), including the user's score (e.g., 85%).
Progress Check:
The app forwards this data to the server (App → Server: "Conversation Passed"), which queries the database (Server → DB) to check the user's overall progress:
Has the user finished ≥70% of conversations at this level? (e.g., 7/10 conversations done).
Level-Up Eligibility:
The database responds with the user's progress (DB → Server).
If 70%+ conversations are completed AND the last conversation is PASSED (score threshold met):
The server marks the user as eligible to level up.
The app shows: "Congratulations! You have leveled up." (celebratory popup).
Level Update & Lesson Unlocking:
The server updates the database (Server → DB):
Increments the user's level (e.g., Level 3 → Level 4).
Unlocks next level lessons (e.g., sets is_locked: false for Lessons 11–15).
New Level Data Sent:
The server responds to the app (Server → App) with:
{
"new_level": 4,
"message": "Congratulations! You have leveled up.",
"unlocked_lessons": [
{ "id": 11, "name": "Level 4 - Part 1" },
{ "id": 12, "name": "Level 4 - Part 2" }
]
}
The app updates the UI:
Unlocks Level 4 lessons (changes "Locked" labels to "Start").
Automatically starts Lesson 11 (first lesson of Level 4).
Alternative Flows:
Failed Last Conversation:
If the user's score is below the threshold (e.g., 45%), the server returns:
{ "status": "fail", "message": "Keep practicing! You didn't pass this conversation." }
The app shows this message, and no level update occurs.
Incomplete Progress:
If the user has only completed 5/10 conversations (<70%), the server responds:
{ "status": "incomplete", "message": "Finish more conversations to level up!" }
The user stays at the current level.
Post-Condition:
The user progresses to the next level, accesses new lessons, and continues learning. If level-up fails, they continue practicing at the same level.
UC-14: Select Virtual Teacher
Sequence Diagram Description:
This sequence lets the user personalize their learning experience by selecting a different Virtual Teacher (e.g., switching from a British accent to an American accent).
User Opens Teacher Selection:
The user, already logged in, taps "Virtual Teacher Selection" in the app menu.
The app requests the list of available Virtual Teachers from the server (App → Server: Get Virtual Teachers).
Fetching Teacher Profiles:
The server queries the database (Server → DB) for teacher details:
The server forwards this data to the app (Server → App), which renders the teacher list in the UI.
Previewing Accents:
The user taps "Preview" next to a teacher (e.g., Luna).
The app streams the accent audio sample directly from the CDN (e.g., https://cdn.vt/british.mp3). No server interaction occurs here; it's a direct client-side action.
Selecting a Teacher:
The user chooses a teacher (e.g., Mateo) and taps "Update".
The app sends the selection to the server (App → Server: Update Teacher ID), including:
user_id
new_teacher_id (e.g., 2 for Mateo).
Updating User Profile:
The server validates the teacher ID (exists and is active) and updates the user's profile in the database (Server → DB).
Example DB update: UPDATE users SET virtual_teacher_id = 2 WHERE user_id = 123.
In both cases, the user's previous teacher remains active.
Post-Condition:
The user's profile is updated with the new Virtual Teacher, and all future lessons use this teacher's voice and style.
UC-15: Translate Conversation Text
Sequence Diagram Description:
This sequence enables the user to translate messages from the Virtual Teacher during an active conversation, ensuring better understanding of the content.
Virtual Teacher Sends Message:
The VirtualTeacher service sends a message in the original language (e.g., "Bonjour, comment ça va?" in French).
The app displays this message in the chat UI.
User Requests Translation:
The user taps the "Translate" button next to the message.
The app sends a translation request to the server (App → Server: Translate Text), including:
Message text: "Bonjour, comment ça va?"
Target language: User's preferred language (e.g., "en" for English, stored in their profile).
Translation API Call:
The server forwards the request to the Translation Service (e.g., Google Translate/Microsoft Translator):
Detects the original language (if not provided).
Translates the text to the target language.
Translation Response:
The Translation Service returns:
{
"original_text": "Bonjour, comment ça va?",
"original_language": "fr",
"translated_text": "Hello, how are you?",
"target_language": "en"
}
The server relays this data to the app.
Display Translated Text:
The app renders both texts:
Original: "Bonjour, comment ça va?" (French)
Translated: "Hello, how are you?" (English)
Labeled as: "Translated to English".
Alternative Flow (Translation Fails):
If the Translation Service returns an error (e.g., unsupported language pair or quota exceeded):
{ "error": "Language pair not supported", "code": 400 }
The server informs the app, which shows:
"Translation not available. Try again?"
Retry: Re-sends the translation request (with backoff delay).
Continue: Hides the error and focuses on the conversation.
Post-Condition:
The user understands the Virtual Teacher's message in their preferred language. If translation succeeds, both original and translated texts remain visible in the chat.
Key Observations Across All Sequences:
Modular Design:
Each sequence decouples critical services (e.g., Translation Service, Virtual Teacher Service, DB) for scalability.
The Server acts as the orchestrator, validating requests and bridging services.
Error Handling:
Explicit retry logic (e.g., Translation retries, DB conflicts).