Vigtra Backend is a reimagined implementation of the openIMIS project, tailored to align with my personal vision for health insurance management systems. This project is built with respect and appreciation for the openIMIS community and their contributions to open-source healthcare solutions.
Vigtra aims to provide a robust, scalable, and user-friendly backend for managing health insurance processes. It is designed to support healthcare providers, insurers, and beneficiaries by streamlining operations and improving accessibility.
- Policy Management: Create, update, and manage health insurance policies.
- Claims Processing: Efficient handling of claims with automated workflows.
- Insuree Management: Maintain detailed records of insurees and their coverage.
- Family Management: Advanced family membership tracking with relationship management.
- Reporting and Analytics: Generate insightful reports to aid decision-making.
- GraphQL API: Modern GraphQL API with comprehensive mutation and query support.
- Audit Trail: Complete change logging for compliance and debugging.
- Customizable Workflows: Adapt the system to meet specific organizational needs.
- Backend Framework: Django 4.x with Python 3.8+
- Database: PostgreSQL (production) / SQLite (development)
- API: GraphQL with Graphene-Django
- Authentication: JWT (JSON Web Tokens)
- Caching: Redis (production) / In-memory (development)
- Task Queue: Celery with Redis broker
- Logging: Structured logging with rotation and environment-aware configuration
- Python 3.10 or higher
- PostgreSQL 12+ (for production)
- Redis 6+ (for caching and task queue)
- Virtual environment tool (venv, virtualenv, or uv)
-
Clone the repository:
git clone git@github.com:Legacy-Engineers/vigtra_backend.git cd vigtra_backend -
Set up environment and install dependencies:
# Using uv (recommended) uv sync # Or using traditional pip python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install poetry poetry install
-
Configure environment variables:
cp .env.example .env # Edit .env with your specific settings -
Run database migrations:
python manage.py migrate
-
Create a superuser (optional):
python manage.py createsuperuser
-
Start the development server:
python manage.py runserver
Or use the Makefile:
make # to run server
The application supports multiple environments through the ENVIRONMENT variable:
- Development:
ENVIRONMENT=development(default) - Testing:
ENVIRONMENT=testing - Staging:
ENVIRONMENT=staging - Production:
ENVIRONMENT=production
The application supports multiple database engines:
# SQLite (development default)
DB_ENGINE=sqlite
# PostgreSQL (recommended for production)
DB_ENGINE=postgresql
DB_NAME=vigtra_db
DB_USER=vigtra_user
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432Multiple cache backends are supported:
# Redis (recommended)
CACHE_BACKEND=redis
CACHE_URL=redis://localhost:6379/1
# Memcached
CACHE_BACKEND=memcached
CACHE_URL=memcached://localhost:11211
# Development (no caching)
CACHE_BACKEND=dummy# Run all tests
python manage.py test
# Run specific app tests
python manage.py test modules.insuree
### Code Quality
```bash
# Format code
black .
# Check linting
flake8 .
# Type checking
mypy .# Create migrations
python manage.py makemigrations
# Apply migrations
python manage.py migrate
# Reset database (development only)
python manage.py flush
# Create cache table (if using database cache)
python manage.py createcachetableENVIRONMENT=production
DEBUG=false
SECRET_KEY=your-super-secure-secret-key
JWT_SECRET_KEY=your-jwt-secret-key
# Database
DB_ENGINE=postgresql
DB_NAME=vigtra_prod
DB_USER=vigtra_user
DB_PASSWORD=secure_password
DB_HOST=your-db-host.com
# Cache
CACHE_BACKEND=redis
CACHE_URL=redis://your-redis-host:6379/1
# Security
SECURE_SSL_REDIRECT=true
SESSION_COOKIE_SECURE=true
CSRF_COOKIE_SECURE=trueLogs are automatically organized by environment:
- Development: Console + file logging with debug information
- Production: Structured JSON logs with rotation
- Files: Located in
logs/directorydebug.log: All debug informationerror.log: Warnings and errors onlydjango.log: Django framework logsvigtra.log: Application-specific logs
# Database health check
python manage.py check --database
# Cache health check
python manage.py shell -c "from django.core.cache import cache; print('Cache OK' if cache.get('test') is not None or cache.set('test', 'ok') is None else 'Cache Failed')"-
Virtual environment not found
python -m venv venv source venv/bin/activate -
Module import errors
# Check PYTHONPATH export PYTHONPATH="${PYTHONPATH}:$(pwd)"
-
Database connection errors
# Check database settings in .env # Ensure database server is running
-
Permission errors in production
# Check file permissions chmod +x manage.py chown -R www-data:www-data /path/to/project
Enable detailed debugging:
ENVIRONMENT=development
DEBUG=true
LOG_LEVEL=DEBUG
GRAPHQL_DEBUG=trueComprehensive documentation is available in the DOCS/ directory:
- API Documentation: Complete GraphQL API reference with examples
- Testing Guide: Testing strategy, tools, and best practices
- Development Setup: Detailed development environment setup
- GraphQL Endpoint:
http://localhost:8000/graphql/ - GraphiQL IDE:
http://localhost:8000/graphiql/(development only) - Admin Interface:
http://localhost:8000/admin/
The project includes comprehensive test coverage across multiple layers:
# Run all tests
python manage.py test
# Run with coverage
coverage run --source='.' manage.py test
coverage report
# Run specific module tests
python manage.py test modules.insuree
# Run integration tests
python manage.py test tests.integrationThis project is licensed under the GPL-3.0 License.
Special thanks to the openIMIS community for their inspiration and dedication to improving healthcare systems worldwide.
Note: This project is under active development. Features and APIs may change between versions.