Skip to content

Latest commit

 

History

History
141 lines (102 loc) · 2.42 KB

File metadata and controls

141 lines (102 loc) · 2.42 KB

Development

Snapshot uses a standard Python src/ layout with project metadata and tooling in pyproject.toml.

Setup

PowerShell:

python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

Linux or macOS:

python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

The .[dev] extra installs Snapshot plus Black, Ruff, mypy, Pytest, coverage, and HTTPX.

If you see this:

No module named pytest
No module named ruff

run:

python -m pip install -e ".[dev]"

Run The App

snapshot

Alternative:

python -m uvicorn snapshot.main:app --host 0.0.0.0 --port 3000

Tests

python -m pytest

Formatting

Check formatting:

python -m black --check .

Apply formatting:

python -m black .

Linting

python -m ruff check .

Typechecking

python -m mypy

Full Local Check

python -m black --check .
python -m ruff check .
python -m mypy
python -m pytest
docker compose config --quiet

Docker Storage

The repository Compose file stores uploads in ./data/uploads and writes the generated ShareX config to ./data/snapshot.sxcu. Docker logs are written to stdout/stderr and can be viewed with:

docker compose logs -f
docker compose logs --no-color > snapshot.log

Generate the ShareX config without starting the server:

make config

Versioning

Use Conventional Commits and Python Semantic Release:

semantic-release --noop version --print
semantic-release version
git push --follow-tags

See Versioning.

Package Structure

src/snapshot/
├── api.py          # FastAPI routes and app factory
├── cli.py          # snapshot command
├── config.py       # Pydantic settings
├── constants.py    # App constants and messages
├── errors.py       # API exceptions and error codes
├── log_config.py   # Request-aware logging
├── main.py         # ASGI app entry point
├── rate_limit.py   # In-memory rate limiter
├── schemas.py      # Response models
├── security.py     # Secret comparison
├── storage.py      # Upload storage
└── utils.py        # Small shared helpers