> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spn.wtf/llms.txt
> Use this file to discover all available pages before exploring further.

# SPN - Local Setup

> Get SPN running locally in under 5 minutes

## Prerequisites

* **Docker & Docker Compose** — for running the backend and database
* **Node.js 18+** — for the frontend
* **Git**

***

## 1. Clone and Configure

```bash theme={null}
git clone https://github.com/sahyogi/spn.git
cd spn
cp .env.example .env
```

Edit `.env` with your credentials:

```env theme={null}
# Database
POSTGRES_SERVER=localhost
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=spn_db

# Sanity CMS
SANITY_PROJECT_ID=your_project_id
SANITY_DATASET=production
SANITY_TOKEN=your_token

# AWS S3
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
S3_BUCKET_NAME=your_bucket
AWS_REGION=eu-north-1

# Security
SESSION_SECRET=your-random-secret-key
GEMINI_API_KEY=your_gemini_key
```

***

## 2. Start the Backend

```bash theme={null}
cd backend
docker-compose up -d --build
```

<Check>
  Backend is running at **[http://localhost:8000](http://localhost:8000)**
  Interactive API docs at **[http://localhost:8000/docs](http://localhost:8000/docs)**
  PostgreSQL available on **localhost:5432**
</Check>

***

## 3. Run Database Migrations

```bash theme={null}
docker compose exec api alembic upgrade head
```

***

## 4. Start the Frontend

```bash theme={null}
cd frontend
npm install
npm run dev
```

<Check>
  Frontend running at **[http://localhost:5173](http://localhost:5173)**
</Check>

***

## 5. Verify Everything Works

```bash theme={null}
curl http://localhost:8000/api/v1/system/health
# → { "status": "healthy" }
```

Then open [http://localhost:5173](http://localhost:5173) and register a new account.

***

## Optional: Sanity Studio

Sanity handles rich media (logos, galleries) only. You can skip this for backend-only development.

```bash theme={null}
cd sanity-studio
npm install
npx sanity login
npm run dev
# → http://localhost:3333
```

***

## Running Tests

<CodeGroup>
  ```bash Backend theme={null}
  cd backend
  pytest tests/ -v
  ```

  ```bash Frontend theme={null}
  cd frontend
  npm test
  ```
</CodeGroup>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Architecture" icon="sitemap" href="/architecture">
    Understand the PostgreSQL-first system design
  </Card>

  <Card title="API Reference" icon="code" href="/api/overview">
    Explore all available endpoints
  </Card>

  <Card title="Deployment" icon="server" href="/guides/deployment">
    Deploy to production with Docker + Caddy
  </Card>

  <Card title="Testing" icon="flask" href="/guides/testing">
    Backend and frontend test setup
  </Card>
</CardGroup>
