Skip to content

AI-powered UN GA speech analysis tool for UN OSAA's Intergovernmental team. Generates daily readouts from member state speeches using LLM with curated prompts aligned to UN OSAA priorities. Supports PDF, DOCX, MP3 files.

License

Notifications You must be signed in to change notification settings

MafiAtUN/osaa-unga-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

60 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

UNGA Analysis App

Production-ready analysis platform for UN General Assembly speeches

Python 3.13 Streamlit License

🎯 Overview

The UNGA Analysis App is a comprehensive platform for analyzing United Nations General Assembly speeches from 1946 to 2025. It provides advanced AI-powered analysis, cross-year trend analysis, document context analysis, and interactive visualizations for UN member states and development partners.

✨ Features

πŸ” Authentication & User Management

  • Secure user registration and authentication
  • Admin portal for user management
  • Role-based access control
  • Session management

πŸ“Š Core Analysis Features

  • New Analysis: AI-powered speech analysis with multiple models
  • Cross-Year Analysis: Historical trend analysis across 80 years
  • Document Context: Upload and analyze documents with context
  • Database Chat: Direct interaction with UNGA database
  • Visualizations: Interactive charts and graphs
  • Data Explorer: Comprehensive data exploration tools

🌍 Data Coverage

  • 11,093 speeches from 1946-2025
  • 199 countries represented
  • 80 years of historical data
  • Complete embeddings for semantic search
  • African vs Development Partner classification

πŸ€– AI Capabilities

  • Multiple AI model support (GPT-4, Claude, etc.)
  • Semantic search with embeddings
  • Document classification
  • Sentiment analysis
  • Topic extraction
  • Cross-reference analysis

πŸ—οΈ Architecture

unga_analysis/
β”œβ”€β”€ src/unga_analysis/          # Main application package
β”‚   β”œβ”€β”€ core/                   # Core business logic
β”‚   β”‚   β”œβ”€β”€ auth.py            # Authentication
β”‚   β”‚   β”œβ”€β”€ classify.py        # Document classification
β”‚   β”‚   β”œβ”€β”€ enhanced_search_engine.py  # Advanced search
β”‚   β”‚   β”œβ”€β”€ llm.py             # LLM integration
β”‚   β”‚   β”œβ”€β”€ openai_client.py   # OpenAI client
β”‚   β”‚   β”œβ”€β”€ prompts.py         # AI prompts
β”‚   β”‚   β”œβ”€β”€ startup.py         # Application startup
β”‚   β”‚   └── user_auth.py       # User authentication
β”‚   β”œβ”€β”€ data/                   # Data management
β”‚   β”‚   β”œβ”€β”€ cross_year_analysis.py  # Cross-year analysis
β”‚   β”‚   β”œβ”€β”€ data_ingestion.py  # Data ingestion
β”‚   β”‚   β”œβ”€β”€ ingest.py          # Data processing
β”‚   β”‚   └── simple_vector_storage.py  # Vector database
β”‚   β”œβ”€β”€ ui/                     # User interface
β”‚   β”‚   β”œβ”€β”€ auth_interface.py   # Authentication UI
β”‚   β”‚   β”œβ”€β”€ components/         # UI components
β”‚   β”‚   β”œβ”€β”€ tabs/              # Tab implementations
β”‚   β”‚   β”œβ”€β”€ ui_components.py   # UI utilities
β”‚   β”‚   └── unified_search_interface.py  # Search interface
β”‚   β”œβ”€β”€ utils/                  # Utilities
β”‚   β”‚   β”œβ”€β”€ country_manager.py  # Country management
β”‚   β”‚   β”œβ”€β”€ export_utils.py     # Export functionality
β”‚   β”‚   β”œβ”€β”€ logging_config.py  # Logging configuration
β”‚   β”‚   β”œβ”€β”€ security.py        # Security utilities
β”‚   β”‚   β”œβ”€β”€ utils.py           # General utilities
β”‚   β”‚   └── visualization.py   # Visualization utilities
β”‚   └── config/                 # Configuration
β”‚       β”œβ”€β”€ countries.py        # Country definitions
β”‚       └── questions.py        # Analysis questions
β”œβ”€β”€ tests/                      # Test suite
β”œβ”€β”€ docs/                       # Documentation
β”œβ”€β”€ scripts/                    # Deployment scripts
β”œβ”€β”€ artifacts/                  # Data artifacts
β”œβ”€β”€ requirements.txt           # Dependencies
β”œβ”€β”€ main.py                    # Application entry point
└── README.md                  # This file

