Skip to content

Dogecat0/Aperilex

Repository files navigation

Aperilex - AI-Powered Financial Analysis Platform (v2.0.0)

Democratize financial analysis by making SEC filings as easy to understand as reading a news article.

Aperilex is an open-source financial analysis platform that transforms complex SEC filings into clear, actionable insights. Whether you're an investor, analyst, student, or simply curious about public companies, Aperilex provides AI-powered analysis through an intuitive web interface and powerful developer API.

πŸ”„ Current Status

Version: 2.0.0 - Production-Ready Architecture

βœ… Completed:

  • Clean Domain-Driven Design with CQRS pattern implementation
  • Flexible messaging system with pluggable backends (local/RabbitMQ/AWS)
  • Full-stack application with React 19 frontend and FastAPI backend
  • Comprehensive API with OpenAPI documentation
  • Multi-provider LLM support (OpenAI, Google AI)
  • AWS deployment infrastructure with Pulumi

πŸ”§ Recent Updates:

  • Removed Redis/Celery dependencies for simplified architecture
  • Implemented flexible messaging system for different deployment scenarios
  • Added batch analysis capabilities for processing multiple filings
  • Enhanced error handling with circuit breaker patterns
  • Improved test coverage and code quality metrics

πŸš€ What Aperilex Does

For Everyone:

  • πŸ” Smart Company Research: Search any public company and get instant insights
  • πŸ“Š AI-Powered Analysis: Automatic extraction of key risks, opportunities, and financial trends
  • πŸ“ˆ Interactive Dashboards: Comprehensive analysis tracking with visual progress indicators
  • πŸ’Ύ Export & Sharing: Generate PDF reports and JSON file of analysis results
  • πŸ“± Responsive Design: Works seamlessly on desktop and mobile devices

For Developers:

  • πŸ”Œ REST API: FastAPI with automatic OpenAPI documentation and type safety
  • ⚑ Flexible Processing: Pluggable messaging backends (local, RabbitMQ, AWS SQS/Lambda)
  • πŸ“š TypeScript Support: Full type definitions with auto-generated API types

Key Features:

  • Complete web application with React 19 interface
  • AI-powered SEC filing analysis (10-K, 10-Q)
  • Plain-English summaries of complex financial documents
  • Risk factor analysis and business opportunity identification
  • Financial metrics visualization with interactive charts
  • Company comparison and trend analysis tools

πŸ—οΈ Architecture

Aperilex is a complete full-stack application built with clean architecture principles:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Frontend Layer                           β”‚
β”‚              React 19 + TypeScript + Tailwind CSS              β”‚
β”‚          (Components, Dashboards, Visualizations)               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚ REST API + TypeScript Client
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Presentation Layer                         β”‚
β”‚            FastAPI REST API with OpenAPI Documentation         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      Application Layer                          β”‚
β”‚                (CQRS Commands/Queries + Handlers)               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        Domain Layer                             β”‚
β”‚           (Rich Entities + Value Objects + Business Rules)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Infrastructure Layer                         β”‚
β”‚    (PostgreSQL + EdgarTools + OpenAI/Google AI + Messaging)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

Full-Stack Application Structure:

