# Mathē application

This is the mobile client application for the `Mathē` system. It is an interactive, multiplatform application designed for both **iOS** and **Android** devices. The application is also fully localized in Czech and English.

---

## Features

Mathē is a tutoring-oriented application developed as a research tool to investigate how large language models (LLMs) can support students' academic achievements and to what extent they are capable of providing pedagogically correct guidance and interactive dialogue.  

### Task Generation

The task generation pipeline connects the LLM with the Wolfram Alpha engine to produce mathematics tasks formatted in LaTeX. It currently supports single-choice and true-false question types. Tasks can be generated in both Czech and English.

### Tutoring Chat

The tutoring chat offers a way for students to engage in a Socratic-style dialogue with the LLM. Messages can combine plain text with LaTeX formatting to represent mathematical formulas.

---

The `mathe-application` is organized into several main folders, each responsible for a distinct layer of the mobile application.

### Application

The `application` folder manages communication with backend services and exposes the results and functions to the rest of the app through **Riverpod** state management. It also contains dtos definitions implemented using the **Freezed** package, ensuring structured and type-safe data handling.

### Core

The `core` folder contains foundational elements used throughout the application, including **localization**, **theming**, **routing**, and **reusable widgets**. This folder provides essential infrastructure for building.

### Infrastructure

The `infrastructure` folder defines the client used to communicate with the backend system, implemented using the **Dio** package. It handles network requests, interceptors, and any service-level configurations necessary for external communication.

### Persistence

The `persistence` folder manages local state. Currently, it is used primarily for storing **JWT tokens** required for authentication.

### Presentation

The `presentation` folder contains all screens, screen-specific state management, forms, and widgets unique to individual screens. It defines the user interface and interaction flow for the mobile application, keeping UI logic separated from business and infrastructure logic.

---

## Local Development

This section describes how to set up the mobile client application for local development. The following prerequisites are required:

- **Flutter** (latest stable version compatible with the project)  
- **Platform tooling** for at least one supported platform:  
  - **Android:** Android Studio with Android SDK  
  - **iOS:** Xcode with iOS Simulator
- **Running backend:** The `Mathē` backend must be running locally to provide API access for the mobile application.

1. **Install dependencies**  
    Fetch all project dependencies using Flutter:
    ```bash
    flutter pub get
    ```

2. **Generate models with Freezed**
    Freezed is used for immutable data classes and DTOs. Run the build runner to generate the necessary code:
    ```bash
    flutter pub run build_runner build
    ```

3. **Configure the application and launch**

   - **If using VSCode:**  
     Copy the example configuration file and rename it for development:
     ```bash
     cp config.example.json config.dev.json
     ```
     The application can then be launched directly using the VSCode interface.

   - **If not using an editor with UI integration:**  
     Launch the application from the command line using Flutter, providing the necessary environment variables:
     ```bash
     flutter run \
       --dart-define=MAIN_API_URL=http://localhost:3000/api/v1 \
       --dart-define=MAIN_API_KEY=main-api-key \
       --dart-define=RESEARCH_TEAM_EMAIL=research.team@mathe.com
     ```

After completing this step, the mobile application will start and connect to the local backend, ready for testing and interaction.