πŸš€ Quick Start

Prerequisites

  • Python 3.13+
  • Virtual environment (recommended)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd unga-analysis-app
  2. Create virtual environment

    python3 -m venv unga80
    source unga80/bin/activate  # On Windows: unga80\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up environment variables

    cp env.template .env
    # Edit .env with your configuration
  5. Initialize database

    python setup_database.py
  6. Run the application

    python main.py
    # Or: streamlit run main.py

Default Admin Access

πŸ”§ Configuration

Environment Variables

Create a .env file with the following variables:

# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key_here

# Admin Configuration
ADMIN_EMAIL=[email protected]
ADMIN_PASSWORD=OSAAKing!

# Database Configuration
DATABASE_URL=sqlite:///unga_vector.db
USER_DATABASE_URL=sqlite:///user_auth.db

# Application Configuration
APP_NAME=UNGA Analysis App
APP_VERSION=1.0.0
DEBUG=False

Database Setup

The application uses two databases:

  1. unga_vector.db: Main speech database with embeddings
  2. user_auth.db: User authentication database

πŸ“Š Data Management

Database Population

The application comes with a complete UNGA corpus (1946-2025):

  • Total Speeches: 11,093
  • Countries: 199
  • Years: 1946-2025 (80 years)
  • Embeddings: 100% coverage for semantic search

Data Quality

  • βœ… No duplicates
  • βœ… Complete country mapping
  • βœ… Proper African vs Development Partner classification
  • βœ… Full temporal coverage
  • βœ… Semantic search capabilities

🎨 User Interface

Main Tabs

  1. πŸ“ New Analysis: Create new speech analyses
  2. 🌍 Cross-Year Analysis: Historical trend analysis
  3. πŸ“„ Document Context: Upload and analyze documents
  4. πŸ“š All Analyses: View past analyses
  5. πŸ“Š Visualizations: Interactive charts and graphs
  6. πŸ—ΊοΈ Data Explorer: Explore the database
  7. πŸ—„οΈ Database Chat: Chat with the database
  8. πŸ” Error Insights: System monitoring
  9. πŸ›‘οΈ Admin Portal: User management (admin only)

Features by User Type

  • Regular Users: All analysis and visualization features
  • Admin Users: Additional user management capabilities

πŸ”’ Security

  • Secure password hashing
  • Session management
  • Input validation
  • SQL injection prevention
  • XSS protection
  • CSRF protection

πŸ§ͺ Testing

# Run tests
pytest tests/

# Run with coverage
pytest --cov=src tests/

πŸ“ˆ Performance

  • Database: Optimized with proper indexing
  • Search: Semantic search with embeddings
  • Caching: Efficient country and data caching
  • Memory: Optimized for large datasets

πŸš€ Deployment

Local Development

streamlit run main.py --server.port 8501

Production Deployment

See docs/DEPLOYMENT.md for detailed deployment instructions.

πŸ“š Documentation

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🏒 Organization

Built for UN OSAA (Office of the Special Adviser on Africa)

  • Supports: PDF, DOCX, MP3 file formats
  • Auto-classifies: African Member States vs Development Partners
  • Developed by: SMU Data Team

πŸ†˜ Support

For support and questions:

  • Email: [email protected]
  • Documentation: See docs/ directory
  • Issues: Create an issue in the repository

πŸ‡ΊπŸ‡³ UNGA Analysis App - Empowering UN Member States with Data-Driven Insights

About

AI-powered UN GA speech analysis tool for UN OSAA's Intergovernmental team. Generates daily readouts from member state speeches using LLM with curated prompts aligned to UN OSAA priorities. Supports PDF, DOCX, MP3 files.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages