API for a model car shop
- Python 3.10+
- UV
- Docker & Docker Compose (for database)
curl -LsSf https://astral.sh/uv/install.sh | sh
# or on Windows PowerShell:
# irm https://astral.sh/uv/install.ps1 | iex# Activate virtual environment
source .venv/bin/activate
# Install dependencies and dev tools
uv sync# Copy the example environment file
cp .env.example .env
# Edit .env with your database configuration
# (Optional: defaults work with docker-compose setup)# Start MariaDB/MySQL via Docker (includes both development and test databases)
docker compose up -d
# This starts:
# - db: Development database (applepy) on port 3306
# - db_test: Test database (applepy_test) on port 3307
# - adminer: Web interface for database management on http://localhost:8080
# Run database migrations
uv run applepy db:migrate# Run Flask development server
uv run applepy flask
# Server will be available at http://localhost:5000Default: Transaction Rollback Isolation (Recommended) Tests use the development database with automatic transaction rollback:
make testBenefits:
- β No additional setup needed
- β Fastest test execution
- β Complete test isolation via transaction rollback
- β No test data persists to development database
- β
Works with
docker compose up -d
How it works:
- Each test runs within a database transaction
- All changes (inserts, updates, deletes) happen in the transaction
- At the end of each test, the transaction is rolled back
- Development database is restored to its original state
- Zero test data pollution
Separate Test Database (Optional - Manual Testing) If you want to use the separate test database for manual testing:
# The db_test service runs on port 3307 with applepy_test database
# Access via: mysql -h localhost -P 3307 -u root -p
# Inspect via Adminer: http://localhost:8080GitHub Actions CI Automatically uses a separate test database service to mirror production-like environment and prevent any CI data from affecting development database.
# Run type checking and linting
make check
# Format code
make format
# Build documentation
uv run mkdocs serve
# View all CLI commands
uv run applepy --help