DataSpace is a platform for sharing and managing datasets. This repository contains the backend code for the DataSpace platform, built with Django and GraphQL.
- Secure Authentication: Integration with Keycloak for robust authentication
- Role-Based Access Control: Fine-grained permissions based on user roles
- GraphQL API: Modern API with efficient data fetching
- REST API: Traditional REST endpoints for specific operations
- Data Management: Tools for dataset management and organization
The backend uses Keycloak for authentication, providing a secure and scalable solution. Key aspects of the authentication system include:
- Token-Based Authentication: All requests require a valid Keycloak JWT token
- Direct Validation: Tokens are validated directly with Keycloak
- User Synchronization: User data is synchronized from Keycloak to the Django database
- No Development Mode: The system only works with real Keycloak tokens, with no fallback mechanisms
For detailed information about the Keycloak integration, see the Keycloak Integration Documentation.
- Python 3.8+
- PostgreSQL
- Keycloak server
-
Clone the repository:
git clone https://github.com/CivicDataLab/DataSpaceBackend.git cd DataSpaceBackend
-
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
-
Set up environment variables (create a
.env
file in the project root):DEBUG=True SECRET_KEY=your-secret-key DB_ENGINE=django.db.backends.postgresql DB_NAME=dataspace DB_USER=postgres DB_PASSWORD=postgres DB_HOST=localhost DB_PORT=5432 KEYCLOAK_SERVER_URL=https://your-keycloak-server/auth KEYCLOAK_REALM=your-realm KEYCLOAK_CLIENT_ID=your-client-id KEYCLOAK_CLIENT_SECRET=your-client-secret
-
Run migrations:
python manage.py migrate
-
Initialize roles:
python manage.py init_roles
-
Start the development server:
python manage.py runserver
API documentation is available at the following endpoints when the server is running:
- Swagger UI:
/swagger/
- ReDoc:
/redoc/
- GraphQL Playground:
/graphql/
api/
: Main API application with models, views, and GraphQL schemaauthorization/
: Authentication and authorization componentsDataSpace/
: Project settings and configurationdocs/
: Documentation filessearch/
: Search functionality and Elasticsearch integration
- Create a feature branch from the
main
branch - Make your changes
- Submit a pull request
This project is licensed under the MIT License.