Welcome to DocuThinker! This is a full-stack application that integrates an AI-powered document processing backend, blue/green & canary deployment on an AWS infrastructure, and a React-based frontend. The app allows users to upload documents for summarization, generate key insights, chat with an AI, and do even more with the documentβs content.
The DocuThinker app is designed to provide users with a simple, AI-powered document management tool. Users can upload PDFs or Word documents and receive summaries, key insights, and discussion points. Additionally, users can chat with an AI using the documentβs content for further clarification.
DocuThinker is created using the FERN-Stack architecture, which stands for Firebase, Express, React, and Node.js. The backend is built with Node.js and Express, integrating Firebase for user authentication and MongoDB for data storage. The frontend is built with React and Material-UI, providing a responsive and user-friendly interface.
graph LR
U[Client's Browser] -->|HTTPS| N[NGINX - SSL, Routing, Caching]
N -->|static calls| A[React Frontend]
N -->|/api/* proxy| B[Express Backend]
A -->|REST API calls| N
B --> C[Firebase Auth]
B --> D[Firestore]
B --> E[MongoDB]
B --> F[Redis Cache]
B --> G[AI/ML Services]
A --> H[Material-UI]
A --> I[React Router]
G --> J[Google Cloud APIs]
G --> K[LangChain]
Feel free to explore the app, upload documents, and interact with the AI! For architecture details, setup instructions, and more, please refer to the sections below, as well as the ARCHITECTURE.md file.
[!TIP] Access the live app at https://docuthinker.vercel.app/ by clicking on the link or copying it into your browser! π
We have deployed the entire app on Vercel and AWS. You can access the live app here.
aws/ directory. Itβs a one-click deployment using AWS Fargate.[!IMPORTANT] The backend server may take a few seconds to wake up if it has been inactive for a while. The first API call may take a bit longer to respond. Subsequent calls should be faster as the server warms up.
DocuThinker offers a wide range of features to help users manage and analyze their documents effectively. Here are some of the key features of the app:
DocuThinker is built with 120+ technologies spanning frontend, backend, AI/ML, mobile, infrastructure, and DevOps. Below is the complete technology stack.
coralogix/coralogix provider.For a comprehensive deep-dive into the AI/ML architecture with visual diagrams, see AI_ML.md.
DocuThinker features a clean and intuitive user interface designed to provide a seamless experience for users. The app supports both light and dark themes, responsive design, and easy navigation. Here are some screenshots of the app:
The DocuThinker app is organized into separate subdirectories for the frontend, backend, and mobile app. Each directory contains the necessary files and folders for the respective components of the app. Here is the complete file structure of the app:
DocuThinker-AI-App/
βββ .beads/ # Beads task coordination system
β βββ .status.json # Agent reservations & active bead tracking
β βββ README.md # Beads workflow quick-reference
β βββ active/ # Beads available for agents to pick up
β βββ completed/ # Archive of finished beads
β βββ templates/
β βββ feature-bead.md # Template for new feature beads
βββ .agent-sessions/ # Agent session history & coordination
β βββ README.md # Session management guide
β βββ SCHEMA.md # Session data structure specification
β βββ config.json # Session configuration
β βββ active/ # Sessions currently in progress
β βββ completed/ # Archived finished sessions
β βββ templates/
β βββ session-log.md # Standard session log template
β βββ handoff-report.md # Agent-to-agent handoff template
β βββ escalation-report.md # Conflict / blocker escalation template
βββ .claude/ # Claude Code workspace settings
βββ .mcp.json # MCP server configuration
βββ AGENTS.md # Agent behavior instructions
βββ CLAUDE.md # Claude Code project instructions
βββ ai_ml/ # AI/ML pipelines & services directory (Python)
βββ orchestrator/ # Agentic orchestration layer (Node.js)
β βββ core/
β β βββ supervisor.js # Intent classification, decomposition, dispatch
β β βββ circuit-breaker.js # Per-provider circuit breaker state machine
β β βββ agent-loop.js # Iterative tool-use agent loop
β β βββ handoff.js # Cross-agent context transfer
β β βββ batch-processor.js # Concurrent batch document processing
β β βββ cost-tracker.js # Token cost tracking with budget limits
β β βββ dlq.js # Dead letter queue with retry logic
β β βββ python-bridge.js # HTTP bridge to Python AI/ML service
β β βββ providers.js # Unified LLM client (Claude + Gemini)
β β βββ tool-registry.js # Tool registration and dispatch
β βββ context/
β β βββ token-budget.js # Context window management
β β βββ conversation-store.js # Auto-summarizing conversation memory
β β βββ observability.js # OTel-compatible context metrics
β β βββ hybrid-rag.js # Keyword + semantic search with RRF
β βββ prompts/
β β βββ system-prompts.js # 14 versioned system prompts
β β βββ cache-strategy.js # 3-layer Anthropic prompt caching
β βββ schemas/
β β βββ ai-outputs.js # 12 Zod validation schemas
β βββ mcp/
β β βββ server.js # MCP server exposing 13 tools
β β βββ client.js # MCP client for external servers
β βββ __tests__/
β β βββ orchestrator.test.js # Integration tests (Jest)
β βββ Dockerfile # Production container (node:20-alpine)
β βββ package.json # Dependencies and scripts
β βββ index.js # Express server entry point (port 4000)
β
βββ backend/
β βββ middleware/
β β βββ jwt.js # Authentication middleware with JWT for the app's backend
β βββ controllers/
β β βββ controllers.js # Controls the flow of data and logic
β βββ graphql/
β β βββ resolvers.js # Resolvers for querying data from the database
β β βββ schema.js # GraphQL schema for querying data from the database
β βββ models/
β β βββ models.js # Data models for interacting with the database
β βββ services/
β β βββ services.js # Models for interacting with database and AI/ML services
β βββ views/
β β βββ views.js # Output formatting for success and error responses
β βββ redis/
β β βββ redisClient.js # Redis client for caching data in-memory
β βββ swagger/
β β βββ swagger.js # Swagger documentation for API endpoints
β βββ .env # Environment variables (git-ignored)
β βββ firebase-admin-sdk.json # Firebase Admin SDK credentials (git-ignored)
β βββ index.js # Main entry point for the server
β βββ Dockerfile # Docker configuration file
β βββ manage_server.sh # Shell script to manage and start the backend server
β βββ README.md # Backend README file
β
βββ frontend/
β βββ public/
β β βββ index.html # Main HTML template
β β βββ manifest.json # Manifest for PWA settings
β βββ src/
β β βββ assets/ # Static assets like images and fonts
β β β βββ logo.png # App logo or images
β β βββ components/
β β β βββ ChatModal.js # Chat modal component
β β β βββ Spinner.js # Loading spinner component
β β β βββ UploadModal.js # Document upload modal component
β β β βββ Navbar.js # Navigation bar component
β β β βββ Footer.js # Footer component
β β β βββ GoogleAnalytics.js # Google Analytics integration component
β β βββ pages/
β β β βββ Home.js # Home page where documents are uploaded
β β β βββ LandingPage.js # Welcome and information page
β β β βββ Login.js # Login page
β β β βββ Register.js # Registration page
β β β βββ ForgotPassword.js # Forgot password page
β β β βββ HowToUse.js # Page explaining how to use the app
β β βββ App.js # Main App component
β β βββ index.js # Entry point for the React app
β β βββ App.css # Global CSS 1
β β βββ index.css # Global CSS 2
β β βββ reportWebVitals.js # Web Vitals reporting
β β βββ styles.css # Custom styles for different components
β β βββ config.js # Configuration file for environment variables
β βββ .env # Environment variables file (e.g., REACT_APP_BACKEND_URL)
β βββ package.json # Project dependencies and scripts
β βββ craco.config.js # Craco configuration file
β βββ Dockerfile # Docker configuration file
β βββ manage_frontend.sh # Shell script for managing and starting the frontend
β βββ README.md # Frontend README file
β βββ package.lock # Lock file for dependencies
β
βββ mobile-app/ # Mobile app directory
β βββ app/ # React Native app directory
β βββ .env # Environment variables file for the mobile app
β βββ app.json # Expo configuration file
β βββ components/ # Reusable components for the mobile app
β βββ assets/ # Static assets for the mobile app
β βββ constants/ # Constants for the mobile app
β βββ hooks/ # Custom hooks for the mobile app
β βββ scripts/ # Scripts for the mobile app
β βββ babel.config.js # Babel configuration file
β βββ package.json # Project dependencies and scripts
β βββ tsconfig.json # TypeScript configuration file
β
βββ aws/ # AWS deployment assets (ECR/ECS/CloudFormation/CDK)
β βββ README.md
β βββ cloudformation/
β β βββ fargate-service.yaml # Reference Fargate stack for backend + ai_ml services
β βββ infrastructure/
β β βββ cdk-app.ts # CDK entrypoint
β β βββ lib/docuthinker-stack.ts # CDK stack definition
β βββ scripts/
β βββ local-env.sh # Helper to mirror production env vars locally
β
βββ kubernetes/ # Kubernetes configuration files
β βββ manifests/ # Kubernetes manifests for deployment, service, and ingress
β βββ backend-deployment.yaml # Deployment configuration for the backend
β βββ backend-service.yaml # Service configuration for the backend
β βββ frontend-deployment.yaml # Deployment configuration for the frontend
β βββ frontend-service.yaml # Service configuration for the frontend
β βββ firebase-deployment.yaml # Deployment configuration for Firebase
β βββ firebase-service.yaml # Service configuration for Firebase
β βββ configmap.yaml # ConfigMap configuration for environment variables
β
βββ nginx/
β βββ nginx.conf # NGINX configuration file for load balancing and caching
β βββ Dockerfile # Docker configuration file for NGINX
β
βββ images/ # Images for the README
βββ .env # Environment variables file for the whole app
βββ docker-compose.yml # Docker Compose file for containerization
βββ jsconfig.json # JavaScript configuration file
βββ package.json # Project dependencies and scripts
βββ package-lock.json # Lock file for dependencies
βββ postcss.config.js # PostCSS configuration file
βββ tailwind.config.js # Tailwind CSS configuration file
βββ render.yaml # Render configuration file
βββ vercel.json # Vercel configuration file
βββ openapi.yaml # OpenAPI specification for API documentation
βββ manage_docuthinker.sh # Shell script for managing and starting the app (both frontend & backend)
βββ .gitignore # Git ignore file
βββ LICENSE.md # License file for the project
βββ README.md # Comprehensive README for the whole app
βββ (and many more files...) # Additional files and directories not listed here
Ensure you have the following tools installed:
.env file - but you should obtain your own API keys for production).Additionally, basic fullstack development knowledge and AI/ML concepts are recommended to understand the appβs architecture and functionalities.
Clone the repository:
git clone https://github.com/hoangsonww/DocuThinker-AI-App.git
cd DocuThinker-AI-App/backend
Navigate to the frontend directory:
cd frontend
Install dependencies:
npm install
Or npm install --legacy-peer-deps if you face any peer dependency issues.
npm start
Build the Frontend React app (for production):
npm run build
yarn to install dependencies and run the app:
yarn install
yarn start
Or, for your convenience, if you have already installed the dependencies, you can directly run the app in the root directory using:
npm run frontend
This way, you donβt have to navigate to the frontend directory every time you want to run the app.
http://localhost:3000. You can now access it in your browser.[!NOTE] Note that this is optional since we are deploying the backend on Render. However, you can (and should) run the backend locally for development purposes.
backend) directory:
cd backend
npm install
Or npm install --legacy-peer-deps if you face any peer dependency issues.
npm run server
http://localhost:3000. You can access the API endpoints in your browser or Postman.backend directory. Feel free to explore the API endpoints and controllers.[!CAUTION] Note: Be sure to use Node v.20 or earlier to avoid compatibility issues with Firebase Admin SDK.
cd mobile-app
npm install
npx expo start
The backend of DocuThinker provides several API endpoints for user authentication, document management, and AI-powered insights. These endpoints are used by the frontend to interact with the backend server:
| Method | Endpoint | Description |
|---|---|---|
| POST | /register |
Register a new user in Firebase Authentication and Firestore, saving their email and creation date. |
| POST | /login |
Log in a user and return a custom token along with the user ID. |
| POST | /upload |
Upload a document for summarization. If the user is logged in, the document is saved in Firestore. |
| POST | /generate-key-ideas |
Generate key ideas from the document text. |
| POST | /generate-discussion-points |
Generate discussion points from the document text. |
| POST | /chat |
Chat with AI using the original document text as context. |
| POST | /forgot-password |
Reset a userβs password in Firebase Authentication. |
| POST | /verify-email |
Verify if a userβs email exists in Firestore. |
| GET | /documents/{userId} |
Retrieve all documents associated with the given userId. |
| GET | /documents/{userId}/{docId} |
Retrieve a specific document by userId and docId. |
| GET | /document-details/{userId}/{docId} |
Retrieve document details (title, original text, summary) by userId and docId. |
| DELETE | /delete-document/{userId}/{docId} |
Delete a specific document by userId and docId. |
| DELETE | /delete-all-documents/{userId} |
Delete all documents associated with the given userId. |
| POST | /update-email |
Update a userβs email in both Firebase Authentication and Firestore. |
| POST | /update-password |
Update a userβs password in Firebase Authentication. |
| GET | /days-since-joined/{userId} |
Get the number of days since the user associated with userId joined the service. |
| GET | /document-count/{userId} |
Retrieve the number of documents associated with the given userId. |
| GET | /user-email/{userId} |
Retrieve the email of a user associated with userId. |
| POST | /update-document-title |
Update the title of a document in Firestore. |
| PUT | /update-theme |
Update the theme of the app. |
| GET | /user-joined-date/{userId} |
Get date when the user associated with userId joined the service. |
| GET | /social-media/{userId} |
Get the social media links of the user associated with userId. |
| POST | /update-social-media |
Update the social media links of the user associated with userId. |
| POST | /update-profile |
Update the userβs profile information. |
| POST | /update-document/{userId}/{docId} |
Update the document details in Firestore. |
| POST | /update-document-summary |
Update the summary of a document in Firestore. |
| POST | /sentiment-analysis |
Analyzes the sentiment of the provided document text |
| POST | /bullet-summary |
Generates a summary of the document text in bullet points |
| POST | /summary-in-language |
Generates a summary in the specified language |
| POST | /content-rewriting |
Rewrites or rephrases the provided document text based on a style |
| POST | /actionable-recommendations |
Generates actionable recommendations based on the document text |
| GET | /graphql |
GraphQL endpoint for querying data from the database |
More API endpoints will be added in the future to enhance the functionality of the app. Feel free to explore the existing endpoints and test them using Postman or Insomnia.
[!NOTE] This list is not exhaustive. For a complete list of API endpoints, please refer to the Swagger or Redoc documentation of the backend server.
http://localhost:5000/api-docs.http://localhost:5000/api-docs/redoc.For example, our API endpoints documentation looks like this:
Additionally, we also offer API file generation using OpenAPI. You can generate API files using the OpenAPI specification. Here is how:
npx openapi-generator-cli generate -i http://localhost:5000/api-docs -g typescript-fetch -o ./api
This will generate TypeScript files for the API endpoints in the api directory. Feel free to replace or modify the command as needed.
/upload endpoint by sending a POST request with the document file as a form-data parameter.curl --location --request POST 'http://localhost:3000/register' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "test@example.com",
"password": "password123"
}'
curl --location --request POST 'http://localhost:3000/upload' \
--header 'Authorization: Bearer <your-token>' \
--form 'File=@"/path/to/your/file.pdf"'
The backend APIs uses centralized error handling to capture and log errors. Responses for failed requests are returned with a proper status code and an error message:
{
"error": "An internal error occurred",
"details": "Error details go here"
}
DocuThinker employs a two-layer agentic architecture that separates orchestration concerns (Node.js) from AI/ML execution (Python), connected by a resilient bridge with circuit breakers, cost controls, and full observability.
| Layer | Technology | Port | Responsibility |
|---|---|---|---|
| Orchestrator | Node.js 18+ / Express | 4000 |
Supervisor routing, agent loops, tool dispatch, cost tracking, MCP |
| AI/ML Backend | Python / FastAPI | 8000 |
LLM inference, RAG pipelines, NER, CrewAI multi-agent, vector/graph stores |
graph TB
subgraph "Clients"
WEB[React Frontend]
EXT[External Agents / MCP]
end
subgraph "Orchestrator :4000"
SUP[Supervisor<br/>classify / decompose / dispatch]
AL[Agent Loop<br/>tool-use cycle up to 10 iters]
CB[Circuit Breaker<br/>CLOSED / OPEN / HALF_OPEN]
CT[Cost Tracker<br/>daily + monthly budgets]
BP[Batch Processor<br/>concurrent doc processing]
DLQ[Dead Letter Queue<br/>retry + DLQ]
HO[Handoff Manager<br/>cross-agent context transfer]
TR[Tool Registry<br/>local + Python-bridge tools]
TB[Token Budget Manager<br/>context window guard]
CS[Conversation Store<br/>auto-summarizing history]
OBS[Context Observability<br/>OTel-compatible metrics]
PC[Prompt Cache Strategy<br/>3-layer Anthropic caching]
MCP_S[MCP Server<br/>13 tools over stdio]
MCP_C[MCP Client<br/>connect to external servers]
end
subgraph "AI/ML Backend :8000"
PY_SVC[DocumentIntelligenceService]
RAG[Agentic RAG Pipeline]
CREW[CrewAI Multi-Agent]
NLP[SpaCy NER / Sentiment]
VEC[ChromaDB Vectors]
KG[Neo4j Knowledge Graph]
end
subgraph "LLM Providers"
CLAUDE[Anthropic Claude]
GEMINI[Google Gemini]
end
WEB -->|REST| SUP
EXT -->|MCP stdio| MCP_S
SUP --> AL
SUP --> BP
AL --> TR
TR -->|Python Bridge| PY_SVC
AL --> CB
CB --> CLAUDE
CB --> GEMINI
CT -.->|budget check| SUP
TB -.->|token check| SUP
DLQ -.->|retry| SUP
HO -.->|context| AL
CS -.->|history| AL
OBS -.->|metrics| CT
PC -.->|cache hints| AL
PY_SVC --> RAG
PY_SVC --> CREW
PY_SVC --> NLP
RAG --> VEC
RAG --> KG
The orchestrator (orchestrator/) is a standalone Node.js service providing:
maxIterations (default 10), calling tools via the Tool Registry and feeding results back until the LLM produces a final response.maxRetries (default 3) before moving to the DLQ for manual inspection.analyze_document_text) and Python-bridged tools (e.g., extract_entities, rag_search, vector_search, knowledge_graph_query, python_sentiment). Tools are exposed to the Agent Loop in Anthropic tool-use format.userId:documentId. Auto-summarizes history when messages exceed 20, evicts LRU conversations beyond 10,000, and builds context-injected message arrays with document context and summaries.cache_control: ephemeral on system prompts, document context, and conversation history.orchestrator/mcp/server.js) β Exposes 13 tools over stdio transport: document_summarize, document_key_ideas, document_sentiment, document_discussion_points, document_analytics, document_bullet_summary, document_rewrite, document_recommendations, document_chat, system_health, system_costs, rag_query, knowledge_graph_query.orchestrator/mcp/client.js) β Connects to external MCP servers via stdio transport, enabling the orchestrator to consume tools from other agents.| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
System health with circuit breaker, cost, cache, DLQ, and provider status |
GET |
/api/costs |
Cost usage report by provider and intent |
GET |
/api/circuits |
Circuit breaker state for all providers |
GET |
/api/context-metrics |
Context utilization and cache hit rate metrics |
GET |
/api/dlq |
Dead letter queue stats and recent messages |
GET |
/api/tools |
Registered tool definitions and count |
POST |
/api/tools/execute |
Execute a registered tool by name |
POST |
/api/token-check |
Check token budget for a given model/prompt/messages |
POST |
/api/supervisor/process |
Route a request through the supervisor pipeline |
POST |
/api/agent/run |
Run the agentic tool-use loop with a message and context |
POST |
/api/batch/process |
Batch process multiple documents (summarize, keyIdeas, sentiment) |
POST |
/api/conversations/:userId/:documentId/message |
Add a message to a conversation |
GET |
/api/conversations/:userId/:documentId |
Retrieve conversation history |
DELETE |
/api/conversations/:userId/:documentId |
Clear a conversation |
[!TIP] Visit the
orchestrator/README.mdfor full API request/response examples and theai_ml/README.mdfor the Python AI/ML layer.
DocuThinker AI agents (and humans) use a Beads sub-architecture to coordinate work across multiple AI agents and humans operating on the same codebase. A bead is a self-contained, dependency-aware task unit that any agent can pick up, execute, and complete β enabling safe parallel development without merge conflicts.
When several AI agents (or human developers) work concurrently, they risk editing the same files and producing conflicting changes. Beads solve this with:
stateDiagram-v2
[*] --> Authored: Bead created from template
Authored --> Claimed: Agent reserves files via .status.json
Claimed --> InProgress: Agent begins implementation
InProgress --> Testing: Code changes complete
Testing --> Done: Acceptance criteria pass
Testing --> InProgress: Tests fail β iterate
Done --> [*]: Reservations released
InProgress --> Blocked: Dependency not met
Blocked --> InProgress: Dependency resolved
.beads/
βββ .status.json # Live agent reservations & bead counters
βββ README.md # Quick-start guide for the beads workflow
βββ templates/
βββ feature-bead.md # Canonical bead template
.beads/.status.json)The status file is the single source of truth for agent coordination:
{
"version": "1.0.0",
"agents": {},
"reservations": {},
"lastUpdated": null,
"beadsCompleted": 0,
"beadsActive": 0
}
| Field | Purpose |
|---|---|
agents |
Map of active agent IDs to their metadata (name, start time, current bead) |
reservations |
Map of file paths to the agent ID that holds the reservation |
beadsCompleted |
Counter of successfully finished beads |
beadsActive |
Counter of beads currently in progress |
Every bead follows a structured template (.beads/templates/feature-bead.md):
| Section | Description |
|---|---|
| Background | Why the work exists |
| Current State | Files to read before starting |
| Desired Outcome | Specific, testable result |
| Files to Touch | Explicit list of files to read, enhance, or create |
| Dependencies | Upstream beads that must finish first and downstream beads this unblocks |
| Acceptance Criteria | Checklist including βall existing tests still passβ |
Certain files are single-agent only β only one agent may hold a reservation at a time:
| Conflict Zone File | Reason |
|---|---|
docker-compose.yml |
Shared service definitions |
ai_ml/services/orchestrator.py |
Central AI/ML entry point |
ai_ml/providers/registry.py |
LLM provider configuration |
orchestrator/index.js |
Orchestrator entry point |
| Shared config files | Cross-service settings |
Safe parallel zones (multiple agents can work simultaneously):
ai_ml/providers/ vs. orchestrator/context/)sequenceDiagram
participant A as Agent
participant S as .status.json
participant C as Codebase
A->>S: 1. Check for conflicts
S-->>A: No reservation on target files
A->>S: 2. Post reservation (agent ID + file list)
A->>C: 3. Implement bead instructions
A->>C: 4. Run tests (acceptance criteria)
A->>S: 5. Release reservations
A->>S: 6. Increment beadsCompleted
Agents must:
.beads/.status.json before starting any work.agent/<agent-name>/<bead-id>.[!NOTE] For the full agent coordination protocol including conflict resolution and escalation, see AGENTS.md. For how beads integrate with the AI/ML pipeline, see AI_ML.md.
Our application supports a fully-featured GraphQL API that allows clients to interact with the backend using flexible queries and mutations. This API provides powerful features for retrieving and managing data such as users, documents, and related information.
https://docuthinker-app-backend-api.vercel.app/graphql
Or, if you are running the backend locally, the endpoint will be:
http://localhost:3000/graphql
Testing the API:
You can use the built-in GraphiQL Interface to test queries and mutations. Simply visit the endpoint in your browser.
You should see the following interface:
Now you can start querying the API using the available fields and mutations. Examples are below for your reference.
This query retrieves a userβs email and their documents, including titles and summaries:
query GetUser {
getUser(id: "USER_ID") {
id
email
documents {
id
title
summary
}
}
}
Retrieve details of a document by its ID:
query GetDocument {
getDocument(userId: "USER_ID", docId: "DOCUMENT_ID") {
id
title
summary
originalText
}
}
Create a user with an email and password:
mutation CreateUser {
createUser(email: "example@domain.com", password: "password123") {
id
email
}
}
Change the title of a specific document:
mutation UpdateDocumentTitle {
updateDocumentTitle(userId: "USER_ID", docId: "DOCUMENT_ID", title: ["Updated Title.pdf"]) {
id
title
}
}
Delete a document from a userβs account:
mutation DeleteDocument {
deleteDocument(userId: "USER_ID", docId: "DOCUMENT_ID")
}
errors field in the response.For more information about GraphQL, visit the official documentation. If you encounter any issues or have questions, feel free to open an issue in our repository.
The DocuThinker mobile app is built using React Native and Expo. It provides a mobile-friendly interface for users to upload documents, generate summaries, and chat with an AI. The mobile app integrates with the backend API to provide a seamless experience across devices.
Currently, it is in development and will be released soon on both the App Store and Google Play Store.
Stay tuned for the release of the DocuThinker mobile app!
Below is a screenshot of the mobile app (in development):
The DocuThinker app can be containerized using Docker for easy deployment and scaling. The docker-compose.yml defines all services including the new agentic orchestrator.
docker compose up --build
You can also view the image in the Docker Hub repository here.
| Service | Container | Port | Description |
|---|---|---|---|
frontend |
docuthinker-frontend |
3001 |
React frontend |
backend |
docuthinker-backend |
3000 |
Express API server |
orchestrator |
docuthinker-orchestrator |
4000 |
Agentic orchestration layer (Node.js) |
ai-ml |
docuthinker-ai-ml |
8000 |
Python AI/ML services (FastAPI) |
redis |
docuthinker-redis |
6379 |
In-memory cache (Redis 7 Alpine) |
firebase |
firebase | β | Firebase emulator |
The orchestrator container includes a health check (/health), runs as a non-root user, and depends on Redis being healthy before starting.
graph TB
A[Docker Compose] --> B[Frontend Container]
A --> C[Backend Container]
A --> O[Orchestrator Container]
A --> ML[AI/ML Container]
A --> D[Redis Container]
A --> F[Firebase Container]
B -->|Port 3001| G[React App]
C -->|Port 3000| H[Express Server]
O -->|Port 4000| I[Agentic Orchestrator]
ML -->|Port 8000| J[FastAPI AI/ML]
D -->|Port 6379| K[Redis Cache]
I -->|Python Bridge| J
I -->|Circuit Breaker| L[Claude / Gemini]
H -->|REST| I
DocuThinker now ships primarily via Kubernetes with blue/green promotion plus weighted canaries driven by the updated Jenkinsfile. Vercel/Render remain as backup endpoints, and AWS ECS Fargate is still available as an alternative target.
graph TB
GIT[GitHub Repo] --> JENKINS[Jenkins Pipeline]
JENKINS --> TEST[Install + Lint + Tests]
TEST --> BUILD[Containerize Frontend + Backend]
BUILD --> REG[Push Images to Registry]
REG --> CANARY[Canary Deploy - 10% weight]
CANARY --> BG[Promote to Blue/Green]
BG --> USERS[Live Traffic]
JENKINS --> VERCEL[Vercel Fallback Deploy]
VERCEL --> USERS
backend-service/frontend-service to the active track (blue by default). Canary traffic is handled by *-canary-service through the weighted ingress (ingress.yaml) using the X-DocuThinker-Canary: always header.${GIT_SHA}-${BUILD_NUMBER}, pushes them to $REGISTRY, deploys the target color (scaled to 3 replicas), and rolls out canaries (1 replica each). Promotion is a gated manual input before the service selector flips to the new color and the previous color scales to 0.To promote manually outside Jenkins:
TARGET=green # or blue
kubectl -n <ns> scale deployment/backend-$TARGET --replicas=3
kubectl -n <ns> scale deployment/frontend-$TARGET --replicas=3
kubectl -n <ns> patch service backend-service -p "{\"spec\": {\"selector\": {\"app\": \"backend\", \"track\": \"$TARGET\"}}}"
kubectl -n <ns> patch service frontend-service -p "{\"spec\": {\"selector\": {\"app\": \"frontend\", \"track\": \"$TARGET\"}}}"
kubectl -n <ns> scale deployment/backend-$( [ "$TARGET" = "blue" ] && echo green || echo blue ) --replicas=0
kubectl -n <ns> scale deployment/frontend-$( [ "$TARGET" = "blue" ] && echo green || echo blue ) --replicas=0
See kubernetes/README.md for the full rollout flow, ingress weighting, and rollback commands.
vercel --prod using the vercel-token credential when the main branch updates.To deploy manually:
npm install -g vercel
vercel --prod
kubernetes/backend-*.yaml, fronted by backend-service and the NGINX ingress canary (ingress.yaml). Vercel (https://docuthinker-app-backend-api.vercel.app/) and Render (https://docuthinker-ai-app.onrender.com/) remain as backup endpoints.$REGISTRY, deploys the next color alongside canary pods, and flips the service selector after manual approval.aws/ still provisions Fargate services if you prefer ECS over Kubernetes.To run the new rollout flow by hand:
kubectl apply -f kubernetes/configmap.yaml
kubectl apply -f kubernetes/backend-service.yaml kubernetes/backend-canary-service.yaml
kubectl apply -f kubernetes/backend-deployment-blue.yaml kubernetes/backend-deployment-green.yaml kubernetes/backend-deployment-canary.yaml
# See kubernetes/README.md for the promotion/rollback commands
nginx directory.npm ci) β lint/test β build β docker build/push ($REGISTRY) β canary deploy β manual promotion to blue/green on Kubernetes, with an optional Vercel deploy as fallback.docuthinker-registry β username/password for the container registry set in REGISTRY.kubeconfig-docuthinker β kubeconfig file used for all kubectl invocations.vercel-token β optional Vercel API token (keeps the legacy deploy available).For local Jenkins bootstrap:
brew install jenkins-lts
brew services start jenkins-lts
open http://localhost:8080
REGISTRY, KUBE_CONTEXT, and KUBE_NAMESPACE as job/env vars, and assign the credentials above. Jenkins will run automatically on every push to main.backend-service/frontend-service to the new track and scales down the previous color after approval.Jenkinsfile for the full stage definitions and environment configuration.If successful, you should see the Jenkins pipeline running tests, pushing images, rolling out the canary, and promoting blue/green automatically whenever changes are merged. Example dashboard:
In addition to Jenkins, we also have a GitHub Actions workflow set up for CI/CD. The workflow is defined in the .github/workflows/ci.yml file.
The GitHub Actions workflow includes the following steps:
vercel-token secret.dockerhub-username and dockerhub-password secrets, as well as to GHCR using the ghcr-token secret.
DocuThinker includes a comprehensive suite of tests to ensure the reliability and correctness of the application. The tests cover various aspects of the app, including:
To run the backend tests, follow these steps:
cd backend
# Run the tests in default mode
npm run test
# Run the tests in watch mode
npm run test:watch
# Run the tests with coverage report
npm run test:coverage
This will run the unit tests and integration tests for the backend app using Jest and Supertest.
To run the frontend tests, follow these steps:
cd frontend
# Run the tests in default mode
npm run test
# Run the tests in watch mode
npm run test:watch
# Run the tests with coverage report
npm run test:coverage
This will run the unit tests and end-to-end tests for the frontend app using Jest and React Testing Library.
kubernetes/*.yaml; see kubernetes/README.md for promotion/rollback commands.kubernetes directory.graph TB
A[Kubernetes Cluster] --> B[Ingress Controller]
B --> C[Frontend Service]
B --> D[Backend Service]
C --> E[Frontend Pods]
D --> F[Backend Pods]
E --> G[Pod 1]
E --> H[Pod 2]
E --> I[Pod 3]
F --> J[Pod 1]
F --> K[Pod 2]
F --> L[Pod 3]
D --> M[ConfigMap]
D --> N[Secrets]
D --> O[Persistent Volume]
O --> P[MongoDB]
O --> Q[Redis]
The DocuThinker Viewer extension brings your document upload, summarization and insightβextraction workflow right into VS Code.
Key Features
To install the extension, follow these steps:
For full install and development steps, configuration options, and troubleshooting, see extension/README.md.
We welcome contributions from the community! Follow these steps to contribute:
Fork the repository.
git checkout -b feature/your-feature
git commit -m "Add your feature"
git push origin feature/your-feature
Thank you for contributing to DocuThinker! π
This project is licensed under the Creative Commons Attribution-NonCommercial License. See the LICENSE file for details.
[!IMPORTANT] The DocuThinker open-source project is for educational purposes only and should not be used for commercial applications. But free to use it for learning and personal projects!
For more information on the DocuThinker app, please refer to the following resources:
However, this README file should already provide a comprehensive overview of the project ~
Here are some information about me - the projectβs humble creator:
Happy Coding and Analyzing! π
Created with β€οΈ by Son Nguyen in 2024-2025. Licensed under the Creative Commons Attribution-NonCommercial License.