An Android app for stroke-based behavioral authentication inspired by Touchalytics.
The app collects vertical swipe behavior from a chat-style interface, stores enrollment samples in Firebase Realtime Database, and uses a local Flask ML server to verify whether a new swipe matches the current user.
This project is a course prototype for touch-based authentication.
Instead of requiring a password or a fingerprint, the app uses how a user swipes on the screen as a behavioral biometric signal.
The current MVP flow is:
- The user enters a numeric User ID
- The user enters the app and navigates to a chat-based interface
- The app collects swipe strokes during normal scrolling
- The first 50 valid strokes are used for enrollment
- After enrollment, new strokes are sent to a local ML server for verification
- The app shows how many results are Match and Not Match
The current MVP is focused on the authentication flow, not on building a full messaging platform.
- Login screen
- numeric User ID input
- Chat list
- list of mock chat partners
- Chat view
- read-only incoming long messages
- designed to allow repeated vertical scrolling for swipe collection
- Enrollment Mode
- shows current user ID
- shows how many strokes have been collected out of 50
- Verification Mode
- shows the number of green Match
- shows the number of red Not Match
The chat content is currently read-only for MVP.
The purpose of the chat view is to provide a natural scrolling surface for swipe collection.
Sending messages is not required for the current version.
- Android Studio
- Kotlin
- Jetpack Compose
- Firebase Realtime Database
- Retrofit
- Local Flask ML server
StrokeUtils.ktfor stroke feature extraction
At the time of writing, this repository contains the Android app module and standard Gradle project files. The repo currently includes:
app/gradle/- top-level Gradle build files
- Firebase config file (
google-services.json) insideapp/:contentReference[oaicite:1]{index=1}
A simplified structure:
TouchAnalytics/
├── app/
│ ├── src/
│ ├── build.gradle.kts
│ ├── google-services.json
│ └── proguard-rules.pro
├── gradle/
├── build.gradle.kts
├── settings.gradle.kts
├── gradle.properties
├── gradlew
├── gradlew.bat
└── README.md
Before running the project, make sure you have:
- Android Studio installed
- A working Android emulator or a physical Android device
- Internet access for Firebase
- A local machine that can run the Flask ML server
- The Android device and the Flask server machine on the same network if using a physical device
This app uses Firebase Realtime Database to store enrollment stroke data.
https://swen-549-touchanalytics-default-rtdb.firebaseio.com/
- Enrollment samples are stored in Firebase under the current numeric user ID
- Firebase must be accessible for enrollment to work correctly
- The project includes a
google-services.jsonfile in theapp/module
This project uses a persistent Flask ML server for verification.
The ML server is hosted on AWS Elastic Beanstalk.
If logcat is encountering an error with hostname on swipe, ensure that the emulator has an active internet connection. Emulator may need to be restarted and cold booted.
This project may also use a local Flask ML server for verification.
5001
The Flask server IP address may change each time the server starts.
Please check the Flask terminal output every time before running the Android app.
Example Flask output:
Running on http://127.0.0.1:5001
Running on http://129.21.40.25:5001
- Do not use
127.0.0.1for a physical Android device - Use the current local network IP shown by Flask, for example:
http://129.21.40.25:5001/
127.0.0.1means "this machine itself"- On a phone,
127.0.0.1refers to the phone, not the laptop/server machine - The Android app must point Retrofit to the current local network IP
The Android app communicates with the Flask ML server using Retrofit.
POST /authenticate/{userID}
This endpoint is used in Verification Mode.
DELETE /delete/{userID}
This endpoint can be used to reset a user's enrollment data and start over.
git clone https://github.com/ZixiongBillLi/TouchAnalytics.git
cd TouchAnalyticsOpen the project folder in Android Studio.
Let Android Studio finish Gradle sync.
If Gradle version issues appear, use the versions configured in the project and make sure Android Studio is using a compatible Android Gradle Plugin / Gradle combination.
Make sure the Firebase Realtime Database is accessible and the Firebase configuration is valid.
Run the local Flask server on your machine.
When it starts, note the current local network IP address and confirm that the server is running on port 5001.
Example:
http://129.21.40.25:5001
If the local IP changes, update the Retrofit base URL in the Android project so it points to the current Flask server address.
Example:
http://129.21.40.25:5001/
If your code stores the base URL in a dedicated file such as RetrofitClient.kt or a network config file, update it there before running the app.
Run the app on:
- an emulator, or
- a physical Android device
If using a physical device:
- the phone and the Flask server machine must be on the same network
- the app must use the current Flask server IP address, not
127.0.0.1
- Launch the app
- Enter a numeric User ID
- Navigate into a chat view
- Scroll repeatedly through the long read-only messages
- Confirm the app shows Enrollment Mode
- Continue until the enrollment count reaches
50
- After enrollment completes, continue scrolling
- Confirm the app switches to Verification Mode
- Verify that the app sends new stroke features to the Flask server
- Check that the UI updates:
- green Match
- red Not Match
- Trigger reset / re-enrollment
- Confirm the user's enrollment data is cleared
- Confirm the app returns to Enrollment Mode
- This is a course prototype / MVP
- The main focus is the touch authentication workflow
- The chat interface is intentionally simple and currently read-only
- The app is not intended to be a full messaging platform in the current version
- The Flask server IP may change between runs, so the local server address may need to be updated before testing
Check:
- Is the Flask server running?
- Is the app using the correct current local IP?
- Are the phone and server on the same network?
- Are you accidentally using
127.0.0.1on a physical device?
Check:
- Has the user already collected at least 50 enrollment samples?
- Is Firebase storing the enrollment data correctly?
- Is the Flask server running on port
5001? - Is the Retrofit base URL correct?
Check:
- Firebase connectivity
- valid stroke capture
- whether the app is successfully saving enrollment data under the current user ID
Check:
- Android Studio version
- Android Gradle Plugin version
- Gradle wrapper version
- compatibility between Android Studio and AGP
Possible future extensions include:
- richer chat data management
- message sending
- more mock users and conversations
- improved reset / re-enrollment flow
- better verification feedback and usability polish
Team members are contributing on separate branches and merging features into main as the project evolves.