A production-grade, permission-aware knowledge assistant built for secure organizational document search and question answering.
SecureKnowledge combines multi-tenant access control, hybrid retrieval, cited answers, document ingestion, evaluations, audit logs, and production-oriented observability.
The main goal is to demonstrate how a reliable AI knowledge assistant should be designed when documents have different visibility rules.
A user must never retrieve, cite, summarize, or indirectly access information from a document they are not authorized to view.
Permission filtering happens during retrieval, before document chunks are passed to the language model.
- Multi-tenant organizations and workspaces
- User, group, workspace, and document-level permissions
- PDF and text document ingestion
- Asynchronous document processing
- PostgreSQL full-text search
- Vector search with pgvector
- Hybrid retrieval and result fusion
- Answers with document and passage citations
- Answer abstention when evidence is insufficient
- Conversation history
- Retrieval traces
- Token, latency, and cost tracking
- Administrative review interface
- Audit logs
- Evaluation datasets and automated evaluation runs
- Authorization-leakage tests
SecureKnowledge is organized as a monorepo with three independently deployable applications.
secure-knowledge/
├── apps/
│ ├── api/
│ ├── worker/
│ └── web/
├── packages/
│ └── secure-knowledge-core/
├── infrastructure/
├── tests/
├── docs/
├── docker-compose.yml
└── README.md
The FastAPI application handles:
- authentication
- organizations and workspaces
- users, roles, and memberships
- document metadata
- permission management
- query orchestration
- conversations
- audit and administration endpoints
The worker handles asynchronous jobs such as:
- document extraction
- text normalization
- chunking
- embedding generation
- indexing
- document reprocessing
- evaluation runs
- cleanup tasks
Cleanup periods, preserved aggregates, and organization-specific audit requirements are documented in the data retention policy.
The React and TypeScript application provides:
- authentication
- workspace management
- document upload
- permission management
- knowledge-assistant interface
- citations
- conversation history
- retrieval review
- evaluation dashboards
- audit-log views
The API and worker use a shared Python package containing:
- configuration and logging
- database models and repositories
- authorization policies
- ingestion pipelines
- retrieval logic
- model-provider integrations
- evaluation tooling
- Python
- FastAPI
- Pydantic
- SQLAlchemy
- Alembic
- PostgreSQL
- pgvector
- Redis
- LLM APIs
- embeddings
- PostgreSQL full-text search
- vector similarity search
- hybrid retrieval
- reciprocal-rank fusion
- optional reranking
- structured model outputs
- retrieval and answer evaluations
- React
- TypeScript
- Vite
- TanStack Query
- React Router
- Docker
- Docker Compose
- AWS
- S3
- RDS
- ECS Fargate
- ElastiCache
- CloudWatch
- GitHub Actions
Authorization is enforced before retrieval results reach the language model.
Incorrect approach:
Retrieve relevant documents
↓
Ask the model not to reveal restricted information
SecureKnowledge approach:
Authenticate user
↓
Resolve organization and workspace permissions
↓
Determine authorized documents
↓
Retrieve only authorized chunks
↓
Generate a cited answer
The model never receives unauthorized document content.
The planned authorization model includes:
- organization membership
- organization roles
- workspace membership
- workspace roles
- group membership
- organization-wide documents
- workspace-visible documents
- group-restricted documents
- user-restricted documents
- owner-only documents
The project is currently in the foundation stage.
Implemented or in progress:
- monorepo structure
- API, worker, and web applications
- shared Python package
- Docker Compose environment
- PostgreSQL setup
- SQLAlchemy models
- Alembic migrations
- users
- organizations
- organization memberships
- workspaces
- workspace memberships
- authentication
- JWT access tokens
- initial tenancy rules
- authentication
- organizations
- workspaces
- memberships
- tenant isolation
- authorization tests
- groups
- document visibility
- user-level document permissions
- centralized authorization service
- access-control integration tests
- uploads
- object storage
- PDF and text extraction
- document versioning
- chunking
- embeddings
- asynchronous processing
- vector retrieval
- full-text retrieval
- hybrid retrieval
- permission-aware filtering
- result fusion
- retrieval traces
- structured outputs
- citations
- abstention
- conversations
- streaming responses
- token and cost tracking
- evaluation datasets
- retrieval recall
- citation correctness
- groundedness
- answer relevance
- abstention quality
- unauthorized retrieval rate
- retrieval review interface
- audit-log interface
- usage dashboard
- AWS deployment
- CI/CD
- threat model
- architecture documentation
- Python 3.12+
- uv
- Node.js
- Docker
- Docker Compose
Clone the repository:
git clone https://github.com/richardj46/secure-knowledge
cd secure-knowledgeCreate the environment file:
cp .env.example .envInstall Python dependencies:
uv syncStart PostgreSQL, Redis, API, worker, and web applications:
docker compose up --buildAPI health endpoint:
http://localhost:8000/health
Frontend:
http://localhost:5173
API documentation:
http://localhost:8000/docs
Run the ingestion worker locally:
uv run celery \
-A secure_knowledge_worker.celery_app:celery_app \
worker \
--loglevel=INFORun tests:
uv run pytestRun lint checks:
uv run ruff check .Run formatting checks:
uv run ruff format --check .Run type checking:
uv run mypy .Apply database migrations:
uv run alembic \
-c infrastructure/database/alembic.ini \
upgrade headCreate a migration:
uv run alembic \
-c infrastructure/database/alembic.ini \
revision \
--autogenerate \
-m "describe migration"This project is designed to demonstrate production AI application engineering skills, including:
- secure multi-tenant architecture
- authentication and authorization
- relational data modelling
- asynchronous processing
- retrieval-augmented generation
- hybrid search
- AI evaluation
- auditability
- observability
- cost and latency controls
- cloud deployment
- human review workflows
The initial version will not include:
- unrestricted autonomous agents
- internet browsing
- OCR-heavy scanned documents
- fine-tuning
- Slack or Teams synchronization
- Google Drive synchronization
- complex billing
- many model providers
- large-scale distributed vector infrastructure
This project is licensed under the MIT License.