aperilex/
β”œβ”€β”€ frontend/                # 🎨 REACT WEB APPLICATION
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ analysis/    # Analysis results & visualizations
β”‚   β”‚   β”‚   β”œβ”€β”€ charts/      # Financial data charts (Recharts)
β”‚   β”‚   β”‚   β”œβ”€β”€ layout/      # App shell, header, navigation
β”‚   β”‚   β”‚   └── ui/          # Design system components
β”‚   β”‚   β”œβ”€β”€ features/        # Feature-based modules
β”‚   β”‚   β”‚   β”œβ”€β”€ analyses/    # Analysis management
β”‚   β”‚   β”‚   β”œβ”€β”€ companies/   # Company research
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard/   # Interactive dashboard
β”‚   β”‚   β”‚   └── filings/     # SEC filing exploration
β”‚   β”‚   β”œβ”€β”€ api/            # TypeScript API client
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ lib/            # React Query, Zustand config
β”‚   β”‚   └── utils/          # Helper functions
β”‚   β”œβ”€β”€ coverage/           # Test coverage reports
β”‚   └── tests/              # Frontend test suite
β”œβ”€β”€ src/                    # πŸ”§ BACKEND API
β”‚   β”œβ”€β”€ domain/             # Business logic & entities
β”‚   β”‚   β”œβ”€β”€ entities/       # Analysis, Company, Filing
β”‚   β”‚   └── value_objects/  # Money, ProcessingStatus, Ticker
β”‚   β”œβ”€β”€ application/        # CQRS application services
β”‚   β”‚   β”œβ”€β”€ commands/       # Command handlers (analysis orchestration)
β”‚   β”‚   β”œβ”€β”€ queries/        # Query handlers
β”‚   β”‚   β”œβ”€β”€ schemas/        # Pydantic DTOs & validation
β”‚   β”‚   β”œβ”€β”€ services/       # Application orchestrators
β”‚   β”‚   └── patterns/       # Circuit breaker, resilience
β”‚   β”œβ”€β”€ infrastructure/     # External integrations
β”‚   β”‚   β”œβ”€β”€ database/       # PostgreSQL with SQLAlchemy
β”‚   β”‚   β”œβ”€β”€ repositories/   # Async repository pattern
β”‚   β”‚   β”œβ”€β”€ llm/           # OpenAI provider & analysis schemas
β”‚   β”‚   β”œβ”€β”€ edgar/         # SEC filing integration (edgartools)
β”‚   β”‚   β”œβ”€β”€ cache/         # Multi-level caching infrastructure
β”‚   β”‚   └── messaging/     # Flexible messaging (local/RabbitMQ/SQS)
β”‚   β”œβ”€β”€ presentation/      # FastAPI REST API
β”‚   β”‚   └── api/
β”‚   β”‚       └── routers/   # API endpoints
β”‚   └── shared/            # Cross-cutting concerns
β”œβ”€β”€ tests/                 # πŸ§ͺ COMPREHENSIVE TESTING
β”‚   β”œβ”€β”€ unit/             # Layer-specific unit tests
β”‚   β”œβ”€β”€ integration/      # Cross-layer integration tests
β”‚   β”œβ”€β”€ e2e/              # End-to-end workflow tests
β”‚   └── fixtures/         # Realistic test data
β”œβ”€β”€ docs/                 # πŸ“š PROJECT DOCUMENTATION
β”‚   β”œβ”€β”€ phases/           # Development phase tracking
β”‚   β”œβ”€β”€ architecture/     # Architecture decisions
β”‚   └── implementation/   # Feature implementation summaries
β”œβ”€β”€ scripts/              # πŸ”§ Development & deployment tools
β”‚   β”œβ”€β”€ batch_analyze_filings.py  # Batch analysis for multiple filings
β”‚   β”œβ”€β”€ import_snp500.sh          # S&P 500 company data import
β”‚   β”œβ”€β”€ aws-entrypoint.sh         # AWS deployment entry point
β”‚   └── reset_database.sh         # Database management utilities
└── pulumi/               # ☁️ Infrastructure as Code (AWS)
    β”œβ”€β”€ backend.py        # Backend Elastick Beanstalk configuration
    β”œβ”€β”€ frontend.py       # Frontend S3/CloudFront setup
    β”œβ”€β”€ database.py       # RDS PostgreSQL configuration
    └── orchestration.py  # AWS resource orchestration

⚑ Technology Stack

🎨 Frontend Technologies

  • Framework: React 19 with React Compiler for optimal performance
  • Language: TypeScript 5.7 with strict mode and comprehensive type checking
  • Build Tool: Vite 6 for fast development and optimized production builds
  • Styling: Tailwind CSS 4 with semantic design tokens and responsive design
  • State Management:
    • Client State: Zustand for lightweight, type-safe state management
    • Server State: React Query (TanStack Query) for intelligent data fetching and caching
  • Charts & Visualization: Recharts for interactive financial data visualization
  • Testing: Vitest with React Testing Library for comprehensive component testing
  • Type Safety: Full TypeScript integration with auto-generated API types

πŸ”§ Backend Technologies

  • Language: Python 3.12 with strict type checking via MyPy
  • Web Framework: FastAPI with async/await support and automatic OpenAPI generation
  • Database: PostgreSQL 16 with async SQLAlchemy 2.0+ ORM
  • Cache: Multi-level caching with intelligent TTL strategies
  • Messaging: Flexible messaging system with pluggable backends (local, RabbitMQ, AWS SQS)
  • Cloud Infrastructure: AWS services (S3, RDS, ECS, CloudFront) via Pulumi IaC
  • API Documentation: Auto-generated OpenAPI 3.0 specification with interactive docs

