Scira offers extensive configuration options to customize the application for your specific requirements. This guide covers application settings, database configuration, search providers, and user preferences.
Application Settings
Next.js Configuration
The main application configuration is in next.config.ts:
const nextConfig : NextConfig = {
compiler: {
removeConsole: process . env . NODE_ENV === 'production'
? { exclude: [ 'error' ] }
: false ,
},
reactCompiler: true ,
experimental: {
turbopackFileSystemCacheForDev: true ,
turbopackFileSystemCacheForBuild: true ,
optimizePackageImports: [
'@phosphor-icons/react' ,
'lucide-react' ,
'@hugeicons/react' ,
'date-fns' ,
],
serverActions: {
bodySizeLimit: '20mb' ,
},
staleTimes: {
dynamic: 10 ,
static: 30 ,
},
},
};
Key Configuration Options
Removes console statements in production builds (except errors)
Enables the React compiler for optimized builds
experimental.serverActions.bodySizeLimit
Maximum size for server action payloads (set to 20MB for file uploads)
experimental.optimizePackageImports
Packages to optimize for faster imports and smaller bundle sizes
Scira configures security headers automatically:
async headers () {
return [
{
source: '/(.*)' ,
headers: [
{
key: 'X-Content-Type-Options' ,
value: 'nosniff' ,
},
{
key: 'X-Frame-Options' ,
value: 'DENY' ,
},
{
key: 'Referrer-Policy' ,
value: 'strict-origin-when-cross-origin' ,
},
],
},
];
}
Image Configuration
Next.js image optimization is configured for external sources:
images : {
qualities : [ 75 , 100 ],
dangerouslyAllowSVG : true ,
remotePatterns : [
{
protocol: 'https' ,
hostname: '**' ,
},
],
deviceSizes : [ 640 , 750 , 828 , 1080 , 1200 , 1920 , 2048 , 3840 ],
imageSizes : [ 16 , 32 , 48 , 64 , 96 , 128 , 256 , 384 ],
formats : [ 'image/webp' ],
minimumCacheTTL : 60 ,
}
Database Configuration
Scira uses Drizzle ORM with PostgreSQL . The configuration is in drizzle.config.ts:
import { defineConfig } from 'drizzle-kit' ;
export default defineConfig ({
schema: './lib/db/schema.ts' ,
out: './drizzle/migrations' ,
dialect: 'postgresql' ,
dbCredentials: {
url: process . env . DATABASE_URL ! ,
} ,
}) ;
Database Schema
Path to the database schema file (./lib/db/schema.ts)
Directory for generated migrations (./drizzle/migrations)
Database dialect - PostgreSQL
Database connection URL from DATABASE_URL environment variable
Connection Pooling
For production, configure connection pooling in your database URL:
# Example with PgBouncer
DATABASE_URL = "postgresql://user:password@host:6432/database?pgbouncer=true"
# Example with connection pool size
DATABASE_URL = "postgresql://user:password@host:5432/database?pool_size=20"
Search Provider Preferences
Scira supports multiple search providers. Users can configure their preferred providers through user preferences.
Available Search Providers
Exa AI-powered search with semantic understanding
Parallel High-performance parallel web and Reddit search
Tavily Web search optimized for AI applications
Firecrawl Web scraping with structured data extraction
Provider Configuration
Set your search provider API keys in environment variables:
EXA_API_KEY = your_exa_api_key
TAVILY_API_KEY = your_tavily_api_key
FIRECRAWL_API_KEY = your_firecrawl_api_key
Custom Instructions
Users can configure custom instructions to personalize AI responses. Custom instructions are stored per user in the database.
Custom Instructions Schema
From lib/db/schema.ts:
export const customInstructions = pgTable ( 'custom_instructions' , {
id: text ( 'id' ). primaryKey (). $defaultFn (() => generateId ()),
userId: text ( 'user_id' )
. notNull ()
. references (() => user . id , { onDelete: 'cascade' }),
content: text ( 'content' ). notNull (),
createdAt: timestamp ( 'created_at' ). notNull (). defaultNow (),
updatedAt: timestamp ( 'updated_at' ). notNull (). defaultNow (),
});
Using Custom Instructions
Custom instructions allow users to:
Define preferred response formats
Set domain-specific context
Configure tone and style preferences
Add recurring research requirements
User Preferences Structure
User preferences are stored in the user_preferences table with a flexible JSON structure.
Preferences Schema
From lib/db/schema.ts:
export const userPreferences = pgTable ( 'user_preferences' , {
id: text ( 'id' ). primaryKey (). $defaultFn (() => generateId ()),
userId: text ( 'user_id' )
. notNull ()
. unique ()
. references (() => user . id , { onDelete: 'cascade' }),
preferences: json ( 'preferences' )
. $type <{
'scira-search-provider' ?: 'exa' | 'parallel' | 'tavily' | 'firecrawl' ;
'scira-extreme-search-provider' ?: 'exa' | 'parallel' ;
'scira-group-order' ?: string [];
'scira-model-order-global' ?: string [];
'scira-blur-personal-info' ?: boolean ;
'scira-custom-instructions-enabled' ?: boolean ;
'scira-location-metadata-enabled' ?: boolean ;
}>()
. notNull ()
. default ({}),
createdAt: timestamp ( 'created_at' ). notNull (). defaultNow (),
updatedAt: timestamp ( 'updated_at' ). notNull (). defaultNow (),
});
Available Preferences
Preferred search provider: exa, parallel, tavily, or firecrawl
scira-extreme-search-provider
Provider for extreme/deep search: exa or parallel
Custom ordering for search mode groups
Preferred ordering for AI models
Whether to blur personal information in the UI
scira-custom-instructions-enabled
Enable/disable custom instructions for AI responses
scira-location-metadata-enabled
Enable/disable location metadata in searches
Rate Limiting
Scira uses Upstash Redis for rate limiting:
// From lib/auth.ts
export const auth = betterAuth ({
rateLimit: {
max: 100 ,
window: 60 ,
},
// ... other config
});
Maximum number of requests (100)
Time window in seconds (60)
CORS and Trusted Origins
Configure allowed origins for authentication:
// From lib/auth.ts
trustedOrigins : [
'http://localhost:3000' ,
'https://scira.ai' ,
'https://www.scira.ai'
],
allowedOrigins : [
'http://localhost:3000' ,
'https://scira.ai' ,
'https://www.scira.ai'
]
Update trustedOrigins and allowedOrigins to include your production domain when deploying.
Environment-Specific Configuration
Scira uses environment-specific configuration through env/server.ts and env/client.ts:
import { createJiti } from 'jiti' ;
const jiti = createJiti ( fileURLToPath ( import . meta . url ));
jiti . import ( './env/server.ts' );
jiti . import ( './env/client.ts' );
This ensures:
Server-only environment variables remain secure
Client variables are properly exposed with NEXT_PUBLIC_ prefix
Type-safe environment variable access
Validation at build time
Turbopack Configuration
turbopack : {
resolveAlias : {
'#default-font/*' : '@mathjax/mathjax-newcm-font/mjs/*' ,
},
resolveExtensions : [ '.js' , '.jsx' , '.ts' , '.tsx' , '.mjs' , '.cjs' , '.json' ],
}
Package Transpilation
transpilePackages : [
'geist' ,
'@daytonaio/sdk' ,
'shiki' ,
'resumable-stream' ,
'@t3-oss/env-nextjs' ,
'@t3-oss/env-core' ,
'@mathjax/src' ,
'@mathjax/mathjax-newcm-font' ,
]
External Server Packages
serverExternalPackages : [
'@aws-sdk/client-s3' ,
'prettier'
]
Next Steps