73 lines
2.1 KiB
Markdown
73 lines
2.1 KiB
Markdown
# Running the AI-Detection Project
|
|
|
|
This project is a FastAPI-based AI application for detection and RAG (Retrieval-Augmented Generation).
|
|
|
|
## Prerequisites
|
|
- **Python 3.11+** (for local setup)
|
|
- **Docker and Docker Compose** (for containerized setup - Recommended)
|
|
- **PostgreSQL** and **Redis** (if running locally)
|
|
|
|
---
|
|
|
|
## 🚀 Option 1: Running with Docker (Recommended)
|
|
|
|
The easiest way to run the project is using Docker Compose, which sets up the application, database, and Redis automatically.
|
|
|
|
1. **Configure Environment Variables**:
|
|
Copy the example environment file and fill in your keys:
|
|
```bash
|
|
cp .env.example .env
|
|
```
|
|
*Note: Open `.env` and provide your `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` if using AI features.*
|
|
|
|
2. **Start the Services**:
|
|
```bash
|
|
docker-compose up --build
|
|
```
|
|
|
|
3. **Access the API**:
|
|
- **API Documentation (Swagger UI)**: [http://localhost:8000/docs](http://localhost:8000/docs)
|
|
- **Health Check**: [http://localhost:8000/health](http://localhost:8000/health)
|
|
|
|
---
|
|
|
|
## 🛠️ Option 2: Running Locally
|
|
|
|
If you prefer to run the application directly on your machine:
|
|
|
|
1. **Create a Virtual Environment**:
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate # On Windows: venv\Scripts\activate
|
|
```
|
|
|
|
2. **Install Dependencies**:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
3. **Configure Environment Variables**:
|
|
Copy `.env.example` to `.env` and update the settings:
|
|
- Set `DATABASE_URL` to point to your local PostgreSQL instance (e.g., `postgresql://user:pass@localhost:5432/dbname`).
|
|
- Set `REDIS_HOST` to `localhost`.
|
|
|
|
4. **Run the Application**:
|
|
```bash
|
|
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
|
|
```
|
|
|
|
---
|
|
|
|
## 📂 Project Structure Highlights
|
|
- `main.py`: Entry point of the FastAPI application.
|
|
- `src/config/`: Configuration management and startup migrations.
|
|
- `src/services/`: Core business logic (RAG, JWT, etc.).
|
|
- `src/migrations/`: Database schema definitions.
|
|
- `docker-compose.yml`: Multi-container orchestration.
|
|
|
|
## 🧪 Testing
|
|
To run tests, ensure dependencies are installed and run:
|
|
```bash
|
|
pytest
|
|
```
|