Development Setup¶
Guide for setting up a mockapi-server development environment.
Quick Start¶
git clone https://github.com/sudzxd/mockapi-server
cd mockapi-server
make dev
make hooks-install
make check
Prerequisites¶
- Python 3.11 or higher
- Git
- Make (pre-installed on macOS/Linux)
Environment Setup¶
Using uv (Recommended)¶
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # macOS/Linux
# or
.venv\Scripts\activate # Windows
uv pip install -e ".[dev]"
Using pip¶
Pre-commit Hooks¶
Install hooks to run checks before each commit:
Hooks run automatically on git commit. Manual run:
Verify Setup¶
All commands should pass.
Makefile Commands¶
| Command | Description |
|---|---|
make dev | Install all dependencies |
make test | Run tests with coverage |
make lint | Run linter |
make lint-fix | Fix lint issues |
make format | Format code |
make type-check | Type checking |
make check | Run all quality checks |
make quick | Fast check (lint + tests) |
make pre-commit | Pre-commit checks |
make ci | CI pipeline simulation |
make clean | Remove build artifacts |
make run | Run example server |
make benchmark | Run benchmarks |
make help | Show all commands |
Project Structure¶
mockapi-server/
├── mock_api/ # Source code
│ ├── cli/ # CLI commands
│ ├── core/ # Core logic
│ ├── integrations/ # External integrations
│ └── utils/ # Utilities
├── tests/ # Test suite
├── docs/ # Documentation
├── examples/ # Example projects
└── pyproject.toml # Project configuration
Development Workflow¶
- Create feature branch off
develop - Make changes following the guidelines
- Run checks:
make check - Commit:
git commit -m "feat: add feature" - Push and create PR:
gh pr create --base develop
VS Code Setup¶
Recommended extensions:
- Python (ms-python.python)
- Pylance (ms-python.vscode-pylance)
- Ruff (charliermarsh.ruff)
Settings (.vscode/settings.json):
{
"python.defaultInterpreterPath": "${workspaceFolder}/.venv/bin/python",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true
},
"python.testing.pytestEnabled": true
}
Common Tasks¶
Add New Dependency¶
Run Local Server¶
make run # Runs basic example
# or
mockapi-server serve --models examples/blog/models.py --generate-data --reload
Clean Build Artifacts¶
View Project Info¶
Getting Help¶
- Check guidelines
- Read testing guide
- Review existing code
- Open GitHub Issues