A beautiful, AI-powered knowledge base for government contracting built with React, FastAPI, and Google Gemini.
- Intelligent Q&A: Ask questions in natural language and get expert answers
- Semantic Search: Find relevant information across 179 documents instantly
- Source Citations: Every answer includes references to source documents
- Beautiful UI: Apple-inspired design with smooth animations
- Dark Mode: Comfortable viewing in any environment
- RAG Architecture: Retrieval Augmented Generation for accurate responses
- FastAPI: Modern Python web framework
- ChromaDB: Vector database for semantic search
- Google Gemini: AI embeddings and text generation
- python-docx: Word document processing
- React with TypeScript
- Vite: Fast build tool
- Tailwind CSS: Utility-first styling
- Framer Motion: Smooth animations
- TanStack Query: Data fetching and caching
- Python 3.9+
- Node.js 18+
- Google Gemini API key
cd /mnt/c/Users/CharlesMartin/projects/apex-accelerator# Navigate to backend directory
cd backend
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate # On Windows: venv\\Scripts\\activate
# Install dependencies
pip install -r requirements.txtThe Google Gemini API key is stored securely in the .env file:
Location: backend/.env
Your API key has already been configured:
GOOGLE_API_KEY=AIzaSyA5JiLrp9LnJQpFxidL7YyjpdJcOvqcHaA
Important Security Notes:
- ✅ The
.envfile is in.gitignoreand will NOT be committed to git - ✅ Never share your API key publicly
- ✅ If you need to regenerate your key, visit: https://makersuite.google.com/app/apikey
- ✅ A
.env.examplefile is provided as a template for others
# Open new terminal
cd frontend
# Install dependencies
npm installcd backend
# Activate virtual environment
source venv/bin/activate # On Windows: venv\\Scripts\\activate
# Run FastAPI server
python -m uvicorn app.main:app --reloadThe backend will be available at: http://localhost:8000
Before using the chat, you need to index your 179 Word documents:
# In a new terminal or using a tool like Postman/curl
curl -X POST "http://localhost:8000/api/index?documents_path=/path/to/Government%20Contracting"Important: Replace /path/to/Government Contracting with the actual path to your documents folder.
You mentioned your documents are in a folder called "Government Contracting". Please provide the full path so we can index them.
Monitor indexing status:
curl http://localhost:8000/api/index/status# In a new terminal
cd frontend
# Start development server
npm run devThe frontend will be available at: http://localhost:5173
- Open the application at
http://localhost:5173 - Click "Start Chatting" to access the chat interface
- Ask questions about government contracting
- View sources for every answer to verify information
- "What are the requirements for government contracts?"
- "How do I register for SAM?"
- "What is a NAICS code?"
- "Explain the FAR regulations"
apex-accelerator/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI application
│ │ ├── models.py # Pydantic models
│ │ ├── api/
│ │ │ └── routes.py # API endpoints
│ │ └── rag/
│ │ ├── document_processor.py # Word doc extraction
│ │ ├── embeddings.py # Gemini embeddings
│ │ ├── vector_store.py # ChromaDB interface
│ │ └── query_engine.py # RAG logic
│ ├── chroma_db/ # Vector database (generated)
│ ├── .env # API keys (DO NOT COMMIT)
│ └── requirements.txt
│
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── Landing.tsx # Landing page
│ │ │ └── Chat.tsx # Chat interface
│ │ ├── lib/
│ │ │ ├── api.ts # API client
│ │ │ └── utils.ts # Utilities
│ │ ├── App.tsx
│ │ └── main.tsx
│ └── package.json
│
├── documents/ # Your Word documents go here
├── .gitignore
└── README.md
Health check endpoint
Index documents from a directory
- Query Param:
documents_path- Path to documents folder
Get indexing status
Send a chat message
- Body:
{ "message": "your question", "conversation_id": "optional" }
Semantic search
- Body:
{ "query": "search term", "top_k": 5 }
Get knowledge base statistics
Your Gemini API key is securely stored in:
backend/.env
- During Development: The key is automatically loaded from
.env - For Deployment: Set the
GOOGLE_API_KEYenvironment variable
If you need to change your API key:
- Get a new key from: https://makersuite.google.com/app/apikey
- Update
backend/.env:GOOGLE_API_KEY=your_new_key_here - Restart the backend server
- ✅ Never commit
.envto git (already in.gitignore) - ✅ Never share your API key in screenshots or documentation
- ✅ Use environment variables in production
- ✅ Rotate keys regularly
- ✅ Monitor API usage in Google AI Studio
cd backend
# Install production dependencies
pip install -r requirements.txt
# Run with gunicorn
gunicorn app.main:app -w 4 -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000cd frontend
# Build for production
npm run build
# Preview production build
npm run previewThe build output will be in frontend/dist/
Problem: "GOOGLE_API_KEY not found"
- Solution: Check that
backend/.envexists and contains your API key
Problem: "Error processing documents"
- Solution: Ensure documents are valid .docx files and path is correct
Problem: ChromaDB errors
- Solution: Delete
backend/chroma_db/and re-index documents
Problem: "Network Error" or "Connection Refused"
- Solution: Ensure backend is running on
http://localhost:8000
Problem: TypeScript errors
- Solution: Run
npm installagain
- Indexing: Takes ~1-2 minutes per 100 documents
- Query Speed: First query is slower (~3-5s), subsequent queries are faster (~1-2s)
- Embeddings: Cached locally in ChromaDB for instant retrieval
- Chunk Size: Adjust in
document_processor.pyfor better performance
- Document upload via UI
- Conversation history
- Export chat to PDF
- Multi-user support
- Advanced filters
- Document preview modal
- Analytics dashboard
For issues or questions, please refer to the documentation or check the logs:
- Backend logs: Terminal where FastAPI is running
- Frontend logs: Browser console (F12)
Private project for APEX Accelerator
Built with ❤️ using React, FastAPI, and Google Gemini