The CRUK Basic Backend is a FastAPI microservice running on http://localhost:8000. It provides the core database and API endpoints for managing Users, Teams, Datasets (JSON metadata blobs & draft states), Projects, Publications, Tools, and Team Invitations.
The CRUK Metadata Catalogue consists of five inter-connected repositories:
- Frontend Landing Page (
CRUK_datahub_landing_page) —git@github.com:UOSbioinformaticslab/CRUK_datahub_landing_page.git- Role: React/Vite user interface running on
http://localhost:5173. Provides dataset browsing, search, metadata upload forms, custodian management, and live schema documentation views.
- Role: React/Vite user interface running on
- Basic Backend (
basic/basic_backend) —git@github.com:UOSbioinformaticslab/basic_backend.git— (You are here)- Role: Core FastAPI database backend running on
http://localhost:8000. Manages Users, Teams, Datasets (JSON metadata blobs & draft states), Projects, Publications, Tools, and Team Invitations.
- Role: Core FastAPI database backend running on
- Middle Layer Proxy (
middle) —git@github.com:UOSbioinformaticslab/cruk-middle-layer.git- Role: Administrative FastAPI service running on
http://localhost:8002. Manages new Data Custodian team request applications (TeamRequest) and centralized system error logging (ErrorLog).
- Role: Administrative FastAPI service running on
- CRUK Semantic Schema Viewer & Package (
semantic-schema/cruk-semantic-schema) —git@github.com:UOSbioinformaticslab/cruk-semantic-schema.git- Role: React component library & standalone interactive UI for rendering the CRUK 1.0.0 semantic schema overlay dynamically fetched from HDRUK schemata.
- AI Microservices (
ai/ai-microservices) — Optional / Private Repository —git@github.com:UOSbioinformaticslab/ai-microservices.git- Role: FastAPI AI microservice running on
http://localhost:8001. Powered by Google Gemini API for intelligent metadata extraction, automated tagging, and semantic search assistance. Note: This repository is private. If you do not have access to it or do not have a Gemini API key, the rest of the CRUK catalogue will run fully and seamlessly without it.
- Role: FastAPI AI microservice running on
Before running this backend microservice, a .env file must be created in this folder:
- Automatic Setup:
Running
./start_all.shfrom the workspace root orCRUK_datahub_landing_page/will automatically copy.env.exampleto.envif no.envfile is present. - Manual Setup:
You can manually copy the provided template file:
cp .env.example .env
- Variable Breakdown:
DATABASE_URL: Connection string for the database (defaults to local SQLitesqlite:///./cruk_datahub.db).DATABASE_PUBLIC_URL: Base URL where the backend is hosted (defaults tohttp://localhost:8000).SECRET_KEY: Secret key used for signing JWT authentication tokens. Replace with a secure random string in production.ALGORITHM: JWT signing algorithm (defaults toHS256).ACCESS_TOKEN_EXPIRE_MINUTES: JWT token lifetime in minutes (defaults to600).ADMIN_PASSWORD: Default admin user password for seeding initial admin accounts (seed_sarah.py).
Example .env configuration:
DATABASE_URL="sqlite:///./cruk_datahub.db"
DATABASE_PUBLIC_URL="http://localhost:8000"
SECRET_KEY="your-secure-random-secret-key"
ALGORITHM="HS256"
ACCESS_TOKEN_EXPIRE_MINUTES=600
ADMIN_PASSWORD="your-admin-password"To launch this service individually:
uvicorn main:app --reload --port 8000To start the entire system together:
# From workspace root or CRUK_datahub_landing_page
./start_all.shView interactive OpenAPI documentation at: http://localhost:8000/docs
The SQLite database file (cruk_datahub.db) is automatically initialized if it does not exist when starting the backend.
The backend powers the dataset upload filter system. When users select Topography and Histology tags on the frontend, it posts to the /datasets/extra-terms endpoint. The backend looks up these tags in the CancerTermMapping table and returns associated SNOMED/TCGA mappings to inject into the dataset payload.
The backend provides comprehensive support for Data Custodians (teams) and their actions:
- Public Team Assets: The
/teams/{team_id}/assetsendpoint aggregates and returns all active datasets, projects, and publications associated with a specific team. - Asset Management: Endpoints like
/datasets/list/simplefilter results based on the logged-in user's active team, allowing editors to manage both active records and drafts securely.