{"id":44340584,"url":"https://github.com/dkdndes/pybiorythm-django-sqlite-example","last_synced_at":"2026-02-11T12:57:51.606Z","repository":{"id":309380892,"uuid":"1036064575","full_name":"dkdndes/pybiorythm-django-sqlite-example","owner":"dkdndes","description":null,"archived":false,"fork":false,"pushed_at":"2025-08-11T23:48:53.000Z","size":279,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-12T23:29:30.902Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dkdndes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-11T14:01:14.000Z","updated_at":"2025-08-11T23:47:48.000Z","dependencies_parsed_at":"2025-08-11T16:10:49.804Z","dependency_job_id":null,"html_url":"https://github.com/dkdndes/pybiorythm-django-sqlite-example","commit_stats":null,"previous_names":["dkdndes/pybiorythm-django-sqlite-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dkdndes/pybiorythm-django-sqlite-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkdndes%2Fpybiorythm-django-sqlite-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkdndes%2Fpybiorythm-django-sqlite-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkdndes%2Fpybiorythm-django-sqlite-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkdndes%2Fpybiorythm-django-sqlite-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkdndes","download_url":"https://codeload.github.com/dkdndes/pybiorythm-django-sqlite-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkdndes%2Fpybiorythm-django-sqlite-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29333146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T12:42:24.625Z","status":"ssl_error","status_checked_at":"2026-02-11T12:41:23.344Z","response_time":97,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-11T12:57:50.823Z","updated_at":"2026-02-11T12:57:51.598Z","avatar_url":"https://github.com/dkdndes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyBiorythm Django SQLite Integration Example\n\nA complete Django application demonstrating how to integrate the [PyBiorythm](https://github.com/dkdndes/pybiorythm) library with SQLite for biorhythm data storage and management.\n\n## 🌟 Features\n\n- **SQLite Database Integration** with Django ORM\n- **PyBiorythm Library Integration** for real biorhythm calculations\n- **Database Models** for storing biorhythm data, people, and calculations\n- **Django Admin Interface** for data management\n- **Management Commands** for bulk data loading\n- **Comprehensive Data Models** with relationships and validation\n- **Performance Optimized** with database indexes\n\n## 📋 Table of Contents\n\n- [Quick Start](#quick-start)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Database Schema](#database-schema)\n- [Management Commands](#management-commands)\n- [Django Admin](#django-admin)\n- [API Documentation](#api-documentation)\n- [Contributing](#contributing)\n- [License](#license)\n\n## 🚀 Quick Start\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/your-username/pybiorythm-django-sqlite-example.git\n   cd pybiorythm-django-sqlite-example\n   ```\n\n2. **Set up virtual environment and install dependencies**\n   ```bash\n   # Install uv if you haven't already\n   curl -LsSf https://astral.sh/uv/install.sh | sh\n   \n   # Create virtual environment and install dependencies\n   uv venv\n   source .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n   uv sync\n   ```\n\n4. **Run migrations**\n   ```bash\n   uv run python manage.py migrate\n   ```\n\n5. **Create superuser**\n   ```bash\n   uv run python manage.py createsuperuser\n   ```\n\n6. **Load sample data**\n   ```bash\n   uv run python manage.py load_biorhythm_data --name \"Test User\" --birthdate \"1990-01-15\" --days 365\n   ```\n\n7. **Start the development server**\n   ```bash\n   uv run python manage.py runserver\n   ```\n\n8. **Access the application**\n   - Django Admin: http://127.0.0.1:8000/admin/\n   - API: http://127.0.0.1:8000/api/\n\n## 📦 Installation\n\n### Prerequisites\n\n- Python 3.8+\n- [uv](https://github.com/astral-sh/uv) package manager\n\n### Installation with uv\n\n```bash\n# Install uv if you haven't already\ncurl -LsSf https://astral.sh/uv/install.sh | sh\n\n# Create virtual environment and install dependencies\nuv venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\nuv sync\n```\n\n### Dependencies\n\nThis project uses the following key dependencies:\n\n- **Django** 5.2.5+ - Web framework\n- **PyBiorythm** - Real biorhythm calculations from GitHub\n- **django-extensions** - Enhanced Django management commands\n- **python-dateutil** - Date/time utilities\n\n## 💻 Usage\n\n### Basic Usage\n\n1. **Create a person and calculate biorhythms**:\n   ```bash\n   uv run python manage.py load_biorhythm_data --name \"John Doe\" --birthdate \"1985-03-20\" --days 180\n   ```\n\n2. **Access Django Admin** to view and manage data:\n   ```\n   http://127.0.0.1:8000/admin/\n   ```\n\n3. **Query data programmatically**:\n   ```python\n   from biorhythm_data.models import Person, BiorhythmData\n   \n   # Get a person\n   person = Person.objects.get(name=\"John Doe\")\n   \n   # Get their biorhythm data\n   data = BiorhythmData.objects.filter(person=person).order_by('date')\n   \n   # Get critical days\n   critical_days = data.filter(\n       Q(is_physical_critical=True) |\n       Q(is_emotional_critical=True) |\n       Q(is_intellectual_critical=True)\n   )\n   ```\n\n### Advanced Usage\n\n#### Custom Date Ranges\n```bash\nuv run python manage.py load_biorhythm_data \\\n    --name \"Jane Smith\" \\\n    --birthdate \"1992-07-10\" \\\n    --start-date \"2024-01-01\" \\\n    --end-date \"2024-12-31\"\n```\n\n#### Bulk Data Processing\n```bash\n# Load multiple people from a CSV file\nuv run python manage.py load_bulk_biorhythm_data people.csv\n```\n\n## 🗄️ Database Schema\n\n### Models Overview\n\n#### Person Model\nStores individual person information and biorhythm metadata.\n\n```python\nclass Person(models.Model):\n    name = models.CharField(max_length=200)\n    birthdate = models.DateField()\n    email = models.EmailField(blank=True, null=True)\n    created_at = models.DateTimeField(auto_now_add=True)\n    updated_at = models.DateTimeField(auto_now=True)\n```\n\n#### BiorhythmData Model\nStores calculated biorhythm values for specific dates.\n\n```python\nclass BiorhythmData(models.Model):\n    person = models.ForeignKey(Person, on_delete=models.CASCADE)\n    date = models.DateField()\n    days_alive = models.IntegerField()\n    physical = models.FloatField()         # Range: -1.0 to 1.0\n    emotional = models.FloatField()        # Range: -1.0 to 1.0\n    intellectual = models.FloatField()     # Range: -1.0 to 1.0\n    is_physical_critical = models.BooleanField(default=False)\n    is_emotional_critical = models.BooleanField(default=False)\n    is_intellectual_critical = models.BooleanField(default=False)\n```\n\n#### BiorhythmCalculation Model\nTracks calculation metadata and parameters.\n\n```python\nclass BiorhythmCalculation(models.Model):\n    person = models.ForeignKey(Person, on_delete=models.CASCADE)\n    start_date = models.DateField()\n    end_date = models.DateField()\n    days_calculated = models.IntegerField()\n    calculation_date = models.DateTimeField(auto_now_add=True)\n    notes = models.TextField(blank=True)\n```\n\n### Database Indexes\n\nOptimized indexes for common queries:\n- `person_id + date` (composite index)\n- `date` (for date range queries)\n- `is_*_critical` (for critical day lookups)\n\n## 🛠️ Management Commands\n\n### load_biorhythm_data\n\nLoad biorhythm data for a person into the database.\n\n```bash\nuv run python manage.py load_biorhythm_data [OPTIONS]\n```\n\n**Options:**\n- `--name` - Person's name (required)\n- `--birthdate` - Birth date in YYYY-MM-DD format (required)\n- `--days` - Number of days to calculate (default: 365)\n- `--start-date` - Start date for calculations (default: today)\n- `--email` - Person's email address (optional)\n- `--notes` - Calculation notes (optional)\n\n**Examples:**\n```bash\n# Basic usage\nuv run python manage.py load_biorhythm_data --name \"Alice Cooper\" --birthdate \"1988-12-25\"\n\n# With custom parameters\nuv run python manage.py load_biorhythm_data \\\n    --name \"Bob Dylan\" \\\n    --birthdate \"1975-05-15\" \\\n    --days 730 \\\n    --email \"bob@example.com\" \\\n    --notes \"Two year analysis\"\n\n# Specific date range\nuv run python manage.py load_biorhythm_data \\\n    --name \"Carol King\" \\\n    --birthdate \"1990-08-30\" \\\n    --start-date \"2024-01-01\" \\\n    --days 365\n```\n\n### Data Export Commands\n\n```bash\n# Export data to CSV\nuv run python manage.py export_biorhythm_data --person-id 1 --format csv\n\n# Export data to JSON\nuv run python manage.py export_biorhythm_data --person-id 1 --format json\n```\n\n## 👑 Django Admin\n\nThe Django admin interface provides a comprehensive view of all biorhythm data:\n\n### Features\n- **Person Management** - Add, edit, and delete people\n- **Biorhythm Data Browser** - View calculated biorhythm values\n- **Calculation History** - Track all calculations performed\n- **Data Filtering** - Filter by date ranges, people, critical days\n- **Bulk Operations** - Perform batch operations on data\n\n### Admin Customizations\n- **Enhanced List Views** with filtering and search\n- **Custom Actions** for bulk data operations\n- **Inline Editing** for related models\n- **Data Validation** with custom form validators\n\n## 📖 API Documentation\n\n### Models API\n\n#### Person\n```python\n# Create a person\nperson = Person.objects.create(\n    name=\"Example User\",\n    birthdate=\"1990-01-01\",\n    email=\"user@example.com\"\n)\n\n# Query methods\nPerson.objects.get_active_people()\nPerson.objects.with_recent_calculations()\n```\n\n#### BiorhythmData\n```python\n# Get data for a person\ndata = BiorhythmData.objects.filter(person=person)\n\n# Get critical days\ncritical = BiorhythmData.objects.get_critical_days(person=person)\n\n# Get data by date range\nrange_data = BiorhythmData.objects.get_date_range(\n    person=person,\n    start_date=\"2024-01-01\",\n    end_date=\"2024-12-31\"\n)\n```\n\n### Calculation Functions\n\n```python\nfrom biorhythm_data.utils import calculate_biorhythm_range\n\n# Calculate biorhythm for a date range\nresults = calculate_biorhythm_range(\n    birthdate=\"1990-01-01\",\n    start_date=\"2024-01-01\",\n    days=365\n)\n```\n\n## 🔧 Configuration\n\n### Django Settings\n\nKey settings in `biorhythm_storage/settings.py`:\n\n```python\n# Database configuration\nDATABASES = {\n    'default': {\n        'ENGINE': 'django.db.backends.sqlite3',\n        'NAME': BASE_DIR / 'db.sqlite3',\n    }\n}\n\n# PyBiorythm specific settings\nBIORHYTHM_DEFAULT_DAYS = 365\nBIORHYTHM_MAX_DAYS = 3650\nBIORHYTHM_BATCH_SIZE = 1000\n```\n\n### Environment Variables\n\nCreate a `.env` file for local development:\n\n```bash\nDEBUG=True\nSECRET_KEY=your-secret-key-here\nBIORHYTHM_DEFAULT_DAYS=365\nBIORHYTHM_MAX_CALCULATION_DAYS=3650\n```\n\n## 🧪 Testing\n\nRun the test suite:\n\n```bash\n# Run all tests\nuv run python manage.py test\n\n# Run with coverage\nuv run coverage run --source='.' manage.py test\nuv run coverage report\nuv run coverage html  # Generates HTML coverage report\n```\n\n### Test Structure\n- **Model Tests** - Test model methods and validation\n- **Management Command Tests** - Test data loading commands\n- **Admin Tests** - Test admin interface functionality\n- **Integration Tests** - Test PyBiorythm integration\n\n## 📊 Performance Considerations\n\n### Database Optimization\n- **Indexes** on frequently queried fields\n- **Batch Processing** for large data sets\n- **Connection Pooling** for production deployments\n\n### Memory Management\n- **Chunked Processing** for large calculations\n- **Lazy Loading** of related objects\n- **Query Optimization** with `select_related` and `prefetch_related`\n\n## 🐳 Docker Support\n\n### Dockerfile\n```dockerfile\nFROM python:3.12-slim\n\nWORKDIR /app\nCOPY requirements.txt .\nRUN pip install -r requirements.txt\n\nCOPY . .\n\nEXPOSE 8000\nCMD [\"uv\", \"run\", \"python\", \"manage.py\", \"runserver\", \"0.0.0.0:8000\"]\n```\n\n### Docker Compose\n```yaml\nversion: '3.8'\nservices:\n  web:\n    build: .\n    ports:\n      - \"8000:8000\"\n    volumes:\n      - .:/app\n    environment:\n      - DEBUG=1\n```\n\n## 🚀 Deployment\n\n### Production Considerations\n\n1. **Database** - Consider PostgreSQL for production\n2. **Static Files** - Configure static file serving\n3. **Security** - Update SECRET_KEY and security settings\n4. **Performance** - Enable caching and optimization\n\n### Environment Setup\n```bash\n# Production settings\nexport DEBUG=False\nexport SECRET_KEY=\"your-production-secret-key\"\nexport ALLOWED_HOSTS=\"yourdomain.com\"\n\n# Database URL for production\nexport DATABASE_URL=\"postgresql://user:pass@localhost/dbname\"\n```\n\n## 🤝 Contributing\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature/amazing-feature`\n3. Commit your changes: `git commit -m 'Add amazing feature'`\n4. Push to the branch: `git push origin feature/amazing-feature`\n5. Open a Pull Request\n\n### Development Setup\n```bash\n# Install development dependencies\nuv sync --extra dev\n\n# Run tests before committing\nuv run python manage.py test\n```\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🔗 Related Projects\n\n- **[PyBiorythm](https://github.com/dkdndes/pybiorythm)** - Core biorhythm calculation library\n- **[PyBiorythm Django API Server](https://github.com/your-username/pybiorythm-django-api-server-example)** - REST API server example\n- **[PyBiorythm Django Dashboard](https://github.com/your-username/pybiorythm-django-dashboard-example)** - Visualization dashboard example\n\n## 📞 Support\n\n- **Issues**: [GitHub Issues](https://github.com/your-username/pybiorythm-django-sqlite-example/issues)\n- **Discussions**: [GitHub Discussions](https://github.com/your-username/pybiorythm-django-sqlite-example/discussions)\n- **Documentation**: [Wiki](https://github.com/your-username/pybiorythm-django-sqlite-example/wiki)\n\n## 🙏 Acknowledgments\n\n- **PyBiorythm Library** by [dkdndes](https://github.com/dkdndes)\n- **Django Framework** by the Django Software Foundation\n- **Contributors** and community members who helped improve this example\n\n---\n\n**Made with ❤️ for the PyBiorythm community**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkdndes%2Fpybiorythm-django-sqlite-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkdndes%2Fpybiorythm-django-sqlite-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkdndes%2Fpybiorythm-django-sqlite-example/lists"}