This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This project uses Python 3.6.9+ with virtual environments. Install dependencies:
# Create virtual environment
mkdir ~/venv
cd ~/venv
python3 -m venv neurolibre
source ~/venv/neurolibre/bin/activate
# Install dependencies
pip3 install --upgrade pip
pip3 install -r api/requirements.txtCopy the appropriate environment template and configure:
# For preview server
cp api/env_templates/env.preview.template api/.env
# For preprint server
cp api/env_templates/env.preprint.template api/.envThe system operates two distinct server environments:
- Preview Server (
neurolibre_preview_api.py) - Handles preview & screening tasks prior to submission - Preprint Server (
neurolibre_preprint_api.py) - Handles publishing tasks after technical screening
- Common API (
neurolibre_common_api.py) - Shared functionality between servers - Server-specific APIs - Preview and preprint specific endpoints
- Configuration - YAML-based config in
api/config/directorycommon.yaml- Shared configurationpreview.yaml- Preview server specificpreprint.yaml- Preprint server specific
- Flask - Web framework with API blueprints
- Gunicorn - WSGI application server
- Celery - Asynchronous task queue with Redis backend
- NGINX - Reverse proxy and static file serving
- Docker - Containerization for reproducible environments
Celery handles asynchronous operations:
- Book building (JupyterBook/MyST)
- Data synchronization between servers
- Zenodo archival processes
- Binder image builds
# Activate environment
source ~/venv/neurolibre/bin/activate
# Preview server (development)
python api/neurolibre_preview_api.py
# Preprint server (development)
python api/neurolibre_preprint_api.py# Start Celery worker
source ~/venv/neurolibre/bin/activate
cd api/
celery -A neurolibre_celery_tasks worker --loglevel=infoThe application runs as systemd services:
neurolibre-preview.service- Preview serverneurolibre-preprint.service- Preprint server- Celery workers for async tasks
api/- Main application codeconfig/- YAML configuration filestemplates/- HTML templatesenv_templates/- Environment file templates
nginx/- NGINX configuration templatessystemd/- Service configuration filesfail2ban/- Security configuration
- Preview:
preview.neurolibre.org - Preprint:
preprint.neurolibre.org - Both use same domain (
neurolibre.org) with different subdomains
- Root data path:
/DATA(shared between servers) - Book artifacts:
/DATA/book-artifacts - MyST sources:
/DATA/myst - Logs:
/DATA/logs
- Uses GitHub API for repository management
- Forked repositories go to
roboneurolibreorganization - Review issues tracked in
neurolibre/neurolibre-reviews
- HTTP Basic Authentication for API endpoints
- SSL/TLS with Cloudflare integration
- fail2ban for brute-force protection
- Separate preview/production environments
- NewRelic integration for infrastructure monitoring
- NGINX status monitoring
- Celery task monitoring
- Comprehensive logging with journalctl