A full-stack Retrieval-Augmented Generation (RAG) application that lets users upload PDF documents and have intelligent conversations about them, powered by Google Gemini and FastAPI.
- PDF Upload & Processing — Upload any PDF and it gets converted into vector embeddings via FAISS
- Conversational AI — Chat with your document using Google Gemini 2.5 Flash
- Full Auth System — JWT-based authentication with signup and login
- Persistent Chat History — All conversations saved to PostgreSQL, resumable anytime
- ChatGPT-like Sidebar — Switch between multiple document chats
- React Frontend — Clean, dark-themed UI built with Vite + React
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite |
| Backend | FastAPI, Python 3.12 |
| AI Model | Google Gemini 2.5 Flash |
| Vector Store | FAISS |
| Database | PostgreSQL 16 |
| ORM | SQLAlchemy + Alembic |
| Auth | JWT (PyJWT) + bcrypt |
docmind/
├── app.py # FastAPI main application
├── config.py # Environment config
├── requirements.txt # Python dependencies
│
├── api/
│ ├── auth.py # Signup & login routes
│ └── security.py # JWT token validation
│
├── dbsetup/
│ ├── db_config.py # Database connection
│ ├── models.py # SQLAlchemy models
│ └── migrations/ # Alembic migrations
│
├── dependencies/
│ ├── prepare_pdf.py # PDF → FAISS vector index
│ └── prepare_prompt.py # RAG prompt builder
│
└── frontend/ # React application
└── src/
└── App.jsx # Main UI component
- Python 3.12
- Node.js 20+
- PostgreSQL 16
- Google Gemini API key — get one at aistudio.google.com
git clone https://github.com/YOUR_USERNAME/docmind.git
cd docmindpython -m venv gemni_env
source gemni_env/bin/activate
pip install -r requirements.txtsudo -u postgres psqlCREATE DATABASE rag_app;
CREATE USER your_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE rag_app TO your_user;
\qCreate a .env file in the root directory:
DATABASE_URL=postgresql://your_user:your_password@localhost/rag_app
SECRET_KEY=your_super_secret_key_here
ALGORITHEM=HS256
API_KEY=your_google_gemini_api_key
PORT=8000alembic upgrade headpython app.pyBackend runs at http://localhost:8000
Swagger docs at http://localhost:8000/docs
cd frontend
npm install
npm run devFrontend runs at http://localhost:5173
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/user/auth/signup |
Register new user |
| POST | /api/v1/user/auth/login |
Login, returns JWT token |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/upload |
Upload a PDF, creates a chat session |
| POST | /api/chat |
Send a message in a session |
| GET | /api/chat/sessions |
Get all sessions for the user |
| GET | /api/chat/{session_id}/messages |
Get full message history |
User uploads PDF
↓
PDF split into chunks → embedded into vectors → saved as FAISS index (named by session_id)
↓
User sends a message
↓
Relevant chunks retrieved from FAISS → injected into Gemini prompt
↓
Gemini responds using document context
↓
Both messages saved to PostgreSQL
↓
User can resume any past conversation from the sidebar
| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string |
SECRET_KEY |
Secret key for signing JWT tokens |
ALGORITHEM |
JWT algorithm (e.g. HS256) |
API_KEY |
Google Gemini API key |
PORT |
Port for uvicorn (default 8000) |
MIT License — feel free to use and modify.