Development Setup
Development Setup
Section titled “Development Setup”This guide will help you set up your local development environment for contributing to Querri.
Prerequisites
Section titled “Prerequisites”- Docker Desktop (required)
- Git
- Node.js 18+ (for running frontend outside Docker)
- Python 3.11+ (for running backend outside Docker)
- Poetry (for Python dependency management)
Primary Development Workflow
Section titled “Primary Development Workflow”IMPORTANT: Always use Docker for development. The Docker setup includes hot reloading for both frontend and backend services.
First Time Setup
Section titled “First Time Setup”- Clone the repository
git clone https://github.com/querri/querri-stack.gitcd querri-stack/Querri- Get the .env file
Request the .env file from your team lead and place it in the root directory.
- Set version environment variables
source scripts/set-version-env.sh- Build and start the development stack
# First time only - builds all containersdocker compose -f docker-compose.dev.yml up --build
# Subsequent startsdocker compose -f docker-compose.dev.yml up- Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Traefik Dashboard: http://localhost:8080
Daily Development
Section titled “Daily Development”The Docker stack should remain running. It provides:
- Frontend hot reloading - SvelteKit auto-reloads on file changes
- Backend hot reloading - FastAPI auto-reloads on Python file changes
- Database persistence - MongoDB data persists across restarts
- Complete service mesh - All microservices running together
Stopping the Development Environment
Section titled “Stopping the Development Environment”# Press Ctrl+C in terminal, ordocker compose downClean Rebuild
Section titled “Clean Rebuild”Only when explicitly needed:
docker compose -f docker-compose.dev.yml down --volumesdocker compose -f docker-compose.dev.yml up --buildCode Organization
Section titled “Code Organization”Frontend (/Querri/web-app)
Section titled “Frontend (/Querri/web-app)”web-app/├── src/│ ├── routes/ # SvelteKit pages│ │ ├── project/ # Project editor│ │ ├── dashboard/ # Dashboard viewer│ │ └── settings/ # Settings pages│ ├── lib/│ │ ├── components/ # Reusable components│ │ │ ├── panels/ # Chat, settings panels│ │ │ ├── ui/ # UI components│ │ │ └── dataFlow/ # Visual workflow editor│ │ ├── api/ # API client classes│ │ ├── stores/ # Svelte stores│ │ └── utils/ # Utility functions│ ├── app.css # Global styles│ └── app.html # HTML template├── static/ # Static assets└── package.jsonBackend (/Querri/server-api)
Section titled “Backend (/Querri/server-api)”server-api/├── api/│ ├── routes/ # API endpoints│ │ ├── projects_routes.py│ │ ├── steps_routes.py│ │ ├── chat_routes.py│ │ └── files_routes.py│ ├── models/ # Pydantic models│ ├── services/ # Business logic│ └── main.py # FastAPI app├── querri_core/ # Core data processing│ ├── steps/ # Step implementations│ ├── qdf/ # Querri Data Frame│ └── connectors/ # Data connectors├── tests/ # Test suite└── pyproject.toml # Poetry configDevelopment Patterns
Section titled “Development Patterns”Frontend Development
Section titled “Frontend Development”State Management
Section titled “State Management”Use Svelte stores for shared state:
import { writable } from 'svelte/store';
export const projects = writable([]);export const currentProject = writable(null);API Integration
Section titled “API Integration”Use the API client classes:
import { QProjects } from '$lib/api/projects';
// In your componentconst project = await QProjects.get(uuid);await QProjects.update(uuid, { name: 'New Name' });Component Lifecycle
Section titled “Component Lifecycle”<script> import { onMount, onDestroy } from 'svelte';
let data = [];
onMount(async () => { // Load data data = await fetchData(); });
onDestroy(() => { // Cleanup });</script>Backend Development
Section titled “Backend Development”Async/Await Pattern
Section titled “Async/Await Pattern”All database operations should be async:
from motor.motor_asyncio import AsyncIOMotorClient
async def get_project(project_id: str): db = get_database() return await db.projects.find_one({"uuid": project_id})Dependency Injection
Section titled “Dependency Injection”Use FastAPI’s dependency injection:
from fastapi import Dependsfrom api.deps import get_current_user
@router.get("/projects")async def list_projects( user = Depends(get_current_user)): # user is automatically injected return await get_user_projects(user.id)Error Handling
Section titled “Error Handling”Use HTTPException for API errors:
from fastapi import HTTPException
if not project: raise HTTPException( status_code=404, detail="Project not found" )Pydantic Models
Section titled “Pydantic Models”Define request/response models:
from pydantic import BaseModel
class ProjectCreate(BaseModel): name: str description: str | None = None
class ProjectResponse(BaseModel): uuid: str name: str owner_id: strTesting
Section titled “Testing”Frontend Tests
Section titled “Frontend Tests”cd web-app
# Unit tests with Vitestnpm run test
# E2E tests with Playwrightnpm run test:ui
# E2E against Docker environmentnpm run test:dockerBackend Tests
Section titled “Backend Tests”cd server-api
# Run all testspoetry run pytest
# With coveragepoetry run pytest --cov=api --cov=querri_core
# Specific test filepoetry run pytest tests/test_projects.py
# Type checkingpoetry run mypy .Code Quality
Section titled “Code Quality”Linting and Formatting
Section titled “Linting and Formatting”Frontend
Section titled “Frontend”cd web-appnpm run lint # ESLintnpm run format # PrettierBackend
Section titled “Backend”cd server-apipoetry run black . # Format codepoetry run isort . # Sort importspoetry run flake8 . # Lintingpoetry run mypy . # Type checkingPre-commit Hooks
Section titled “Pre-commit Hooks”Install pre-commit hooks to run checks automatically:
# In repository rootpip install pre-commitpre-commit installDebugging
Section titled “Debugging”Frontend Debugging
Section titled “Frontend Debugging”Use browser DevTools:
- Open Chrome/Firefox DevTools
- Set breakpoints in Sources tab
- Use
console.log()for quick debugging - Check Network tab for API calls
Backend Debugging
Section titled “Backend Debugging”VS Code
Section titled “VS Code”Add to .vscode/launch.json:
{ "version": "0.2.0", "configurations": [ { "name": "FastAPI", "type": "python", "request": "launch", "module": "uvicorn", "args": [ "api.main:app", "--reload", "--host", "0.0.0.0", "--port", "8000" ], "cwd": "${workspaceFolder}/server-api" } ]}Logging
Section titled “Logging”Use Python logging:
import logging
logger = logging.getLogger(__name__)
logger.info("Processing project", extra={"project_id": uuid})logger.error("Failed to save", exc_info=True)Contributing Guidelines
Section titled “Contributing Guidelines”Branch Strategy
Section titled “Branch Strategy”main- Production-ready codedevelop- Integration branchfeature/*- New featuresbugfix/*- Bug fixeshotfix/*- Production hotfixes
Commit Messages
Section titled “Commit Messages”Follow conventional commits:
feat: add dashboard export featurefix: resolve CORS error on file uploaddocs: update installation guidetest: add tests for project sharingchore: update dependenciesPull Request Process
Section titled “Pull Request Process”- Create feature branch from
develop - Make your changes
- Add tests for new functionality
- Run linting and tests
- Create PR against
develop - Request review from team members
- Address feedback
- Merge after approval
Common Issues
Section titled “Common Issues”Port Already in Use
Section titled “Port Already in Use”# Find process using portlsof -i :5173
# Kill processkill -9 <PID>Database Connection Failed
Section titled “Database Connection Failed”Check MongoDB is running:
docker ps | grep mongodocker logs querri_mongo_1Frontend Won’t Build
Section titled “Frontend Won’t Build”Clear cache and rebuild:
cd web-apprm -rf node_modules .svelte-kitnpm installBackend Import Errors
Section titled “Backend Import Errors”Reinstall dependencies:
cd server-apipoetry install