This is a CAT to work with texts. Now in experimental stage. Uses Python and FastAPI as a backend library. For a frontend Vue with its stack is used.
To run the backed navigate to backend directory and create virtual
environment:
python3 -m venv .venv
source .venv/bin/activateInstall all dependencies:
pip install -r requirements.txt
python3 -m nltk.downloader punkt_tabThen run FastAPI server:
uvicorn asgi:appYou will need PostgreSQL server running on a local machine. Set up connection
string to the environment variable DATABASE_URL or update settings.py file.
To run tests you need to install pytest and pytest-asyncio packages. They
are already listed in requirements.txt file, so you if you installed all
dependencies from a previous section you are good to go.
It order to run tests you need to run pytest command from the backend
directory.
pytestTo run linting for backend code execute the following command:
ruff format . && ruff check --select I --fix . && ruff check --fix .To run the worker navigate to backend directory and create virtual environment
if not yet:
python3 -m venv.venv
source.venv/bin/activateThen install all dependencies:
pip install -r requirements.txt
python3 -m nltk.downloader punkt_tabThen run the worker:
python3 worker.pyThe worker is being tested by the same test suite as the backend.
To run the frontend you need to install all dependencies first. Navigate to
frontend directory and run:
pnpm installThen you can run the development server:
pnpm run devThis will start the development server on localhost:5173 address. Open your
browser and check the website. When development server is run you need to run
backend server as well.
To run frontend's tests you need to run:
pnpm run testBefore setting up the production version you need to adjust environment configs.
To do this copy .env.example to .env and fill in all needed variables.
Also you have to adjust alembic.ini file to match your database settings. It
is located in backend directory.
To run production version of the tool you need to use docker compose:
docker compose up -d --buildYou can have two separate .env files for local testing and for production
deployment. To do this make two copies of .env.template with different names:
.env-local for local testing and .env-prod for production and specify
which file to use by setting --env-file parameter when running docker-compose.
docker compose --env-file .env.prod up -d --buildThis will build all needed images and run services in detached mode. Please
note that reverse proxy is listening to 6916 port on the localhost, so you
need to set up something to listed on the domain name if you need.
The production version is located at https://hat.codecliffs.ru
There is a PGAdmin instance as a container which is set up to automatically
connect to the database in another container. You should run docker compose
with additional profile named debug like this:
docker compose --env-file .env-prod --profile debug up -d --buildAfter everything is running you can access PGAdming instance on http://localhost:8082/ address. It will automatically set up and lets you use it without login and password. This set up might be used to debug database issues or do mundane maintenance tasks without having to use CLI.
Since it is set up to be accessed by anyone who has an access to the server, make sure you've removed a container after doing debugging or limit access to people with such access.