跳转到主要内容

前置条件

开始搭建开发环境前,请确保你具备:

Python 3.12+

运行应用所必需

Docker & Docker Compose

用于运行 PostgreSQL 与 Redis

Git

用于版本控制

Code Editor

VS Code、PyCharm 或你偏好的 IDE

快速搭建

1

克隆仓库

git clone https://github.com/thetahealth/mirobody-health.git
cd mirobody-health
2

创建虚拟环境

python3.12 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
3

安装依赖

pip install -r requirements.txt
pip install -e .  # Install in development mode
4

启动服务

docker-compose up -d postgres redis
5

配置

cp config.example.yaml config.yaml
# Edit config.yaml with your settings
6

运行应用

python main.py
服务应启动于 http://localhost:18080

开发工具

.vscode/extensions.json
{
  "recommendations": [
    "ms-python.python",
    "ms-python.vscode-pylance",
    "ms-python.black-formatter",
    "charliermarsh.ruff",
    "tamasfe.even-better-toml",
    "redhat.vscode-yaml"
  ]
}

Code Formatting

# Install development dependencies
pip install black ruff pytest pytest-asyncio

# Format code
black .

# Lint code
ruff check .

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=connect --cov-report=html

# Run specific test file
pytest tests/test_provider_garmin.py

# Run integration tests
pytest -m integration

项目结构

mirobody-health/
├── connect/                 # Provider integrations
│   └── theta/
│       ├── mirobody_garmin_connect/
│       └── mirobody_whoop/
├── tests/                   # Test files
├── config.yaml             # Configuration
├── main.py                 # Application entry point
├── requirements.txt        # Dependencies
└── setup.py               # Package setup

下一步