---
# System prepended metadata

title: "App Find –\_Backend"

---

# App Find – Backend
## Find Android application alternatives that require less permissions.

This recommendation engine was developed to help privacy-concerned users to find alternatives for their Android applications. 

## How does it work?

Topic modeling was applied to the application descriptions of about 571k Android applications to create a model that we used to assign topic IDs to applications. These topic IDs group similar applications together.

A single page application (SPA) was developed based on React and Redux, which consumes the metadata and recommendations from the backend. The backend itself is developed in Python and fetches data from a PostgreSQL database that contains all the data needed.

## Functions
-  [x] Search and filter functions to browse for Google Play Store applications
-  [x] Find alternatives on the application detail page that require fewer permissions
-  [x] Compare our recommendation with Google's filtered application recommendations

## Repository Description
This repository contains the backend part of the application. The other parts of the application can be found in other repos:
 
App Find Frontend: https://github.zhaw.ch/neut/appfind-frontend 
App Find Deployment: https://github.zhaw.ch/neut/appfind-deployment
App Find Machine Learning: https://github.zhaw.ch/neut/appfind-machine-learning

## Prerequisites
The backend requires data from the generated model in the repo "App Find Machine Learning". Please make sure the data is available in the folder `/data`.

## Backend Setup
The backend provides the data required for the frontend. It delivers the data for the apps, provides a search and makes our recommendations based on the data of the machine learning model.

All the dependencies should be installed into the virtual environment by running the following command: 

 - `pipenv install`	Installs all dependencies into the virtual environment
 - `flask db upgrade`	Runs migrations on the database, creates all tables defined in models.py
- `python import_data.py` Imports data from /data
- `python reindex.py`	Re-index all apps in elastic search

## APIs

### Get all apps
All apps are fetched from the database. To avoid loading all apps at once, the output is paginated. There are 100 apps displayed per page. The API also offers the possibility to filter apps by genre and sort apps alphabetically, by the number of downloads and number of permissions (with the parameter "order_by). The parameter "page" is used to fetch the data chunks for a page.

**Endpoint:** `/api/v1/apps`

**Parameters:**
 - **genre**
Possible values: any distinct genre from apps table
- **price**
Possible values: Free, Paid
- **order_by**
Possible Values: ORDER_BY_APP_NAME_ASC, ORDER_BY_APP_NAME_DESC, ORDER_BY_DOWNLOADS_ASC, ORDER_BY_DOWNLOADS_DESC, ORDER_BY_PERMISSIONS_ASC, ORDER_BY_PERMISSIONS_DESC
- **page**: 
Possible values: 1 to 5712 (with per_page = 100)
- **per_page**
Possible values: 0 to 100 (max 100)

**Example:** `/api/v1/apps/?page=1&order_by=ORDER_BY_DOWNLOADS_DESC`

### Get app by id
The app is loaded from the database via the ID. If an app is found, all details of the app, recommendations that require fewer permissions, recommendations from Google and other apps by the developer are returned.

**Endpoint:** `/api/v1/apps/{id}`
**Parameters:** None
**Example:** `/api/v1/apps/com.android.chrome`

### Get all genres
This endpoint returns all genres for the genres filter.

**Endpoint:** `/api/v1/apps/genres`

**Parameters:** None

**Example:** `/api/v1/apps/genres`

## Search
The search API offers the possibility to search for applications. The searchable fields are: id, app_name, description, translated_description, genre, publisher_name. The search results are ordered by the descending downloads and the application ratings. 

**Endpoint:** `/api/v1/apps/search/{query}`

**Parameters:**
 - **page**
Possible values: 1 to x (while x is the maximum pages from the query)
- **per_page**
Possible values: 0 to 100 (max 100)

**Example:** /api/v1/apps/search/notes?page=1



