Secure & Intelligent Criminal Investigations powered by Aptos, IPFS, Vertex AI, Gemini, and BigQuery.
Project for the HackerEarth Thunderdome Hackathon
This application provides a secure way to store PDF files on IPFS, extract meaningful data from them, and store both metadata on the Aptos blockchain and text chunks in BigQuery for efficient searching and RAG-based chatting. At its core, BlockPatrol is a revolutionary platform designed to empower police officers and investigators with decentralized storage, AI-driven semantic search, immutable logging, and intelligent pattern recognition.
Traditional methods of storing and analyzing criminal case files are often:
- Insecure: Prone to tampering, data loss, or unauthorized access when stored in physical archives or basic web portals.
- Inefficient: Requiring officers to manually sift through mountains of paperwork or disparate digital files, consuming valuable time.
- Siloed: Making it difficult to identify patterns, connect related cases, or share information effectively.
BlockPatrol addresses these challenges head-on.
BlockPatrol offers a comprehensive suite of features:
- PDF Storage: Upload PDF files to IPFS for decentralized storage.
- Data Extraction: Extract structured data from PDFs using FastAPI.
- Immutable Evidence Logging on Aptos Blockchain: Crucial metadata such as key evidence, file hash, and officer details are recorded immutably on Aptos.
- Text Chunk Storage & Embeddings: Store chunks of PDF text in BigQuery; generate embeddings using Gemini or Vertex AI for efficient semantic search.
- AI-Powered Semantic Search & RAG-Based Chat: Retrieve semantically similar cases and chat with documents using LLMs.
- Secure Authentication: JWT-based FastAPI authentication ensures only authorized personnel access sensitive data.
- Decentralized File Storage (IPFS)
- Immutable Metadata (Aptos Blockchain)
- Semantic Search (BigQuery + Vertex AI/Gemini Embeddings)
- RAG-Based Chat with Documents
- Cross-Case Pattern Matching
- Secure Authentication with JWT
- Investigation Dashboard and Case Linking
[User: Officer/Investigator] | |--- Upload PDF ---> [IPFS (Decentralized Storage)] | |--- Returns IPFS Hash | |--- Extract Metadata + Store IPFS Hash ---> [Aptos Blockchain] | |--- Chunk File + Generate Embeddings ---> [Gemini / Vertex AI] | |--- Store in ---> [Google BigQuery] | |--- Officer Search Query ---> [FastAPI Endpoint] |--- Semantic Match ---> [BigQuery Embeddings] |--- Display Relevant Cases + Chat + Links
| Layer | Technology |
|---|---|
| Backend Framework | FastAPI (Python) |
| Authentication | JWT |
| Storage | IPFS |
| Blockchain | Aptos |
| Embeddings | Google Vertex AI or Gemini API |
| Data Store | Google BigQuery |
| Frontend | (Specify: React, Vue, Streamlit, etc.) |
- Python 3.8+
- FastAPI
- Google Cloud account (BigQuery)
- Aptos account and private key
- Gemini API key (for LLM chat)
- IPFS Node (local or remote)
-
Clone the repository:
git clone https://github.com/your-org/blockpatrol.git cd blockpatrol -
Install dependencies:
pip install -r requirements.txt
-
Create a
.envfile:# BigQuery BQ_PROJECT_ID=your-google-cloud-project-id BQ_DATASET=your-bigquery-dataset BQ_TABLE=your-bigquery-table GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json # Gemini API GEMINI_API_KEY=your-gemini-api-key # Aptos APTOS_NODE_URL=https://fullnode.devnet.aptoslabs.com/v1 ADMIN_PRIVATE_KEY=your-admin-private-key
-
Create the BigQuery table:
CREATE TABLE `your-project-id.your-dataset.your-table` ( chunk_id STRING, doc_id STRING, filename STRING, text STRING, original_pdf_ipfs_path STRING, pdf_metadata STRING );
uvicorn app.main:app --reloadAccess API docs at: http://localhost:8000/docs
POST /auth/register: Register a new userPOST /auth/token: Login and get access token
POST /documents/upload: Upload a PDF fileGET /documents/my-documents: Get your uploaded documentsGET /documents/documents/{document_id}: Retrieve specific documentPOST /documents/search: Search by transaction hash or Aptos addressGET /documents/ipfs/{ipfs_hash}: Retrieve file from IPFS
-
POST /documents/search-chunks{ "query": "your search term", "limit": 10 } -
POST /documents/chat{ "query": "your question about the documents", "history": [ {"role": "user", "content": "previous question"}, {"role": "assistant", "content": "previous answer"} ] }
- Log in using your officer credentials.
- Upload a new case file (PDF).
- The file is stored on IPFS; metadata is logged on Aptos.
- Chunks of text and embeddings are generated and stored in BigQuery.
- Use search or chat to interact with case files, uncover similar crimes, or identify patterns.
- Predictive AI Analytics
- Real-time Officer Collaboration
- GeoCrime Mapping (GIS)
- Per-Evidence Upload and Blockchain Anchoring
- Mobile App for Investigators
- Create a GCP Project
- Enable BigQuery API
- Create Service Account with permissions
- Download JSON Key
- Set
GOOGLE_APPLICATION_CREDENTIALSin.env - Create dataset and table as described
- Sign up at https://ai.google.dev
- Get an API Key
- Set
GEMINI_API_KEYin.env
- Saves Investigators Time
- Enhances Evidence Security
- Uncovers Hidden Crime Patterns
- Tamper-Proof Audit Trails
- Empowers Law Enforcement with AI
MIT License
Built for the HackerEarth Thunderdome Hackathon.