MicroMap is designed to access image (stacks) at different taxonomic levels. The project was initially envisioned for microscopic pollen data, but the long-term goal is to expand its use to other domains, such as medical imagery.
This README is specific to the pollen use case and is intended for users setting up MicroMap for development.
MicroMap consists of three main components:
- Database: A PostgreSQL database stores pollen information in a hierarchical format.
ToDo: Add a description of the database structure/schema. - REST API: The REST API translates user queries made on the MicroMap website into SQL queries that interact with the database. The REST API is implemented using FastAPI.
- MicroMap Website: The website serves as the Graphical User Interface (GUI) and it built with TypeScript. It allows users to query and view pollen images at various taxonomic levels and scroll through 3D image stacks.
The API allows using custom UUID's when posting new database items. If no UUID is given, then a new random UUID will be created and returned.
Before setting up the development environment, ensure the following software is installed:
- Docker: Used to run the PostgreSQL database server.
- DBeaver: Used access the database.
- PyCharm (Community Edition)
- Python 3.9
The .env contains the database and API server configuration. At least set a new database password and API key hash.
An SHA-256 hash for api_key can be calculated with:
from hashlib import sha256
sha256(api_key.encode()).hexdigest()A Docker container includes everything needed to run an application (e.g. runtime, system tools, libraries, and
settings).
To run the PostgreSQL container as configured in docker-compose.yml, change directory to where this file located is and run:
docker-compose --env-file .env up -dWhen run for the first time, the micromap database will be empty. The REST API will create new tables and relations.
It will not attempt to recreate tables already present.
Optionally create and start a Python virtual environment for this project.
Install the requirements for development:
python -m pip install -r micromap-api/requirements.txtInstall the micromap-api package in editable mode:
python -m pip install -e ./micromap-apiRun the webserver using uvicorn:
uvicorn --env-file .env micromap_api.main:appIf successful, the terminal should output a link that can be used in the web browser to access the REST API, for example http://localhost:8000/.
The endpoint /docs, e.g. http://localhost:8000/docs should show the OpenAPI documentation.
Compiling the source code for the website requires the node package manager (npm) and build tools.
In Windows, the node version manager npv can be installed using Chocolatey:
choco install nvmThen restart the shell and install and activate the latest npm version:
nvm install latest
nvm use latestTo install all dependencies defined in package.json, run this command from the micromap-web directory:
npm installAn axios client should be generated using the command below (run from the micromap-web directory). In case the Micromap API is changed, the client should be re-generated.
Note: This requires a running micromap_api webserver. See above.
npm run generate-clientTo compile the tailwind-annotated css, run this command in the micromap-web directory:
npx tailwindcss -i ./src/css/style.css -o ./css/pollenbase.cssYou can add --watch to hot rebuild based on changes in the source files.
To compile the typescript source files to a javascript bundle, run this command in the micromap-web directory:
npx webpackYou can add --watch to hot rebuild based on changes in the source files.
The API address and catalog id are configured in the file config.js in micromap-web.
Use a lightweight static server to serve the website.
npm install -g serve
serve .