Skip to content
Merged
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
9be231a
add microscope form create test, isolate snapshot plugin logic (#324)
tlambert03 Oct 30, 2025
2c95d23
plan
tlambert03 Oct 29, 2025
dd90353
feat: Phase 1 - Vite 7 migration preparation complete
tlambert03 Oct 29, 2025
8f79450
feat: Phase 3 - Django integration complete
tlambert03 Oct 29, 2025
55d399c
feat: Phase 4 - E2E test configuration updated
tlambert03 Oct 29, 2025
14b94be
feat: Phase 5 - Webpack removal and cleanup complete
tlambert03 Oct 29, 2025
09daf4f
fix: resolve Vite migration issues and improve ES module compatibility
tlambert03 Oct 30, 2025
a1931fb
sentry mod
tlambert03 Oct 30, 2025
cab5e89
progress on jquery and tests
tlambert03 Oct 30, 2025
26b9cca
fix search
tlambert03 Oct 30, 2025
0616a9d
feat: add Popper.js for Bootstrap tooltips and dropdowns; update D3 h…
tlambert03 Oct 30, 2025
ef6e9eb
fix prod-local
tlambert03 Oct 30, 2025
eacdad5
more test fixes
tlambert03 Oct 30, 2025
fbd9d32
use module type
tlambert03 Oct 30, 2025
bef6de2
fix tests and move tests
tlambert03 Oct 30, 2025
b7cecd8
fix
tlambert03 Oct 30, 2025
60a8e80
some dependency cleanup and jquery cleanup
tlambert03 Oct 30, 2025
bbacb16
fix microscope form
tlambert03 Oct 30, 2025
439f12e
fix: remove duplicate snapshot fixtures from conftest.py
tlambert03 Oct 30, 2025
efbd4dd
fix no data
tlambert03 Oct 30, 2025
92641c0
local-production fixes
tlambert03 Oct 30, 2025
51cd552
some fixes
tlambert03 Oct 31, 2025
713aa28
remove plan
tlambert03 Oct 31, 2025
b9f499b
add overrides react-is
tlambert03 Oct 31, 2025
3352489
ignore existing snapshots dir
tlambert03 Oct 31, 2025
4445385
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 31, 2025
fed89b9
prek
tlambert03 Oct 31, 2025
94627f2
fix bootstrap issues
tlambert03 Oct 31, 2025
0a9feda
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Oct 31, 2025
b8953a1
less code on protein search
tlambert03 Oct 31, 2025
7251356
Merge branch 'use-vite' of https://github.com/tlambert03/FPbase into …
tlambert03 Oct 31, 2025
23dfce6
Refactor initialization of FRET and search features to use data attri…
tlambert03 Oct 31, 2025
f7733be
ignore stupid stuff
tlambert03 Oct 31, 2025
6103884
Enhance console warning filtering in e2e tests to ignore specific coo…
tlambert03 Oct 31, 2025
8e62e80
Remove unused warnings import and console warning message logging in …
tlambert03 Nov 1, 2025
98aa5b3
remove more
tlambert03 Nov 1, 2025
29318d4
Refactor console error handling in Playwright tests to use a class-ba…
tlambert03 Nov 1, 2025
4b53d02
remove webpack word
tlambert03 Nov 1, 2025
f043f7e
comment
tlambert03 Nov 1, 2025
1d00d21
just comments
tlambert03 Nov 1, 2025
70df97f
improve litemol inclusion
tlambert03 Nov 1, 2025
0fe6d5c
fix protein page SEO issues
tlambert03 Nov 1, 2025
0f8c4d8
refactor: separated the Highcharts bundles from the main bundle
tlambert03 Nov 1, 2025
03c7dab
fix font-awesome small i
tlambert03 Nov 1, 2025
10c8f37
delay pattern import
tlambert03 Nov 1, 2025
70fcdd1
reduce bundle
tlambert03 Nov 1, 2025
b5e99b4
remove unused fonts
tlambert03 Nov 1, 2025
6d7e5c1
fix cdn url
tlambert03 Nov 1, 2025
23379bb
refactor: optimize CDN script loading and remove unused scripts
tlambert03 Nov 1, 2025
fc8377c
test more microscope views
tlambert03 Nov 1, 2025
4c21b9c
Merge branch 'main' into use-vite
tlambert03 Nov 2, 2025
cb6a572
Merge branch 'main' into use-vite
tlambert03 Nov 2, 2025
5480caa
Merge branch 'main' into use-vite
tlambert03 Nov 4, 2025
0c6fd67
fix vite
tlambert03 Nov 4, 2025
f88b164
Merge branch 'main' into use-vite
tlambert03 Nov 4, 2025
7ec25be
step1
tlambert03 Nov 5, 2025
4020d6e
defer autocomplete.js
tlambert03 Nov 5, 2025
998ebf3
use d3 modules
tlambert03 Nov 5, 2025
45e5b7c
sentry bundle opt
tlambert03 Nov 5, 2025
d6a21b6
Adapt TEST_BUILD source map debugging for Vite
tlambert03 Nov 5, 2025
ac2fc13
Fix source map transformation for page errors
tlambert03 Nov 5, 2025
09c395b
Merge remote-tracking branch 'upstream/main' into use-vite
tlambert03 Nov 5, 2025
af65aea
Merge branch 'main' into use-vite
tlambert03 Nov 5, 2025
cd26aa4
Merge branch 'main' into use-vite
tlambert03 Nov 5, 2025
8a30628
better init
tlambert03 Nov 5, 2025
c373ed8
Update backend/config/settings/base.py
tlambert03 Nov 5, 2025
ffe0a2c
Merge branch 'use-vite' of https://github.com/tlambert03/FPbase into …
tlambert03 Nov 5, 2025
f72cdc8
refactor: streamline body and content blocks in base.html; enhance au…
tlambert03 Nov 5, 2025
8529ae3
add playwright to clean
tlambert03 Nov 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ Django web app for <https://www.fpbase.org> with React frontend. PostgreSQL data
- unless explicitly told otherwise, don't run `git commit`, let me review changes.
- avoid nested imports unless specifically used to avoid circular imports or delay heavy imports.
- avoid arbitrary time.sleep() calls in tests; use proper waits on a specific condition instead.
- the current year is 2025 (not 2024), for web-searches

## Tech Stack

**Backend**: Django, Python, DRF, GraphQL (graphene-django), PostgreSQL, Celery + Redis
**Frontend**: React, Webpack, pnpm monorepo (packages: spectra, blast use Vite)
**Frontend**: React, vite, pnpm monorepo (packages: spectra, blast use Vite)
**Science**: BioPython, NumPy, Pandas, SciPy, Matplotlib

## Key Overrides
Expand All @@ -29,7 +30,7 @@ uv sync # Install/update Python deps
pnpm install # Install Node deps

# Development
pnpm dev # Start webpack + Django dev server
pnpm dev # Start vite + Django dev server
uv run backend/manage.py shell_plus # Interactive shell with auto-imports

# Testing
Expand Down
13 changes: 3 additions & 10 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# FPbase Copilot Instructions

## Project Overview
FPbase is a Django/React monorepo for the Fluorescent Protein Database (fpbase.org). The backend uses Django 4.x with GraphQL and REST APIs, while the frontend is a hybrid of server-rendered Django templates with embedded React apps built via Webpack and Vite.
FPbase is a Django/React monorepo for the Fluorescent Protein Database (fpbase.org). The backend uses Django 4.x with GraphQL and REST APIs, while the frontend is a hybrid of server-rendered Django templates with embedded React apps built via Vite.

## Architecture

Expand All @@ -12,12 +12,12 @@ FPbase is a Django/React monorepo for the Fluorescent Protein Database (fpbase.o
- `references/`: Publication and citation management
- `fpseq/`: Bioinformatics sequence alignment and analysis using Biopython
- `favit/`: User favorites system
- **`frontend/`**: Webpack-bundled assets integrated via `django-webpack-loader`
- **`frontend/`**: vite-bundled assets integrated via `django-vite`
- **`packages/`**: Standalone Vite apps (`blast/`, `spectra/`) embedded in Django templates

### Key Technologies
- **Backend**: Django, Django REST Framework, Graphene (GraphQL), Celery (Redis), PostgreSQL
- **Frontend**: React, Material-UI, Webpack, Vite
- **Frontend**: React, Material-UI, Vite
- **Search**: Algolia for protein/organism search
- **Bioinformatics**: Biopython (sequence alignment), BLAST (local binaries in `backend/bin/`)
- **Deployment**: Heroku, AWS S3 (media), Sentry (error tracking)
Expand Down Expand Up @@ -50,7 +50,6 @@ Django settings split across `backend/config/settings/`:
- `base.py`: Shared configuration
- `local.py`: Development (DEBUG=True, dummy cache, console email)
- `production.py`: Production (Heroku, AWS S3, real cache)
- `test.py`: Testing (uses `MockWebpackLoader` to skip frontend builds)

Environment variables loaded via `django-environ` from `.env` file (set `DJANGO_READ_DOT_ENV_FILE=True`).

Expand Down Expand Up @@ -91,11 +90,6 @@ Core models in `models/`:

## Frontend Integration

### Webpack + Django Templates
- Webpack builds to `frontend/dist/` with stats tracked in `webpack-stats.json`
- Django loads bundles via `{% load webpack_loader %}` template tags
- Hot reload available with `HOT_RELOAD=1` env var
- Entry points in `frontend/src/`: `index.js`, `spectra-viewer.js`, `blast-app.js`, etc.

### Vite Apps (packages/)
- Standalone React apps (`@fpbase/blast`, `@fpbase/spectra`) embedded as iframes or via CDN
Expand All @@ -110,7 +104,6 @@ Core models in `models/`:
## Testing Patterns
- Tests in `*/tests/` directories (pytest)
- Use `@pytest.mark.django_db` for database access
- Frontend-dependent tests use `@pytest.mark.usefixtures("uses_frontend", "use_real_webpack_loader")`
- Factory fixtures preferred over manual object creation

## Custom Middleware
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ _data
.pytest_cache

/fpseq/addgene.py

webpack-stats.json

/.sentryclirc
.vscode/

Expand All @@ -386,3 +383,4 @@ memray_*/
test_fix*.bin
__snapshots__/
snapshot_failures/
frontend/stats.html
23 changes: 11 additions & 12 deletions backend/config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,16 @@
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]

INSTALLED_APPS.append("webpack_loader")

WEBPACK_LOADER = {
"DEFAULT": {
"CACHE": not DEBUG,
"BUNDLE_DIR_NAME": "/",
"STATS_FILE": str(ROOT_DIR.parent / "frontend" / "dist" / "webpack-stats.json"),
"POLL_INTERVAL": 0.1,
"TIMEOUT": None,
"IGNORE": [r".*\.hot-update.js", r".+\.map"],
INSTALLED_APPS.append("django_vite")

DJANGO_VITE = {
"default": {
"dev_mode": DEBUG,
"dev_server_protocol": "http",
"dev_server_host": "localhost",
"dev_server_port": 5173,
"static_url_prefix": "",
"manifest_path": str(ROOT_DIR.parent / "frontend" / "dist" / "manifest.json"),
}
}

Expand Down Expand Up @@ -336,8 +336,7 @@

# See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id
SITE_ID = 1
# CANONICAL_URL = env('CANONICAL_URL', default='https://www.fpbase.org')
CANONICAL_URL = env("CANONICAL_URL", default=None)
CANONICAL_URL = env("CANONICAL_URL", default="https://www.fpbase.org")


# AVATAR CONFIGURATION
Expand Down
78 changes: 9 additions & 69 deletions backend/config/settings/local.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""Local settings for FPbase project."""

import os

import structlog

from .base import * # noqa

# STATIC FILES - Add backend static directory for development
# ------------------------------------------------------------------------------
# Include backend/fpbase/static so Django can serve microscope.js and other
# static files that don't go through webpack
# static files that don't go through vite
STATICFILES_DIRS = [*STATICFILES_DIRS, str(ROOT_DIR / "fpbase" / "static")]

# DEBUG
Expand All @@ -19,6 +17,10 @@

CRISPY_FAIL_SILENTLY = not DEBUG

# DJANGO_VITE - Enable dev mode for local development
# ------------------------------------------------------------------------------
DJANGO_VITE["default"]["dev_mode"] = True

# CSRF_COOKIE_HTTPONLY = True

# SECRET CONFIGURATION
Expand Down Expand Up @@ -83,7 +85,6 @@
]

# Structlog Configuration for Local Development
# Reconfigure to add dev-specific processors (set_exc_info for better tracebacks)
structlog.configure(
processors=[
*STRUCTLOG_SHARED_PROCESSORS,
Expand Down Expand Up @@ -127,74 +128,13 @@
"level": "INFO",
},
"loggers": {
# Application loggers - DEBUG in local
"fpbase": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
"proteins": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
"references": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
"favit": {
"handlers": ["console"],
"level": "DEBUG",
"django.server": {
"level": "WARNING", # Hide normal requests, use structlog instead
"propagate": False,
},
"celery": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": False,
},
# Django framework
"django": {
"handlers": ["console"],
"level": os.getenv("DJANGO_LOG_LEVEL", "INFO"),
"propagate": False,
},
"django.db.backends": {
"handlers": ["console"],
"level": "INFO", # Set to DEBUG to see SQL queries
"propagate": False,
},
# django-structlog
"django_structlog": {
"handlers": ["console"],
"level": "INFO",
"debug_toolbar": {
"level": "WARNING", # Hide debug toolbar noise
"propagate": False,
},
},
}

# Optional: Desktop logging for specific debugging
if os.getenv("DESKTOP_LOG"):
from pathlib import Path

LOGGING["handlers"]["file"] = {
"level": "DEBUG",
"class": "logging.FileHandler",
"filename": str(Path.home() / "Desktop/fpbase.log"),
"formatter": "colored",
}
LOGGING["loggers"].update(
{
"django.template": {
"handlers": ["file"],
"level": "INFO",
"propagate": True,
},
"django.utils": {
"handlers": ["file"],
"level": "INFO",
"propagate": True,
},
}
)
LOGGING["loggers"]["django"]["handlers"].append("file")
9 changes: 9 additions & 0 deletions backend/config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

"""

import re
import ssl

import sentry_sdk
Expand Down Expand Up @@ -113,6 +114,14 @@
# ------------------------
WHITENOISE_MAX_AGE = 600


# http://whitenoise.evans.io/en/stable/django.html#WHITENOISE_IMMUTABLE_FILE_TEST
# https://github.com/MrBin99/django-vite?tab=readme-ov-file#whitenoise
def WHITENOISE_IMMUTABLE_FILE_TEST(path, url):
# Match vite (rollup)-generated hashes, à la, `some_file-CSliV9zW.js`
return re.match(r"^.+[.-][0-9a-zA-Z_-]{8,12}\..+$", url)


# EMAIL
# ------------------------------------------------------------------------------
DEFAULT_FROM_EMAIL = env("DJANGO_DEFAULT_FROM_EMAIL", default="FPbase <[email protected]>")
Expand Down
14 changes: 14 additions & 0 deletions backend/config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
DEBUG = False
TEMPLATES[0]["OPTIONS"]["debug"] = True

# ALLOWED_HOSTS
# ------------------------------------------------------------------------------
# Allow all hosts for testing (live_server uses random ports)
ALLOWED_HOSTS = ["*"]

# SECRET CONFIGURATION
# ------------------------------------------------------------------------------
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
Expand Down Expand Up @@ -94,3 +99,12 @@
],
],
]


# django-vite in test mode uses manifest (never dev server)
DJANGO_VITE = {
"default": {
"dev_mode": False,
"manifest_path": str(ROOT_DIR.parent / "frontend" / "dist" / "manifest.json"),
}
}
2 changes: 1 addition & 1 deletion backend/fpbase/static/js/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Legacy Static JavaScript

This directory contains legacy JavaScript that is **isolated from the main webpack bundle** and loaded separately via Django static files.
This directory contains legacy JavaScript that is **isolated from the main vite bundle** and loaded separately via Django static files.

## Contents

Expand Down
3 changes: 0 additions & 3 deletions backend/fpbase/templates/500.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% extends "base.html" %}
{% load webpack_static from webpack_loader %}

{% block title %}Server Error{% endblock %}

Expand All @@ -12,8 +11,6 @@ <h3>Looks like something went wrong :(</h3>

{% block javascript %}

<script src="{% webpack_static 'sentry.js' %}"></script>

{% if sentry_event_id %}
<script>
Sentry.init({ dsn: '{{ sentry_dsn }}' });
Expand Down
Loading
Loading