- Overview
- Architecture
- Quick Start Guide
- Configuration
- Development
- Deployment
- API Documentation
- Database Schema
- User Groups and Authorization Details
- Testing
- Management Commands
- Troubleshooting
- Performance and Scaling
- Contributing
Helix Server 2.0 is a modular Django application designed to manage and process various data related to crises, countries, and entries. The project integrates with GraphQL, Redis, AWS S3, and Sentry, and uses environment variables for configuration.
- User authentication and role management
- RESTful and GraphQL APIs for data access
- Modular architecture for maintainability
- Docker support for easy deployment
- Integration with Redis, AWS S3, and Sentry
The Helix Server is structured into several key directories:
- apps/: Contains various Django applications, each responsible for a specific domain (e.g., users, contact, crisis).
- helix/: Contains core application code, including settings, URLs, and GraphQL schema definitions.
- deploy/: Contains deployment scripts and configurations.
- fixtures/: Contains JSON files for seeding the database with initial data.
- utils/: Contains utility functions and classes used across the application.
- Modular Architecture: The application is structured into multiple Django apps, each encapsulating its functionality, which promotes maintainability and scalability.
- RESTful and GraphQL APIs: The application exposes both RESTful and GraphQL APIs, allowing for flexible data retrieval and manipulation.
-
Initialize environment: Create a
.env
file in the project folder. For development, a blank file is fine. -
Start the application:
docker-compose up
-
Initialize database:
./init.sh
-
Seed database:
docker-compose exec server python manage.py save_users_dummy docker-compose exec server python manage.py create_dummy_users docker-compose exec server python manage.py loadtestdata <model_names> --count 2
-
Access GraphQL interface: Navigate to
localhost:9000/graphiql
.
The project uses environment variables for configuration. A sample environment file is provided as .env-sample
. Key configuration options include:
DATABASE_URL
: Database connection stringSECRET_KEY
: Secret key for DjangoDEBUG
: Boolean to enable/disable debug mode
For production and staging environments, refer to the secrets-sample.yml
file for additional configuration options.
To set up the development environment:
-
Clone the repository:
git clone https://github.com/idmc-labs/helix-server.git cd helix-server
-
Install dependencies:
poetry install
-
Run the development server:
python manage.py runserver
-
Build the Docker containers:
docker-compose build
-
Start the services:
docker-compose up -d
For detailed instructions on deploying the Helix Server using AWS Copilot, please refer to the README.copilot.md
file in the root directory of this project. This file contains step-by-step guidelines for:
- Setting up the AWS environment
- Initializing and deploying services
- Configuring additional resources (e.g., RDS, S3, Redis)
- Troubleshooting common deployment issues
- Deactivating services or the entire project
- Restarting individual services
The Copilot README also includes important information about the project's dependencies and future update considerations.
Create appropriate buckets with required policies based on the .env
:
sh deploy/scripts/s3_bucket_setup.sh
- Endpoint:
/graphql
- Interface:
/graphiql
To generate a fresh GraphQL schema:
python manage.py graphql_schema --out schema.graphql
- Endpoint:
/api/users/
- Methods:
GET
: List all usersPOST
: Create a new user
- Endpoint:
/api/auth/login/
- Methods:
POST
: Authenticate user
Located at /docs/helix-server-db-schema.sql
, this document offers a detailed description of the Helix Server's database structure. Key features include:
- Overview of the database purpose and design
- Comprehensive list of tables with their primary keys and important fields
- Explanation of key relationships between tables
- Summary of key features in the database schema (e.g., use of UUIDs, versioning system)
- Notes on specific design choices and capabilities
This document is crucial for developers working on database-related tasks or trying to understand the data structure of the Helix Server.
Located at /docs/user_groups_auth.md
, this document provides a detailed overview of the user group structure and associated permissions within the Helix Server. Key features include:
- Comprehensive list of user groups (e.g., ADMIN, DIRECTORS_OFFICE, MONITORING_EXPERT)
- Detailed permissions for each user group
- Overview of content types and modules that permissions apply to
- Explanation of different permission types (e.g., can add, can change, can delete)
This document is essential for understanding the role-based access control implemented in the system.
To run tests, use the following command:
pytest
Ensure that the test database is set up correctly in your environment variables.
python manage.py populate_calculation_logic_field
python manage.py update_ahhs_2024 update_ahhs.csv
python manage.py force_update_gidd_data
python manage.py addstatictoken -t 123456 "[email protected]"
python manage.py update_pre_2016_gidd_data.py old_conflict_data.csv old_disaster_data.csv
python manage.py update_idps_sadd_estimates idps_sadd_estimates.csv
- Database connection errors: Check your
DATABASE_URL
in the environment variables. - Docker build failures: Ensure Docker is running and you have the correct permissions.
- GraphQL errors: Check the schema definitions and ensure all required fields are provided.
- Redis connection issues: Ensure the Redis service is running and the connection details are correct in the
.env
file.
The application is designed to handle a growing user base. Key performance considerations include:
- Caching: Use Redis for caching frequently accessed data.
- Database Optimization: Use indexing on frequently queried fields and query optimization techniques.
- Load Balancing: Use a load balancer to distribute traffic across multiple instances.
- Monitoring: Use Sentry for error tracking and monitoring.
- Fork the repository and create your branch from
main
. - Ensure your code follows the project's coding standards.
- Write clear, concise commit messages.
- Include tests for any new features or bug fixes.
- Submit a pull request with a detailed description of your changes.
For more detailed information on specific aspects of the project, please refer to the individual documentation files in the repository.