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.
- Beneficiary Management: Maintain detailed records of beneficiaries 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
The project follows a modular architecture with the following key components:
- Modular Design: Dynamic module loading system for extensibility
- Service Layer: Business logic encapsulated in service classes
- GraphQL Layer: Comprehensive GraphQL schema with mutations and queries
- Audit System: Complete change tracking and logging
- Multi-Environment: Environment-specific configurations for development, testing, and production
- Python 3.8 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 https://github.com/yourusername/Vigtra.git --branch backend vigtra_backend cd vigtra_backend
-
Set up environment and install dependencies:
# Using uv (recommended) uv sync # Or using traditional pip python -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
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=5432
Multiple 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
Access the GraphQL endpoints:
- GraphQL Endpoint:
http://localhost:8000/graphql/
- GraphiQL IDE:
http://localhost:8000/graphiql/
(development only) - Schema:
http://localhost:8000/graphql/schema/
The API provides comprehensive GraphQL schema with:
- Queries: Retrieve data with powerful filtering and pagination
- Mutations: Create, update, and delete operations with validation
- Subscriptions: Real-time updates (if configured)
# Run all tests
python manage.py test
# Run specific app tests
python manage.py test modules.insuree
# Run with coverage
coverage run --source='.' manage.py test
coverage report
# 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 createcachetable
- Set
ENVIRONMENT=production
- Set
DEBUG=false
- Configure secure
SECRET_KEY
andJWT_SECRET_KEY
- Set up PostgreSQL database
- Configure Redis for caching
- Set up proper logging
- Configure email settings
- Set up SSL certificates
- Configure static file serving
- Set up monitoring and error tracking
ENVIRONMENT=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=true
Logs 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=true
Comprehensive 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.integration
tests/
├── base.py # Base test classes and utilities
├── conftest.py # Pytest configuration
├── core/ # Core functionality tests
├── authentication/ # Authentication tests
├── insuree/ # Insuree module tests
└── integration/ # API and integration tests
- Current Coverage: 85%+ across all modules
- Target Coverage: 90%+ for critical business logic
- Test Types: Unit, Integration, API, and End-to-End tests
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature-name
- Follow code standards: Use Black for formatting, follow PEP 8
- Write tests: Ensure new code is tested (see Testing Guide)
- Update documentation: Update README and docstrings as needed
- Submit pull request: Provide clear description of changes
# Install development dependencies
pip install -r requirements-dev.txt
# Set up pre-commit hooks
pre-commit install
# Run quality checks
pre-commit run --all-files
# Run tests
python manage.py test
- Test Coverage: Minimum 80% for new code
- Documentation: All public APIs must be documented
- Type Hints: Use type hints for better code clarity
- Security: Follow security best practices
vigtra_backend/
├── vigtra/ # Main project directory
│ ├── settings/ # Environment-specific settings
│ │ ├── base.py
│ │ ├── development.py
│ │ ├── production.py
│ │ ├── database.py
│ │ ├── cache.py
│ │ ├── logging.py
│ │ └── graphql.py
│ ├── urls.py
│ └── wsgi.py
├── modules/ # Application modules
│ ├── core/ # Core functionality
│ ├── insuree/ # Insuree management
│ ├── policy/ # Policy management
│ ├── claim/ # Claims processing
│ └── authentication/ # User authentication
├── logs/ # Log files
├── static/ # Static files
├── media/ # Media uploads
├── manage.py
├── requirements.txt
├── .env.example
└── README.md
This project is licensed under the MIT 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.