File size: 2,321 Bytes
9a2b1cd
 
 
 
 
 
 
 
 
 
 
0bd9dbc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a165d29
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
title: AIResearchAssistant
emoji: πŸ‘€
colorFrom: purple
colorTo: gray
sdk: docker
pinned: false
license: mit
short_description: ResearchAssistant
---

# AI Research Assistant β€” Unified Project

This repository contains both the frontend and backend parts of the AI Research Assistant project, structured for single-port Docker deployment (e.g. Hugging Face Spaces, Render, or self-hosted Docker).

## Repository Structure

- `AI_Research_Assistant-frontend/` β€” React SPA frontend (built with Vite + TypeScript)
- `AI_Research_Assistant-backend/` β€” FastAPI backend (handles text extraction, vector embeddings, Gemini Q&A, and reports)
- `Dockerfile` β€” Multi-stage build that compiles the React frontend and serves it directly through the FastAPI backend on port 7860.

---

## Local Development (Without Docker)

You can run both services independently on localhost:

### 1. Run the Backend
```bash
cd AI_Research_Assistant-backend
python -m venv venv
source venv/bin/activate  # On Windows: .\venv\Scripts\Activate.ps1
pip install -r requirements.txt
python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
```
Make sure to configure the `.env` file inside `AI_Research_Assistant-backend/` with your `GEMINI_API_KEY`.

### 2. Run the Frontend
```bash
cd AI_Research_Assistant-frontend
npm install
npm run dev
```

---

## Running with Docker Locally

To build and run the unified container locally:

1. Build the Docker image:
   ```bash
   docker build -t ai-research-assistant .
   ```

2. Run the container (pass your Gemini API key as an environment variable):
   ```bash
   docker run -p 7860:7860 -e GEMINI_API_KEY="your-gemini-api-key" ai-research-assistant
   ```

3. Open your browser and navigate to:
   * **App**: `http://localhost:7860/`
   * **API Docs**: `http://localhost:7860/docs`

---

## Deployment to Hugging Face Spaces

1. Create a new **Docker** Space on Hugging Face.
2. In the repository settings of the Space, add your `GEMINI_API_KEY` under the **Repository Secrets**.
3. Push the files in this repository (the `main` branch) to the Space's Git remote. Hugging Face will automatically trigger the Docker build using the root `Dockerfile` and run the app on port 7860.

Check out the Hugging Face configuration reference at https://huggingface.co/docs/hub/spaces-config-reference