Application for public usage statistics pages on arXiv.org. stats/ contains the Flask backend and stats-ui/ contains the React frontend.
- Install Docker
- Set environment variables
- Set database connection
- Run
make upto build and run bothstatsandstats-ui. SeeMakefilefor additional lifecycle commands.
- Install uv
- Install Python - see
pyproject.tomlfor current version; useuvif you prefer - Install Node - see
package.jsonfor current version - Set environment variables
- Set database connection
- Install and run
statsuv sync uv run python stats/factory.py - Install and run
stats-uicd ../stats-ui npm install npm run start
NOTE: If you would like to use different ports and are running via Docker, make sure you also update the FE_PORT and BE_PORT in the Makefile.
Non-sensitive constants are declared in stats_api.config. The appropriate config is chosen based on the value of the ENV environment variable - TEST, DEV, or PROD.
Other variables may be set in a .env file or in your local environment (i.e. your shell or terminal session). If running locally with Docker, other variables must be set in an .env file.
In remote environments, both non-sensitive and sensitive variables are declared in the service.yaml and injected at runtime.
-
If using a
.envfile, create a file named.envinstats/ -
Set the following variables in that file or in your local environment
ENV={environment} DEV_DATABASE_URI=postgresql+pg8000://{username}:{password}@{host}:{port}/latexmldbThe database URI for the development
latexml-dbdatabase can be found in GCP Secret Manager.The host you set in the URI should point to your local database proxy. If running via Docker, set the host to
host.docker.internal.
- Authenticate to GCP (only needed once)
gcloud auth login - Run the proxy server locally
Your host address will be this network (
cloud-sql-proxy --address {host} --port {port} {account}:{region}:{db_name}0.0.0.0) or localhost (127.0.0.1). Choose any open port.