How abdulhaq6920/fikra-ai works
FIKRA AI is a multi-tenant RAG chatbot: organization members upload documents for asynchronous indexing, then ask questions and receive answers grounded in retrieved passages with validated citations. The map also includes authentication, administration, analytics, and the ingestion and retrieval layers. The README documents the end-to-end worker and infrastructure flow; source excerpts clarify key service calls. Some route and frontend internals were not sampled, so those links are limited to documented relationships.
Main entry points: router.py API router · document_tasks.py Document worker · layout.tsx Next.js application · session.py PostgreSQL and pgvector
Components 26
Web application
- Next.js application
frontend/src/app/layout.tsx - Chat interface
frontend/src/app/(protected)/chat/page.tsx - Documents interface
frontend/src/app/(protected)/documents/page.tsx - Admin and analytics
frontend/src/app/(protected)/admin/page.tsx
API and identity
- API router
backend/app/api/router.py - Authentication routes
backend/app/api/v1/auth.py - Auth service
backend/app/services/auth_service.py - Auth dependencies
backend/app/api/dependencies.py - Document routes
backend/app/api/v1/documents.py - Chat routes
backend/app/api/v1/chat.py - Admin and analytics routes
backend/app/api/v1/admin.py - Insights routes
backend/app/api/v1/admin_insights.py - Insights service
backend/app/services/insights_service.py
Document ingestion
- Document worker
backend/app/workers/document_tasks.py - Extraction and chunking
backend/app/services/ingestion_service.py - Local file storage
backend/app/storage/local_storage.py
Grounded answers
- RAG orchestration
backend/app/services/rag_service.py - Hybrid retrieval
backend/app/services/retrieval_service.py
Data and providers
- PostgreSQL and pgvector
backend/app/db/session.py - Embedding provider
backend/app/providers/embeddings.py - Cross-encoder reranker
backend/app/providers/reranker.py - LLM provider interface
backend/app/providers/llm.py
Other components
- Organization members
- Groq API
- Ollama service
- Redis and Celery queue
Connections 31
- Organization members → Next.js application: uses
README.md - Next.js application → API router: calls API
README.md - API router → Authentication routes: registers
backend/app/api/router.py - API router → Chat routes: registers
backend/app/api/router.py - API router → Document routes: registers
backend/app/api/router.py - API router → Admin and analytics routes: registers
backend/app/api/router.py - API router → Insights routes: registers
backend/app/api/router.py - Authentication routes → Auth service: calls
backend/app/api/v1/auth.py - Chat routes → RAG orchestration: calls
backend/app/api/v1/chat.py - Insights routes → Insights service: calls
backend/app/api/v1/admin_insights.py - Admin and analytics routes → PostgreSQL and pgvector: queries
backend/app/api/v1/admin.py - Document routes → Redis and Celery queue: queues ingestion
README.md - Redis and Celery queue → Document worker: dispatches tasks
README.md - Document worker → Extraction and chunking: calls
backend/app/workers/document_tasks.py - Document worker → Local file storage: uses
backend/app/workers/document_tasks.py - Document worker → Embedding provider: embeds chunks
backend/app/workers/document_tasks.py - Document worker → PostgreSQL and pgvector: persists index
README.md - Chat interface → Next.js application: renders in
- Documents interface → Next.js application: renders in
- Admin and analytics → Next.js application: renders in
- RAG orchestration → Hybrid retrieval: retrieves passages
backend/app/services/rag_service.py - Hybrid retrieval → Embedding provider: embeds query
backend/app/services/retrieval_service.py - Hybrid retrieval → Cross-encoder reranker: reranks results
backend/app/services/retrieval_service.py - Hybrid retrieval → PostgreSQL and pgvector: searches passages
backend/app/services/retrieval_service.py - RAG orchestration → LLM provider interface: generates answer
backend/app/services/rag_service.py - LLM provider interface → Groq API: uses when configured
README.md - LLM provider interface → Ollama service: uses when configured
README.md - RAG orchestration → PostgreSQL and pgvector: loads conversation
backend/app/services/rag_service.py - Authentication routes → Auth dependencies: uses dependencies
backend/app/api/v1/auth.py - Chat routes → Auth dependencies: uses dependencies
backend/app/api/v1/chat.py - Insights routes → PostgreSQL and pgvector: queries
backend/app/api/v1/admin_insights.py