Skip to content
This repository was archived by the owner on Dec 11, 2025. It is now read-only.

Alexandria-s-Design/government-contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

APEX Accelerator - Government Contracting AI Assistant

A beautiful, AI-powered knowledge base for government contracting built with React, FastAPI, and Google Gemini.

Features

  • 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

Tech Stack

Backend

  • FastAPI: Modern Python web framework
  • ChromaDB: Vector database for semantic search
  • Google Gemini: AI embeddings and text generation
  • python-docx: Word document processing

Frontend

  • React with TypeScript
  • Vite: Fast build tool
  • Tailwind CSS: Utility-first styling
  • Framer Motion: Smooth animations
  • TanStack Query: Data fetching and caching

Prerequisites

  • Python 3.9+
  • Node.js 18+
  • Google Gemini API key

Installation

1. Clone the Repository

cd /mnt/c/Users/CharlesMartin/projects/apex-accelerator

2. Set Up Backend

# 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.txt

3. Configure API Key

The 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 .env file is in .gitignore and 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.example file is provided as a template for others

4. Set Up Frontend

# Open new terminal
cd frontend

# Install dependencies
npm install

Running the Application

Step 1: Start the Backend

cd backend

# Activate virtual environment
source venv/bin/activate  # On Windows: venv\\Scripts\\activate

# Run FastAPI server
python -m uvicorn app.main:app --reload

The backend will be available at: http://localhost:8000

Step 2: Index Your Documents

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

Step 3: Start the Frontend

# In a new terminal
cd frontend

# Start development server
npm run dev

The frontend will be available at: http://localhost:5173

Usage

  1. Open the application at http://localhost:5173
  2. Click "Start Chatting" to access the chat interface
  3. Ask questions about government contracting
  4. View sources for every answer to verify information

Example Questions

  • "What are the requirements for government contracts?"
  • "How do I register for SAM?"
  • "What is a NAICS code?"
  • "Explain the FAR regulations"

Project Structure

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

API Endpoints

GET /api/

Health check endpoint

POST /api/index

Index documents from a directory

  • Query Param: documents_path - Path to documents folder

GET /api/index/status

Get indexing status

POST /api/chat

Send a chat message

  • Body: { "message": "your question", "conversation_id": "optional" }

POST /api/search

Semantic search

  • Body: { "query": "search term", "top_k": 5 }

GET /api/stats

Get knowledge base statistics

API Key Management

Where Your API Key is Stored

Your Gemini API key is securely stored in:

backend/.env

Accessing Your API Key

  1. During Development: The key is automatically loaded from .env
  2. For Deployment: Set the GOOGLE_API_KEY environment variable

Rotating Your API Key

If you need to change your API key:

  1. Get a new key from: https://makersuite.google.com/app/apikey
  2. Update backend/.env:
    GOOGLE_API_KEY=your_new_key_here
    
  3. Restart the backend server

Security Best Practices

  • ✅ Never commit .env to 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

Building for Production

Backend

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:8000

Frontend

cd frontend

# Build for production
npm run build

# Preview production build
npm run preview

The build output will be in frontend/dist/

Troubleshooting

Backend Issues

Problem: "GOOGLE_API_KEY not found"

  • Solution: Check that backend/.env exists 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

Frontend Issues

Problem: "Network Error" or "Connection Refused"

  • Solution: Ensure backend is running on http://localhost:8000

Problem: TypeScript errors

  • Solution: Run npm install again

Performance Tips

  • 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.py for better performance

Future Enhancements

  • Document upload via UI
  • Conversation history
  • Export chat to PDF
  • Multi-user support
  • Advanced filters
  • Document preview modal
  • Analytics dashboard

Support

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)

License

Private project for APEX Accelerator


Built with ❤️ using React, FastAPI, and Google Gemini

About

APEX Accelerator - AI-powered Government Contracting Knowledge Base

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors