Navix Backend - PostgreSQL Setup Guide
Setup Instructions
1. Install PostgreSQL
Windows:
# Download from https://www.postgresql.org/download/windows/
# Or use chocolatey:
choco install postgresql
Linux/WSL:
sudo apt update
sudo apt install postgresql postgresql-contrib
macOS:
brew install postgresql
2. Start PostgreSQL Service
Windows:
# PostgreSQL should start automatically as a service
# Or start manually:
pg_ctl -D "C:\Program Files\PostgreSQL\{version}\data" start
Linux/WSL:
sudo service postgresql start
macOS:
brew services start postgresql
3. Create Database and Schema
# Run the schema file as postgres superuser
psql -U postgres -f backend/schema.sql
# This will:
# 1. Create a dedicated 'navix_user' database user
# 2. Create the 'navix' database owned by navix_user
# 3. Create all tables and schemas
# 4. Grant appropriate privileges
# IMPORTANT: Change the password in the SQL file before running!
# Edit backend/schema.sql and change 'navix_secure_password_change_me' to a strong password
4. Configure Environment Variables
Copy .env.example to .env and update with your settings:
cp .env.example .env
Edit .env with your actual database credentials and JWT secret key.
5. Install Python Dependencies
cd backend
pip install -r requirements.txt
6. Run the Backend
python main.py
API Endpoints
Authentication
POST /api/auth/register- Register new userPOST /api/auth/login- Login and get JWT tokenGET /api/auth/me- Get current user info (requires auth)
Sections
GET /api/sections- Get all sections with apps (requires auth)POST /api/sections- Create new section (requires auth)
Apps
POST /api/apps- Create new app (requires auth)PUT /api/apps/{app_id}- Update app (requires auth)DELETE /api/apps/{app_id}- Delete app (requires auth)
Legacy (YAML-based)
GET /api/apps- Get apps from YAML filePOST /api/add_app- Add app to YAML filePOST /api/edit_app- Edit app in YAML filePOST /api/delete_app- Delete app from YAML file
Authentication Flow
- Register:
POST /api/auth/registerwith{username, email, password} - Login:
POST /api/auth/loginwith{username, password}→ Returns JWT token - Use Token: Include in Authorization header:
Bearer {token}
Testing with cURL
# Register
curl -X POST http://localhost:8000/api/auth/register \
-H "Content-Type: application/json" \
-d '{"username":"testuser","email":"test@example.com","password":"password123"}'
# Login
curl -X POST http://localhost:8000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"testuser","password":"password123"}'
# Get sections (use token from login)
curl -X GET http://localhost:8000/api/sections \
-H "Authorization: Bearer YOUR_TOKEN_HERE"
Database Schema
- users: User accounts with authentication
- sections: User-specific app sections
- apps: Applications within sections
Each user has their own personal view with their own sections and apps.