How researchhub/researchhub-backend works
1. This is a Django monolith organized into many domain apps under src/. The main application bootstrap lives in researchhub/ (settings, urls, wsgi, asgi, celery), while each feature area owns its own models, views, serializers, permissions, services, signals, tasks, and migrations.
2. The core architectural boundary is the Django API layer. Most request handling flows through app-specific DRF views and viewsets, with serializers shaping payloads and permission classes enforcing access. The repo is not a single-purpose app; it exposes a broad API for content, identity, search, funding, discussion, and AI-assisted workflows.
3. Content is centered around the paper/document stack. paper/, researchhub_document/, discussion/, review/, note/, hub/, topic/, tag/, and user/ collectively model scholarly content, authorship, versions, comments, topics, hubs, and moderation state. This content layer feeds most downstream features.
4. Ingestion is a major subsystem. paper/ingestion/ contains a pipeline, source clients, mappers, and enrichment services for external sources such as OpenAlex and preprint providers. The data flow is: external source APIs/XML feeds → parsers/mappers → paper domain models → enrichment and task execution. There are many management commands for backfills and repair jobs, which indicates the ingestion path is both online and batch-driven.
5. researchhub_document/ is the unifying abstraction used across the platform. It defines unified document records and document filters, and it connects papers, posts, grants, notes, and other entities into a common indexing/browse model. This layer is the bridge between content creation and the discovery surfaces.
6. Search is a dedicated subsystem backed by OpenSearch. search/ contains OpenSearch documents, query builders, serializers, view endpoints, and Celery tasks for indexing and cleanup. The search flow is: domain objects change → signals/tasks update OpenSearch documents → search and suggest endpoints query the index. The README confirms OpenSearch is required for browse/search, and there are commands for index rebuild and cleanup.
7. Feed generation is another major read-optimized layer. feed/ builds several feed variants: activity, funding, grant, journal, moderator, personalized, and ResearchHub feeds. It uses feed entries, hot-score logic, filtering, cache segmentation, and a large set of signals from content and transaction apps to invalidate or recompute feeds. This layer sits between the content/reputation events and the home/feed experiences.
8. User identity, author profiles, and moderation are handled in user/, oauth/, orcid/, invite/, organizations/, researchhub_access_group/, and related models. These apps cover signup/auth, ORCID linking, author claims, organizations, invite flows, permissions, risk scoring, and content moderation. External integrations here include OAuth/social login, ORCID, Persona verification, and organization-specific permissions.
9. Funding, transactions, and reputation form a separate financial subsystem. purchase/ handles grants, fundraises, balances, payment intents, and payment-provider integrations; reputation/ handles deposits, withdrawals, bounties, distributions, staking yield, and wallet logic. External payment/ledger integrations include Circle, Coinbase, Stripe, and Endaoment. This subsystem is heavily event-driven and tied to user balances and reward distribution.
10. Social interaction flows are modeled through discussion, comments, reactions, reviews, notes, notifications, and user interactions. discussion/, researchhub_comment/, review/, note/, notification/, and analytics/ each own pieces of the interaction graph. Many of these apps emit signals that feed feed updates, notifications, analytics events, and reputation changes.
11. AI-assisted features are isolated into research_ai/, ai_peer_review/, and some services in paper/, purchase/, and search/. These modules define prompts, LLM service wrappers, email generation, expert finding, proposal review, executive summaries, and RFP-related workflows. The AI boundary is clear: prompt templates and services encapsulate calls to external LLM providers such as Bedrock/OpenAI, then persist or render the generated output back into domain objects and emails.
12. Async and event processing is a cross-cutting backbone. Celery is used throughout for ingestion, indexing, email generation, reputation updates, risk-score backfills, and feed maintenance. Django signals are used heavily to react to model changes and enqueue downstream work. Redis is implied as the task/result/cache substrate from the devcontainer and Celery setup.
13. Analytics and behavioral syncing are handled separately from core product data. analytics/ ingests Amplitude webhooks and maps events into internal user_interactions records; personalize/ exports and syncs items/interactions to a recommendation backend. This creates a pipeline from user behavior → normalized events → recommendation and reporting services.
14. Infra and developer/runtime tooling matter to the architecture: the project runs on PostgreSQL, Redis, OpenSearch, Django ASGI/WSGI, and Celery workers/beat. There are devcontainer definitions, environment-specific config modules, many management commands for backfills and maintenance, and extensive test coverage per app, which supports a service-oriented monolith rather than a thin CRUD app.
Main entry points: src API apps · paper Paper domain · purchase Funding · feed Feeds
Components 20
Core platform
Bootstrap, API surface, and shared runtime wiring.
- researchhub · Project settings, URL routing, ASGI/WSGI, Celery wiring, and shared API runtime.
src/researchhub - API apps · App-specific views, serializers, permissions, and services that implement the public API.
src
Content domain
Scholarly content, unified documents, and interaction models.
- Paper ingestion · External source clients, parsers, mappers, and enrichment services for paper intake.
src/paper/ingestion - Paper domain · Paper, authorship, versions, citations, uploads, and paper-centric services.
src/paper - Unified documents · Cross-domain document abstraction for browse, filters, and shared discovery views.
src/researchhub_document - Discussion layer · Threads, comments, reactions, reviews, and note/discussion interactions.
src/discussion - Review system · Peer review objects, availability, permissions, services, and review signals.
src/review
Discovery layers
Search, feeds, and recommendation-oriented read models.
- Search · Index documents, query builders, suggest endpoints, indexing tasks, and cleanup commands.
src/search - Feeds · Activity, funding, grant, journal, moderator, and personalized feed generation.
src/feed - Personalize · Exports items and interactions to an external recommendation backend.
src/personalize
Identity and access
Signup, profiles, orgs, invites, and moderation boundaries.
- Users · Users, authors, moderation, verification, risk scoring, follows, and engagement state.
src/user - Auth integrations · OAuth signup, ORCID linking, invitation flows, and access group permissions.
src/oauth - ORCID · ORCID connect/callback/fetch services and related tasks.
src/orcid - Organizations · Organizations, access groups, and organization-scoped permissions.
src/organizations
Funding and reputation
Wallets, payments, grants, bounties, and reputation flows.
- Funding · Balances, purchases, fundraises, grants, payment intents, and provider integrations.
src/purchase - Reputation · Deposits, withdrawals, bounties, staking yield, distributions, and wallet logic.
src/reputation
AI workflows
LLM-assisted review, search, and outreach workflows.
- AI workflows · Proposal review, executive summaries, expert finding, and outreach/email generation.
src/research_ai - AI peer review · Proposal review generation, scoring, comment upserts, and editorial feedback workflows.
src/ai_peer_review
Async and integrations
Background jobs, webhooks, analytics, and external services.
- Analytics · Amplitude webhook ingestion and normalization into internal interaction records.
src/analytics - External services · PostgreSQL, Redis, OpenSearch, payment providers, and LLM backends used across the monolith.
Connections 34
- researchhub → API apps: configures · Bootstraps routing, settings, auth, and task execution for all apps.
- API apps → Paper domain: serves · Paper endpoints expose paper CRUD, upload, versions, and related actions.
- API apps → Discussion layer: serves · Discussion and comment endpoints handle threads, reactions, and moderation.
- API apps → Review system: serves · Review endpoints expose review availability and review operations.
- API apps → Funding: serves · Funding APIs expose grants, fundraises, balances, and payment flows.
- API apps → Reputation: serves · Reputation APIs expose deposits, withdrawals, bounties, and staking.
- API apps → Search: serves · Search endpoints query and suggest across indexed documents.
- API apps → Feeds: serves · Feed endpoints render activity, funding, journal, and personalized feeds.
- Paper ingestion → Paper domain: writes · Imported works are normalized into paper records and related models.
- Paper ingestion → Unified documents: enriches · Imported papers are also reflected into unified browse/document records.
- Paper domain → Unified documents: publishes · Paper changes feed the unified document abstraction for discovery surfaces.
- Discussion layer → Unified documents: publishes · Posts, comments, and related entities contribute to unified documents.
- Review system → Discussion layer: extends · Review content is threaded through discussion/comment structures.
- Unified documents → Search: indexes · Unified documents are projected into OpenSearch documents.
- Paper domain → Search: signals · Paper updates trigger indexing and cleanup of search documents.
- Discussion layer → Feeds: signals · Comment and discussion activity invalidates or updates feeds.
- Paper domain → Feeds: signals · Paper changes create feed entries and hot-score updates.
- Funding → Feeds: signals · Funding events contribute to funding, grant, and activity feeds.
- Reputation → Feeds: signals · Reputation events drive bounty, moderation, and activity feed updates.
- Analytics → Personalize: syncs · Normalized interactions are exported for recommendation and sync services.
- Users → Auth integrations: uses · Identity and profile flows rely on signup, OAuth, and ORCID linking.
- Auth integrations → ORCID: delegates · ORCID connect, callback, and fetch logic is handled by the ORCID app.
- Users → Organizations: governs · User and author permissions are constrained by organization access models.
- Users → Funding: owns · Wallets, balances, and support status are attached to users and authors.
- Users → Reputation: owns · Reputation accounts, rewards, and payouts are user-centered.
- Funding → Reputation: feeds · Purchases and grants drive reward, payout, and wallet-related reputation flows.
- AI workflows → Funding: reviews · Proposal and grant workflows generate summaries and assessment outputs.
- AI workflows → Paper domain: analyzes · Paper-related AI services generate summaries, context, and expert discovery artifacts.
- AI peer review → AI workflows: uses · Automated proposal review builds on shared LLM and prompt services.
- Search → External services: depends on · OpenSearch is required for browse/search functionality.
- Feeds → External services: depends on · Feeds rely on cache, async jobs, and external persistence backends.
- Funding → External services: integrates · Payment and transfer providers are used for checkout and grants.
- Reputation → External services: integrates · Ledger, wallet, and staking flows depend on external services and storage.
- AI workflows → External services: calls · LLM and context-generation services call external model providers.