random-access/DEVELOPMENT.md

127 lines
2.4 KiB
Markdown

# Development Setup
## Prerequisites
- Python 3.12 or higher
- Redis server (for caching)
- Git
## Development Installation
1. **Clone and enter the repository:**
```bash
git clone https://github.com/micha-zone/random-access.git
cd random-access
```
2. **Create and activate a virtual environment:**
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. **Install development dependencies:**
```bash
pip install -e .[dev]
```
4. **Set up environment configuration:**
```bash
cp .env.template .env
# Edit .env with your specific configuration
```
5. **Start Redis (if not running):**
```bash
# On Ubuntu/Debian:
sudo systemctl start redis-server
# On macOS with Homebrew:
brew services start redis
# Using Docker:
docker run -d -p 6379:6379 redis:alpine
```
## Development Workflow
### Code Quality Checks
```bash
# Format code
black src/ tests/
isort src/ tests/
# Lint code
ruff check src/ tests/
# Type checking
mypy src/
# Run all quality checks
black src/ tests/ && isort src/ tests/ && ruff check src/ tests/ && mypy src/
```
### Testing
```bash
# Run tests
pytest
# Run tests with coverage
pytest --cov=random_access --cov-report=html
# Run specific test file
pytest tests/test_security.py
```
### Running the Application
```bash
# Development server with auto-reload
random-access-server
# Or with uvicorn directly
uvicorn random_access.main:app --reload --host 0.0.0.0 --port 8000
```
### Building the Package
```bash
# Build source and wheel distributions
python -m build
# Install from local build
pip install dist/random_access-*.whl
```
## IDE Configuration
### VS Code
Recommended extensions:
- Python
- Pylance
- Black Formatter
- isort
- Ruff
### PyCharm
The project includes proper `pyproject.toml` configuration that PyCharm will automatically recognize.
## Troubleshooting
### Common Issues
1. **Redis connection errors**: Ensure Redis is running on localhost:6379
2. **Import errors**: Make sure you've installed the package in development mode (`pip install -e .`)
3. **Permission errors**: Check file permissions and virtual environment activation
### Environment Variables
Key environment variables (see `.env.template`):
- `ENVIRONMENT`: Set to "development" for dev mode
- `REDIS_URL`: Redis connection string
- `AIRTABLE_API_KEY`: Your Airtable API key
- `AIRTABLE_BASE_ID`: Your Airtable base ID