Skip to content

Alicipy/lenzr-server

Repository files navigation

Lenzr Server

This is a simple REST server to host and share images.

Tech Stack

This project is built with

  • Python as the programming language
  • uv as the Python package manager
  • FastAPI as the web framework
  • SQLModel as an ORM
  • alembic for database migrations
  • pytest as the testing framework
  • ruff as a formatter
  • pre-commit for automatic execution of checks

Setup

Configuration

Before starting the server, one needs to configure several options. For that, take the .env.example file and copy it to .env:

cp .env.example .env

Afterward, look into it and modify accordingly.

You at least want to change the username and password for server access.

docker-compose

The easiest way to set up the Lenzr Server is by using docker-compose.

Start the server as a daemon service with

docker compose up -d

It is reachable on port 8000 afterwards.

To stop the server, do

docker compose down

Run manually

Alternatively, you can manually run the server without Docker by executing

uv run fastapi run src/lenzr_server/main.py

This will install all necessary dependencies and start the server locally.

Contributing

This shall be a guide for contributing to the Lenzr Server project.

Installing dev dependencies

At first, install all development dependencies with

uv sync --dev

Activate pre-commit hooks

To automatically run checks when you create a commit, install the hooks:

uv run pre-commit install

You can also run the checks manually with

uv run pre-commit run --all-files

Manual way: Running the server in development

To automatically reload the server on code changes, you can use the following command:

uv run fastapi run --reload src/lenzr_server/main.py

docker-compose way: Running the server in development

You can also use the compose.dev.yaml file for a reloading setup. For that, run

docker compose -f compose.yaml -f compose.dev.yaml up --build

Create Alembic migrations

On a change of the database model, one needs to create a new alembic migration to update already existing databases to the newest state. The simplest solution is to use the proper compose profile create_alembic_migration for that:

docker compose -f compose.yaml -f compose.dev.yaml --profile create_alembic_migration up --build

Running tests

To run the tests, you can use the following command:

uv run pytest

Project management commands

This shall include a list of commands to effectively develop on the project.

Add a new dependency

To add a new dependency, you can use the following command:

uv add <package_name>

This will also update the uv.lock file with the necessary changes.

If the package is only needed for development purposes (like testing or linting), you can add it to the dev group:

uv add --dev <package_name>

Upgrading versions in the uv.lock file

To upgrade the versions of the dependencies in the uv.lock file, you can use the following command:

uv lock --upgrade

About

Lenzr server application to manage images

Resources

License

Stars

Watchers

Forks

Packages