Skip to content

daniel-samson/applepy

Repository files navigation

🍏πŸ₯§ ApplePy

API for a model car shop

Status

CI codecov

Requirements

  • Python 3.10+
  • UV
  • Docker & Docker Compose (for database)

Setup Development Environment

1. Install UV

curl -LsSf https://astral.sh/uv/install.sh | sh
# or on Windows PowerShell:
# irm https://astral.sh/uv/install.ps1 | iex

2. Install Project Dependencies

# Activate virtual environment
source .venv/bin/activate

# Install dependencies and dev tools
uv sync

3. Configure Environment Variables

# Copy the example environment file
cp .env.example .env

# Edit .env with your database configuration
# (Optional: defaults work with docker-compose setup)

4. Start Database

# 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

5. Run the Application

# Run Flask development server
uv run applepy flask

# Server will be available at http://localhost:5000

Running Tests

Default: Transaction Rollback Isolation (Recommended) Tests use the development database with automatic transaction rollback:

make test

Benefits:

  • βœ… 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:

  1. Each test runs within a database transaction
  2. All changes (inserts, updates, deletes) happen in the transaction
  3. At the end of each test, the transaction is rolled back
  4. Development database is restored to its original state
  5. 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:8080

GitHub Actions CI Automatically uses a separate test database service to mirror production-like environment and prevent any CI data from affecting development database.

Other Useful Commands

# 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

Documentation

About

🍏πŸ₯§ API for a model car shop

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages