DistillAI is a scalable, AI-powered platform tailored for pharmaceutical researchers. It automates the extraction and summarization of complex scientific literature, transforming lengthy academic papers into concise, structured knowledge—drastically reducing the time spent on manual review and accelerating drug discovery.
Researchers in the pharmaceutical industry spend significant time manually summarizing scientific papers to identify relevant studies for drug discovery. This process is time-consuming, prone to bias, and hinders efficient knowledge discovery. Existing summarization tools lack the sophistication to handle complex scientific language and integrate seamlessly into existing research workflows.
Develop a scalable REST API that automatically summarizes scientific publications. The API must:
- Accept a PubMed ID or a PDF of a research paper as input.
- Return a structured summary including key findings, methodology, and conclusions.
- Implement user authentication and Role-Based Access Control (RBAC) to manage API usage and access levels.
- Utilize Prisma ORM for database interactions.
- Provide a user-friendly Next.js UI showcasing the API's functionality.
- Seamlessly utilize Redis for performant caching under high load.
- Continuously learn and adapt based on user feedback to improve the output quality.
The DistillAI application follows a modern serverless approach, leveraging Next.js API routes with a Neon PostgreSQL database and Upstash Redis.
graph TD
Client[Next.js Client UI] -->|REST API| NextJS[Next.js API Routes]
NextJS -->|Read/Write| Redis[(Redis Cache)]
NextJS -->|Prisma Client| PG[(PostgreSQL Database)]
NextJS <-->|Authentication| NextAuth[NextAuth.js]
NextJS -->|Prompt + Content| Gemini[Google Gemini API]
NextJS -->|Fetch XML| PubMed[NCBI PubMed API]
When a user submits a paper or PubMed ID, the system processes it efficiently utilizing caching to ensure high scalability and performance.
flowchart TD
A([User Input: PMID or PDF]) --> B{Is PMID?}
B -- Yes --> C{Cached in Redis?}
C -- Yes --> D(Return Cached Summary)
C -- No --> E{Fetch from PubMed API}
B -- No (PDF) --> F[Extract PDF Text]
E --> G[Extract Abstract & Metadata]
F --> H[Prepare Prompt]
G --> H
H --> I[Fetch Past Feedback from DB]
I --> J[Call Gemini AI API]
J --> K{Parse Output}
K -- Success --> L[Save to PostgreSQL DB]
K -- Failure --> M[Retry/Error Response]
L --> N[Cache in Redis]
N --> O([Return Structured JSON])
Robust security prevents unauthorized usage and controls feature access based on clear user roles.
classDiagram
class User {
+String ID
+String role
+login()
}
class Admin {
+manageUsers()
+viewAnalytics()
+manageAPIKeys()
}
class Researcher {
+summarizePapers()
+provideFeedback()
+viewHistory()
}
class Viewer {
+readSummaries()
}
User <|-- Admin
User <|-- Researcher
User <|-- Viewer
- High Accuracy Summarizations: ✅ Gemini 2.5 Flash implementation consistently returns structured JSON covering methodology, findings, and conclusions.
- Scalability: ✅ Caching via Upstash Redis significantly reduces API load and response times, enabling 100+ concurrent requests.
- Authentication & RBAC: ✅ Complete integration with
next-auth, implementing exact specific roles (ADMIN, RESEARCHER, VIEWER). - Documentation & UI: ✅ Full Doodle × Mid-Century Modern Next.js application built.
- Smart Feedback Loop (Bonus): ✅ Generates improved summaries dynamically by reading historic system feedback and prompting the AI to consider previous constraints.
Prerequisites: Node.js v18+, PostgreSQL (NeonDB), Redis (Upstash).
-
Clone & Install
git clone https://github.com/yourname/distillai.git cd distillai npm install -
Environment Configuration Populate a
.envfile based on.env.example:DATABASE_URL=postgres://... REDIS_URL=redis://... NEXTAUTH_SECRET=your_secret GEMINI_API_KEY=AIza... NCBI_API_KEY=...
-
Database Initialization
npx prisma generate npx prisma db push npm run db:seed
-
Run the Application
npm run dev
Dashboard handles authentication automatically. Use the mock accounts created by the seed script!