DocMind is a document question-answering backend built with FastAPI, PostgreSQL, and pgvector.
It provides a backend flow for document upload, text extraction, chunking, embedding generation, vector retrieval, and answer generation with an LLM.
The current public version focuses on text-based document QA.
Included today:
- document upload
- text extraction and chunking
- embedding generation
- vector retrieval with pgvector
- answer generation with an LLM
- basic conversation follow-up handling
- basic async tests for selected application paths
Planned next steps:
- multimodal parsing
- table and image-aware extraction
- stronger citation grounding
- retrieval quality improvements
- production hardening
This repository should be viewed as an MVP backend, not a production-ready system.
What it is good for:
- showing backend architecture and module boundaries
- demonstrating a document QA request flow end to end
- iterating on retrieval and answer generation logic
What it is not yet:
- a fully productionized document intelligence platform
- a complete multimodal document parser
- a benchmarked retrieval system with formal offline evaluation
A simplified view of the backend layout:
backend/
├── app/
│ ├── api/
│ ├── application/
│ ├── core/
│ ├── db/
│ ├── domains/
│ ├── infrastructure/
│ ├── models/
│ └── main.py
├── migrations/
├── tests/
├── pyproject.toml
├── poetry.lock
└── requirements.txt
- API, retrieval, and answer generation are separated into different modules.
- The embedding provider can be switched without changing the main request flow.
- The current implementation favors readability and iteration speed over optimization.
- The repository is intentionally scoped as an MVP backend.
The current request flow is:
- upload a document
- extract text content
- chunk the extracted content
- generate embeddings
- store chunks and vectors in PostgreSQL + pgvector
- retrieve relevant chunks for a query
- generate an answer using retrieved context
- return the answer with supporting context metadata
The current implementation is best described as:
a text-based RAG backend for document QA
- FastAPI
- SQLAlchemy
- PostgreSQL
- pgvector
- Pydantic
- OpenAI API
- Sentence Transformers
- vector similarity search with pgvector
- Poetry
- Python 3.11+
- pip-compatible dependency setup
git clone https://github.com/michael-chow-arch/docmind.git
cd docmind/backendUsing Poetry:
poetry installOr with pip if needed:
pip install -r requirements.txtCreate a .env file in backend/ and configure values such as:
APP_NAME=DocMind
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/docmind
OPENAI_API_KEY=your_api_key_here
EMBEDDING_PROVIDER=sbert
EMBEDDING_DIM=384
AUTO_CREATE_TABLES=trueOnly the embedding provider is configurable (sbert or openai). LLM answers use OpenAI API. Use EMBEDDING_DIM=1536 when EMBEDDING_PROVIDER=openai.
poetry run uvicorn app.main:app --reloadThe current version is suitable for:
- uploading a text-based document
- asking factual questions about document content
- retrieving semantically similar chunks
- experimenting with embedding providers
- demonstrating backend architecture for an AI-enabled document system
Current limitations include:
- the public version is primarily text-oriented
- multimodal asset extraction is not complete
- retrieval quality tuning is still evolving
- evidence grounding is not yet strict enough for high-trust use cases
- some engineering hardening steps are intentionally left for future phases