• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
Downchuck

Downchuck

con-juan

Public
Like
con-juan
Home
Code
9
frontend
1
src
6
tests
4
AUTOBOT.md
README.md
H
chat-api.ts
database.ts
H
power-abuse-analyzer.ts
H
static-file-server.ts
Branches
1
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
src
/
README.md
Code
/
src
/
README.md
Search
5/22/2025
Viewing readonly version of main branch: v37
View latest version
README.md

Power Abuse Analyzer - Source Code

This directory contains the source code for the Power Abuse Analyzer application.

Directory Structure

  • analyzer/: Core text analysis functionality

    • index.ts: Main analyzer module with text analysis and pattern detection
  • api/: HTTP API endpoints

    • power-abuse-analyzer.ts: API endpoint for text analysis
    • chat-api.ts: API endpoint for chat sessions and pattern examples
    • static-file-server.ts: Static file server for the frontend
  • database/: Database operations

    • index.ts: SQLite database operations for sessions, messages, patterns, and examples
  • utils/: Utility functions

    • logger.ts: Logging utility
    • error-handler.ts: Error handling and response formatting

Main Components

Analyzer

The analyzer module provides the core functionality for identifying subtle forms of abuse in text. It uses OpenAI's GPT-4o model to analyze text and extract patterns of abuse, manipulation, and problematic language.

Key functions:

  • analyzeText: Analyzes text for subtle forms of abuse
  • handleQuestion: Handles questions about power abuse patterns
  • handlePatternFollowUp: Handles follow-up questions about specific patterns
  • processAIResponse: Processes the AI response into a structured format

Database

The database module provides functions for storing and retrieving data from SQLite. It uses recursive common table expressions (CTEs) to handle threaded conversations.

Key tables:

  • Sessions: Stores chat sessions with titles and timestamps
  • Messages: Stores messages within sessions, with support for threaded conversations
  • Patterns: Stores identified abuse patterns with severity and confidence ratings
  • Examples: Stores examples of patterns, including user-provided examples

API

The API modules provide HTTP endpoints for interacting with the application.

Key endpoints:

  • power-abuse-analyzer: Analyzes text for subtle forms of abuse
  • chat-api: Manages chat sessions, messages, and pattern examples
  • static-file-server: Serves the frontend files

Utils

The utils modules provide utility functions for logging and error handling.

Key utilities:

  • logger: Provides logging functions with different log levels
  • error-handler: Provides error classes and response formatting
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.