File size: 4,609 Bytes
09fa60b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# AudioForge Setup Guide

Complete setup guide to get AudioForge running locally without errors.

## Prerequisites

- **Python 3.11+** (check with `python --version`)
- **Node.js 20+** (check with `node --version`)
- **PostgreSQL 16+** (or use Docker)
- **Redis 7+** (or use Docker)
- **Docker & Docker Compose** (optional, recommended)

## Quick Start (Docker)

The easiest way to get started:

```bash

# Clone and navigate to project

cd AudioForge



# Start all services

docker-compose up -d



# Backend will be at http://localhost:8000

# Frontend will be at http://localhost:3000

```

## Manual Setup

### Backend Setup

#### Windows (PowerShell)

```powershell

cd backend

.\scripts\setup.ps1

```

#### Linux/macOS

```bash

cd backend

chmod +x scripts/setup.sh

./scripts/setup.sh

```

#### Manual Steps

1. **Create virtual environment:**
```bash

cd backend

python -m venv .venv

# Windows

.venv\Scripts\activate

# Linux/macOS

source .venv/bin/activate

```

2. **Install dependencies:**
```bash

# Install uv (modern Python package manager)

pip install uv



# Install project dependencies

uv pip install -e ".[dev]"

```

3. **Configure environment:**
```bash

# Copy example env file

cp .env.example .env



# Edit .env with your settings

# At minimum, set DATABASE_URL and REDIS_URL

```

4. **Start PostgreSQL and Redis:**

**Option A: Docker**
```bash

docker-compose up -d postgres redis

```

**Option B: Local Installation**
- Install PostgreSQL and start service
- Install Redis and start service
- Update `.env` with connection URLs

5. **Run database migrations:**
```bash

alembic upgrade head

```

6. **Start backend server:**
```bash

uvicorn app.main:app --reload

```

Backend will be available at http://localhost:8000
API docs at http://localhost:8000/api/docs

### Frontend Setup

1. **Install dependencies:**
```bash

cd frontend

pnpm install

# or: npm install

```

2. **Configure environment:**
```bash

# Create .env.local

echo "NEXT_PUBLIC_API_URL=http://localhost:8000" > .env.local

```

3. **Start development server:**
```bash

pnpm dev

# or: npm run dev

```

Frontend will be available at http://localhost:3000

## Verification

### Backend Health Check

```bash

curl http://localhost:8000/health

# Should return: {"status":"healthy","version":"0.1.0"}

```

### Frontend Check

Open http://localhost:3000 in your browser. You should see the AudioForge interface.

## Common Issues & Solutions

### Issue: Database Connection Error

**Solution:**
- Ensure PostgreSQL is running: `docker-compose ps` or `pg_isready`
- Check DATABASE_URL in `.env` matches your PostgreSQL setup

- Verify database exists: `createdb audioforge` (if needed)



### Issue: Redis Connection Error



**Solution:**

- Ensure Redis is running: `docker-compose ps` or `redis-cli ping`

- Check REDIS_URL in `.env`
- Redis is optional for basic functionality

### Issue: Model Loading Errors

**Solution:**
- MusicGen models download automatically on first use (can be slow)
- Ensure sufficient disk space (~2GB for models)
- For CPU-only: Set `MUSICGEN_DEVICE=cpu` in `.env`
- Models load lazily - first generation may take longer

### Issue: Port Already in Use

**Solution:**
- Backend: Change port in `uvicorn` command or `.env`
- Frontend: Change port in `next.config.js` or use `pnpm dev -p 3001`
- Stop conflicting services

### Issue: Import Errors

**Solution:**
- Ensure virtual environment is activated
- Reinstall dependencies: `uv pip install -e ".[dev]"`
- Check Python version: `python --version` (needs 3.11+)

### Issue: Frontend Build Errors

**Solution:**
- Clear cache: `rm -rf .next node_modules`
- Reinstall: `pnpm install`
- Check Node version: `node --version` (needs 20+)

## Development Workflow

1. **Backend changes:** Server auto-reloads with `--reload` flag
2. **Frontend changes:** Next.js hot-reloads automatically
3. **Database changes:** Create migration: `alembic revision --autogenerate -m "description"`
4. **Apply migrations:** `alembic upgrade head`

## Testing

### Backend Tests
```bash

cd backend

pytest tests/ -v

```

### Frontend Tests
```bash

cd frontend

pnpm test

```

## Production Deployment

See `ARCHITECTURE.md` for production deployment considerations.

## Getting Help

- Check logs: Backend logs to console, check for errors
- API docs: http://localhost:8000/api/docs
- Review `ARCHITECTURE.md` for system design
- Check `CONTRIBUTING.md` for development guidelines