Your first configuration
This guide walks through building a complete Hyperterse configuration for a typical application, in this case a user management system with authentication and analytics.
Configuration formats
Section titled “Configuration formats”Hyperterse configuration is defined in a single YAML-like Terse file with the .terse extension. Read the configuration reference for more details.
Building a user management API
Section titled “Building a user management API”Let’s look at a complete configuration for a user management system.
-
Define your adapters
Adapters are database connections. You can define multiple adapters for different databases:
config.terse name: user-management-apiadapters:# Primary PostgreSQL databasemain_db:connector: postgresconnection_string: 'postgresql://app_user:secret@localhost:5432/myapp'options:max_connections: '10'ssl_mode: 'prefer'# Redis for cachingcache:connector: redisconnection_string: 'redis://localhost:6379/0' -
Create user queries
Add queries for common user operations:
config.terse queries:# List users with paginationlist-users:use: main_dbdescription: 'List all users with pagination'statement: |SELECT id, name, email, role, created_atFROM usersORDER BY created_at DESCLIMIT {{ inputs.limit }}OFFSET {{ inputs.offset }}inputs:limit:type: intdescription: 'Maximum number of results'optional: truedefault: '20'offset:type: intdescription: 'Number of results to skip'optional: truedefault: '0'# Get single user by IDget-user-by-id:use: main_dbdescription: 'Retrieve a user by their unique ID'statement: |SELECT id, name, email, role, created_at, updated_atFROM usersWHERE id = {{ inputs.userId }}inputs:userId:type: intdescription: 'Unique user identifier'# Search users by emailfind-user-by-email:use: main_dbdescription: 'Find a user by email address'statement: |SELECT id, name, email, roleFROM usersWHERE email = {{ inputs.email }}inputs:email:type: stringdescription: 'Email address to search for' -
Add analytics queries
config.terse queries:# User signup statisticsuser-signups-by-date:use: main_dbdescription: 'Get user signup counts grouped by date'statement: |SELECTDATE(created_at) as date,COUNT(*) as signupsFROM usersWHERE created_at >= {{ inputs.startDate }}AND created_at <= {{ inputs.endDate }}GROUP BY DATE(created_at)ORDER BY date DESCinputs:startDate:type: datetimedescription: 'Start of date range (ISO 8601)'endDate:type: datetimedescription: 'End of date range (ISO 8601)'# Active users countactive-users-count:use: main_dbdescription: 'Count users who logged in within a timeframe'statement: |SELECT COUNT(DISTINCT user_id) as active_usersFROM sessionsWHERE last_activity > {{ inputs.since }}inputs:since:type: datetimedescription: 'Count users active since this time' -
Server configuration (optional)
Configure server settings:
config.terse server:port: '8080'log_level: 3 # 1=ERROR, 2=WARN, 3=INFO, 4=DEBUG
Complete example
Section titled “Complete example”Here’s the full configuration file:
name: user-management-api
server: port: '8080' log_level: 3
adapters: main_db: connector: postgres connection_string: 'postgresql://app_user:secret@localhost:5432/myapp' options: max_connections: '10'
queries: list-users: use: main_db description: 'List all users with pagination' statement: | SELECT id, name, email, role, created_at FROM users ORDER BY created_at DESC LIMIT {{ inputs.limit }} OFFSET {{ inputs.offset }} inputs: limit: type: int optional: true default: '20' offset: type: int optional: true default: '0'
get-user-by-id: use: main_db description: 'Retrieve a user by their unique ID' statement: | SELECT id, name, email, role, created_at, updated_at FROM users WHERE id = {{ inputs.userId }} inputs: userId: type: int description: 'Unique user identifier'
find-user-by-email: use: main_db description: 'Find a user by email address' statement: | SELECT id, name, email, role FROM users WHERE email = {{ inputs.email }} inputs: email: type: string description: 'Email address'
user-signups-by-date: use: main_db description: 'Get user signup counts grouped by date' statement: | SELECT DATE(created_at) as date, COUNT(*) as signups FROM users WHERE created_at >= {{ inputs.startDate }} AND created_at <= {{ inputs.endDate }} GROUP BY DATE(created_at) ORDER BY date DESC inputs: startDate: type: datetime description: 'Start of date range' endDate: type: datetime description: 'End of date range'Run and test
Section titled “Run and test”Hyperterse can be run in development mode with hot reload:
hyperterse dev -f config.terseOr in production mode:
hyperterse run -f config.terseTo test your queries, you can either test via the HTTP API using cURL or connect it to an agent and ask it to call the tool via MCP.
# List userscurl -X POST http://localhost:8080/query/list-users \ -H "Content-Type: application/json" \ -d '{"limit": 10, "offset": 0}'
# Get specific usercurl -X POST http://localhost:8080/query/get-user-by-id \ -H "Content-Type: application/json" \ -d '{"userId": 1}'
# View auto-generated documentationcurl http://localhost:8080/docs