πŸ—οΈ Architecture & Patterns

  • Full-Stack Architecture: Complete frontend + backend separation with REST API
  • Clean Architecture: Domain-driven design with four distinct layers
  • CQRS Pattern: Command/query separation with dedicated handlers
  • Repository Pattern: Async data access with proper entity/model separation
  • Circuit Breaker: Fault tolerance for external service integrations
  • Dependency Injection: Constructor injection with interface-based abstractions

πŸ”Œ External Integrations

  • SEC Data: edgartools library for direct SEC EDGAR database access
  • AI Analysis: Multiple LLM providers (OpenAI GPT-4, Google AI) with structured output schemas
  • Messaging System: Pluggable backends - local (development), RabbitMQ (staging), AWS SQS/Lambda (production)
  • Storage: Flexible storage backends - local filesystem, AWS S3

πŸ§ͺ Development & Quality

  • Testing Strategy:
    • Backend: pytest with comprehensive test coverage, async testing, realistic fixtures
    • Frontend: Vitest + React Testing Library for component and integration testing
    • Integration: End-to-end API and workflow testing
  • Type Safety:
    • Backend: Strict MyPy with comprehensive type annotations
    • Frontend: TypeScript strict mode with auto-generated API types
  • Code Quality:
    • Backend: Ruff linting, Black formatting, isort import organization
    • Frontend: ESLint, Prettier, TypeScript compiler checks
  • Security: Bandit security scanning, dependency vulnerability checkingF
  • Infrastructure: Docker & Docker Compose for development and production

πŸš€ Production Features

  • Performance:
    • React 19 with optimized rendering and code splitting
    • Async-first backend with PostgreSQL connection pooling
    • Multi-level caching with configurable TTL strategies
  • Scalability:
    • Pluggable messaging backends for different deployment scenarios
    • Stateless design enabling horizontal scaling
    • Support for AWS Lambda for serverless processing
  • Monitoring:
    • Comprehensive health checks for all services
    • Structured logging with context propagation
    • OpenTelemetry instrumentation ready
  • Reliability:
    • Circuit breaker patterns for external services
    • Graceful degradation when services are unavailable
    • Comprehensive error handling with retry logic

πŸš€ Getting Started

Prerequisites

System Requirements:

  • Python 3.12+ for backend development
  • Node.js 18+ for frontend development
  • Docker & Docker Compose for services (PostgreSQL)
  • Poetry for Python dependency management
  • AWS CLI (optional) for cloud deployment
  • Pulumi (optional) for infrastructure as code

Quick Start (Full-Stack Setup)

1. Clone and Setup

git clone https://github.com/Dogecat0/Aperilex.git
cd aperilex

2. Backend Setup

# Install Python dependencies
poetry install

# Set up environment variables
cp .env.example .env
# Edit .env with your OpenAI API key and other settings

# Start infrastructure services (PostgreSQL)
docker-compose up -d postgres

# Run database migrations
alembic upgrade head

3. Frontend Setup

# Navigate to frontend directory
cd frontend

# Install Node.js dependencies
npm install

# Return to project root
cd ..

4. Start the Application

Terminal: Frontend Application

cd frontend
npm run dev
# Web app available at http://localhost:3000

5. Verify Installation

Development Workflow

Quality Checks:

# Backend quality checks
poetry run mypy src/
poetry run ruff check src/
poetry run black src/ --check

# Frontend quality checks
cd frontend
npm run typecheck && npm run lint

# Run all tests
npm run test              # Frontend tests
cd .. && pytest         # Backend tests

# Auto-format code
poetry run black src/ && poetry run isort src/  # Backend
cd frontend && npm run format                   # Frontend

Development Commands:

# Start backend API server
poetry run uvicorn src.presentation.api.app:app --reload --port 8000

# Frontend development
cd frontend && npm run dev

# Run backend tests with coverage
pytest --cov=src --cov-report=html

# Run frontend tests with coverage
cd frontend && npm run test:coverage

πŸ’Ό Use Cases

For Individual Investors:

  • Research companies before making investment decisions
  • Get plain-English explanations of complex SEC filings
  • Track key financial metrics and trends over time
  • Identify risks and opportunities in investment targets

For Financial Analysts:

  • Streamline SEC filing analysis with AI-powered insights
  • Generate comprehensive reports with export functionality
  • Compare companies across industries and timeframes
  • Access structured financial data through REST API

For Students & Educators:

  • Learn financial analysis through interactive examples
  • Understand SEC filing structures and content
  • Practice financial research with real company data
  • Export analysis results for assignments and presentations

For Developers:

  • Integrate financial analysis into existing applications
  • Build custom dashboards with comprehensive REST API
  • Access structured SEC data with TypeScript support
  • Leverage background processing for scalable analysis

