File size: 7,794 Bytes
4343907
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# SAAP Quick Start Guide

**satware Autonomous Agent Platform (SAAP)** - Local multi-agent orchestration platform

## ⚠️ CRITICAL SECURITY NOTICE

**Before running the project, you MUST remediate hardcoded API keys!**

The imported codebase contains **40+ hardcoded API keys** that must be replaced with environment variables before:
- Running the application
- Pushing to GitHub
- Deploying to any environment

**πŸ“‹ Action Required:** See `SECURITY_REMEDIATION_REQUIRED.md` for detailed remediation steps.

---

## Prerequisites

### Required Software

1. **Python 3.10 or higher**
   ```bash
   python3 --version  # Should be 3.10+
   ```

2. **Node.js 18 or higher**
   ```bash
   node --version  # Should be v18+
   npm --version
   ```

3. **PostgreSQL Database**
   ```bash
   psql --version
   ```
   - Installation: https://www.postgresql.org/download/

4. **Git** (for version control)
   ```bash
   git --version
   ```

### Optional (Recommended)

- **Redis** (for caching and message queuing)
- **Docker** (for containerized deployment)
- **Docker Compose** (for multi-service orchestration)

---

## Installation Steps

### 1. Clone the Repository

```bash
git clone https://github.com/satwareAG/saap.git
cd saap
```

### 2. Backend Setup

#### 2.1 Create Python Virtual Environment

```bash
# Create virtual environment
python3 -m venv .venv

# Activate it
source .venv/bin/activate  # On Linux/macOS
# OR
.venv\Scripts\activate  # On Windows
```

#### 2.2 Install Python Dependencies

```bash
pip install --upgrade pip
pip install -r requirements.txt
```

#### 2.3 Configure Environment Variables

```bash
# Copy the example environment file
cp backend/.env.example backend/.env

# Edit the .env file with your settings
nano backend/.env  # or use your preferred editor
```

**Required Configuration:**

```env
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/saap_db

# AI Provider API Keys (⚠️ SECURITY: Never commit these!)
OPENROUTER_API_KEY=your_openrouter_api_key_here
COLOSSUS_API_KEY=your_colossus_api_key_here

# Application Settings
DEBUG=True
LOG_LEVEL=INFO
```

#### 2.4 Set Up Database

```bash
# Create PostgreSQL database
createdb saap_db

# Run migrations (if applicable)
cd backend
alembic upgrade head
cd ..
```

### 3. Frontend Setup

#### 3.1 Install Node.js Dependencies

```bash
cd frontend
npm install
cd ..
```

---

## Starting the Application

### Option 1: Using Startup Scripts (Recommended)

#### Start Backend
```bash
./start_backend.sh
```

The backend will be available at:
- **API:** http://localhost:8000
- **API Docs (Swagger):** http://localhost:8000/docs
- **API Docs (ReDoc):** http://localhost:8000/redoc

#### Start Frontend (in a new terminal)
```bash
./start_frontend.sh
```

The frontend will be available at:
- **Application:** http://localhost:5173

### Option 2: Manual Start

#### Start Backend Manually
```bash
# Activate virtual environment
source .venv/bin/activate  # Linux/macOS
# OR
.venv\Scripts\activate  # Windows

# Load environment variables
export $(cat backend/.env | grep -v '^#' | xargs)

# Start server
cd backend
python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
```

#### Start Frontend Manually
```bash
cd frontend
npm run dev
```

---

## Verifying the Installation

### 1. Check Backend Health

```bash
curl http://localhost:8000/health
# Expected: {"status": "healthy"}
```

### 2. Access API Documentation

Open in browser: http://localhost:8000/docs

### 3. Access Frontend Application

Open in browser: http://localhost:5173

---

## Project Structure

```
saap/
β”œβ”€β”€ backend/                    # Python FastAPI Backend
β”‚   β”œβ”€β”€ agents/                 # AI Agent implementations
β”‚   β”‚   β”œβ”€β”€ colossus_agent.py   # Colossus (local) agent
β”‚   β”‚   └── openrouter_agent*.py # OpenRouter agents
β”‚   β”œβ”€β”€ api/                    # API endpoints
β”‚   β”œβ”€β”€ database/               # Database models & services
β”‚   β”œβ”€β”€ services/               # Business logic services
β”‚   β”œβ”€β”€ .env.example            # Environment template
β”‚   └── main.py                 # FastAPI application entry
β”‚
β”œβ”€β”€ frontend/                   # Vue.js 3 Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/         # Vue components
β”‚   β”‚   β”œβ”€β”€ views/              # Page views
β”‚   β”‚   β”œβ”€β”€ stores/             # Pinia state management
β”‚   β”‚   └── services/           # API client services
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js          # Vite configuration
β”‚
β”œβ”€β”€ start_backend.sh            # Backend startup script
β”œβ”€β”€ start_frontend.sh           # Frontend startup script
β”œβ”€β”€ requirements.txt            # Python dependencies
└── README.md                   # Full documentation
```

---

## Common Issues & Troubleshooting

### Issue: `ModuleNotFoundError` when starting backend

**Solution:** Ensure virtual environment is activated and dependencies installed:
```bash
source .venv/bin/activate
pip install -r requirements.txt
```

### Issue: Port already in use (8000 or 5173)

**Solution:** Kill the process using the port:
```bash
# Find process using port 8000
lsof -i :8000  # or: netstat -tulpn | grep 8000

# Kill the process
kill -9 <PID>
```

### Issue: Database connection errors

**Solution:** 
1. Verify PostgreSQL is running: `systemctl status postgresql`
2. Check DATABASE_URL in `backend/.env`
3. Ensure database exists: `createdb saap_db`

### Issue: Frontend shows "Network Error"

**Solution:** 
1. Verify backend is running on port 8000
2. Check CORS settings in `backend/main.py`
3. Check browser console for specific errors

### Issue: Hardcoded API keys detected

**Solution:** 
1. **DO NOT push to GitHub yet!**
2. Follow `SECURITY_REMEDIATION_REQUIRED.md`
3. Replace all hardcoded keys with environment variables
4. Re-scan with Gitleaks: `gitleaks detect --no-git`

---

## Development Workflow

### Running Tests

**Backend Tests:**
```bash
cd backend
pytest
```

**Frontend Tests:**
```bash
cd frontend
npm test
```

### Code Quality Checks

**Backend (Python):**
```bash
# Linting
ruff check .

# Type checking
mypy backend/
```

**Frontend (JavaScript/TypeScript):**
```bash
cd frontend
npm run lint
```

---

## Security Best Practices

### πŸ”’ Essential Security Rules

1. **Never commit API keys** to version control
2. **Always use environment variables** for sensitive data
3. **Run Gitleaks** before every commit:
   ```bash
   gitleaks detect --no-git
   ```
4. **Update dependencies regularly**:
   ```bash
   pip list --outdated  # Python
   npm outdated         # Node.js
   ```
5. **Use strong passwords** for database and services
6. **Enable HTTPS** in production environments

---

## Next Steps

After successful startup:

1. βœ… **Complete Security Remediation** (see `SECURITY_REMEDIATION_REQUIRED.md`)
2. βœ… **Configure all agents** in the dashboard
3. βœ… **Test agent orchestration** with sample tasks
4. βœ… **Review API documentation** at http://localhost:8000/docs
5. βœ… **Set up development database** with test data
6. βœ… **Configure Redis/RabbitMQ** (optional, for advanced features)

---

## Additional Resources

- **Full Documentation:** `README.md`
- **Security Remediation:** `SECURITY_REMEDIATION_REQUIRED.md`
- **Import Notes:** `IMPORT_NOTES.md`
- **API Documentation:** http://localhost:8000/docs (when running)
- **Project Repository:** https://github.com/satwareAG/saap

---

## Support & Contact

- **Student:** Hanan Wandji Danga
- **Organization:** satware AG
- **Project:** Master's Thesis - SAAP Platform
- **Timeline:** 2025-09-15 to 2026-03-14

For issues or questions, please create an issue on the GitHub repository.

---

**Last Updated:** 2025-11-11