Federal Analytics Application
A terminal-based application for fetching and analyzing federal agency web traffic data from the Digital Analytics Program (DAP) API.
Project + Impact + Tools
Built: Modern TUI (Text User Interface) application with secure API key management, intelligent caching, and multi-agency data fetching capabilities
Impact: Streamlines access to federal web analytics across 400+ agencies with progress tracking and sortable results
Tech Stack: Python • Textual Framework • SQLite • REST API Integration • Environment Variable Security
Key Features
Modern Terminal Interface
Built with Textual framework to deliver an app-like experience in the terminal with keyboard shortcuts, mouse support, and clean visual design.
Smart Caching System
Intelligent caching reduces redundant API calls, storing responses locally to minimize load times and API rate limit impacts.
Multi-Agency Analysis
Fetch analytics for individual agencies or pull reports across all 400+ federal agencies at once with visual progress tracking.
Secure API Management
API keys stored in environment variables (excluded from version control) with automatic validation and setup prompts on first run.
15+ Report Types
Access download events, traffic sources, device models, browser data, operating systems, domains, and more from the DAP API.
Technical Implementation
Architecture
Modular Python application with separation of concerns: API utilities handle external calls, cache logic manages data storage, database utilities provide SQLite operations, and the Textual UI layer handles user interactions.
Data Pipeline
User selects agency and report type → Application checks local cache → If cached, return instantly; if not, fetch from API → Store in SQLite database → Display in sortable table view
Security Approach
API keys managed via python-dotenv, stored in .env file automatically added to .gitignore. No credentials ever committed to version control.
Usage Flow
Setup: Clone repository → Install dependencies (python-dotenv, textual) → Run database setup → Launch application
Single Agency Analysis: Select agency from table → Choose report type (e.g., traffic-source, device-model) → Enter date → View results instantly
Bulk Analysis: Select "all agencies" → Choose report type → Watch progress bar → Review summary table with all results
Navigation: Arrow keys or mouse for selection • Tab/Shift+Tab between fields • ESC to close screens • Q to quit • D to toggle dark/light mode
Project Structure
textual_app.py - Main TUI application with screens and widgets
cache_logic.py - Caching system and API request logic
db_utils.py - SQLite database operations and queries
api_utils.py - Helper functions for API interactions
db_setup.py - Database initialization script
federal_analytics.db - SQLite database for agency data
cache_files/ - Directory for cached API responses
Available Analytics Reports
The DAP API provides 15+ report types covering visitor behavior, device usage, and traffic patterns:
Traffic & Sources: traffic-source, domain, site, second-level-domain
Devices: device (desktop/mobile/tablet), device-model
Browsers & OS: browser, os, os-browser, windows-browser, windows, windows-ie
Other: download events, language codes
Get In Touch
Always happy to chat! Feel free to reach out if you have questions about my projects or think I'd be a valuable addition to your team.