🌟 Key Features in Detail

πŸ” Smart Company Research

  • Universal Search: Find companies by ticker symbol, name, or CIK number
  • Company Profiles: Comprehensive company information with filing history
  • Recent Filings: Quick access to latest 10-K, 10-Q, and 8-K filings
  • Analysis History: Track all previous analyses and results

πŸ€– AI-Powered SEC Filing Analysis

  • Comprehensive Analysis: Complete filing breakdown with executive summary
  • Section Analysis: Detailed insights into business operations, financials, and risks
  • Plain-English Summaries: Complex financial language translated for everyone
  • Confidence Scoring: AI confidence levels for analysis reliability

⚑ Performance & Reliability

  • Background Processing: Long-running analyses don't block the interface
  • Intelligent Caching: Smart caching reduces API calls and improves speed
  • Fault Tolerance: Circuit breaker patterns ensure system reliability
  • Real-time Updates: WebSocket-like updates for analysis progress

πŸ› οΈ Development Features

πŸ§ͺ Comprehensive Testing

  • Backend: High test coverage with pytest, realistic fixtures, async testing
  • Frontend: Comprehensive test coverage with Vitest, React Testing Library, MSW mocking
  • Integration: End-to-end API testing and workflow validation
  • Performance: Load testing and performance benchmarking

πŸ“‹ Quality Assurance

  • Type Safety: Comprehensive MyPy coverage, TypeScript strict mode throughout
  • Code Quality: Automated formatting, linting, and style enforcement
  • Security Scanning: Dependency vulnerability checking and security audits
  • Pre-commit Hooks: Automated quality checks before every commit

API Endpoints

Complete REST API with FastAPI backend:

The API is organized into 5 main resource groups:

1. Filing Analysis (/api/filings)

2. Analysis Management (/api/analyses)

3. Company Research (/api/companies)

4. Task Management (/api/tasks)

5. Health Monitoring (/api/health)

πŸ”— Project Documentation: See docs/phases/ for detailed development history and architectural decisions.

πŸš€ Deployment

Deployment Options

Local Development

# Using Docker Compose
docker-compose up -d

# Access the application
# API: http://localhost:8000
# Frontend: http://localhost:3000

AWS Deployment (Production)

Aperilex includes complete infrastructure as code for AWS deployment using Pulumi:

Infrastructure Components:

  • Frontend: S3 + CloudFront CDN for React application
  • Backend: Elastic Beanstalk or Lambda for API services
  • Database: RDS PostgreSQL with automated backups
  • Messaging: SQS for task queues, Lambda for workers
  • Storage: S3 for analysis results and file storage
  • Networking: VPC with public/private subnets and security groups

Deployment Steps:

# Navigate to infrastructure directory
cd pulumi

# Install Pulumi dependencies
pip install -r requirements.txt

# Configure AWS credentials
export AWS_PROFILE=your-profile

# Deploy infrastructure
pulumi up --stack prod

# View deployment outputs
pulumi stack output

Batch Processing

Process Multiple SEC Filings:

# Import S&P 500 companies to database
./scripts/import_snp500.sh

# Run batch analysis with concurrent processing
poetry run python scripts/batch_analyze_filings.py \
  --tickers AAPL,MSFT,GOOGL \
  --filing-type 10-K \
  --max-concurrent 5

Available Scripts:

  • batch_analyze_filings.py - Process multiple company filings concurrently
  • import_snp500.sh - Import S&P 500 company data
  • reset_database.sh - Database management utilities
  • aws-entrypoint.sh - AWS deployment entry point

πŸ”’ Security

Aperilex implements comprehensive security measures:

  • Input Validation: Pydantic schema validation for all API inputs
  • SQL Injection Prevention: SQLAlchemy ORM with parameterized queries
  • Dependency Security: Regular vulnerability scanning with Bandit and Safety
  • Container Security: Docker security best practices
  • Rate Limiting: API endpoint rate limiting (ready for production)
  • CORS Configuration: Secure cross-origin resource sharing setup
  • Environment Security: Proper secrets management and environment isolation

πŸ”— Resources

  • Documentation: See docs/ for architecture decisions and implementation details
  • API Documentation: Available at /docs when running the API
  • Issues: Report bugs and request features on GitHub
  • Contributing: Contributions welcome! Please read contributing guidelines

πŸ“„ License

MIT License - See LICENSE file for details.

About

LLM Powered SEC Filing Analysis Engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors