A web application that generates credit ratings for public companies using LLM-based methodology interpretation and Box platform integration.
- Generate credit ratings for public companies
- LLM-based methodology interpretation from PDF documents
- Integration with Box platform for document management
- Historical ratings tracking
- RESTful API with interactive documentation
- Python 3.11 or higher
- PostgreSQL database
- Box Custom Application (JWT authentication)
- OpenAI API key
- Financial data provider API key (e.g., Alpha Vantage)
- Clone the repository:
git clone <repository-url>
cd company-credit-rating- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -e ".[dev]"- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration- Set up PostgreSQL database:
createdb credit_rating_db- Initialize the database:
python -c "from app.database import init_db; init_db()"The application uses the self-hosted Box MCP server for Box integration. Follow these steps:
-
Install the Box MCP server following the official guide: https://developer.box.com/guides/box-mcp/self-hosted/
-
Configure your Box Custom Application:
- Create a Custom App in Box Developer Console
- Enable JWT authentication
- Generate and download the configuration file
- Grant necessary permissions (read/write files, manage folders)
-
Update
.envwith Box configuration:BOX_MCP_SERVER_PATH: Path to the Box MCP server executableBOX_CLIENT_ID,BOX_CLIENT_SECRET,BOX_ENTERPRISE_ID: From Box app configurationBOX_METHODOLOGY_FOLDER_ID: Box folder ID containing methodology PDFsBOX_RATINGS_FOLDER_ID: Box folder ID for storing rating reports
python app/main.pyThe application will be available at http://localhost:5000
API documentation is available at http://localhost:5000/api/docs
export FLASK_APP=app.main:create_app
export FLASK_ENV=development
flask runpytestpytest --cov=app --cov=models --cov=services --cov-report=htmlpytest tests/unit/pytest tests/integration/ -v -s# Using the helper script
./scripts/test_sec_to_box.sh
# Or directly with pytest
pytest tests/integration/test_sec_to_box_e2e.py -v -spytest tests/properties/See tests/integration/README.md for detailed information about integration tests.
company-credit-rating/
├── app/ # Flask application
│ ├── __init__.py
│ ├── main.py # Application factory
│ ├── config.py # Configuration
│ ├── database.py # Database setup
│ └── routes/ # API endpoints (to be created)
├── models/ # Data models
│ └── __init__.py
├── services/ # Business logic services
│ └── __init__.py
├── tests/ # Test suite
│ ├── unit/ # Unit tests
│ ├── properties/ # Property-based tests
│ └── conftest.py # Test configuration
├── .env.example # Environment variables template
├── .gitignore
├── pyproject.toml # Project configuration
└── README.md
Key configuration options in .env:
- Flask:
SECRET_KEY,FLASK_ENV - Database:
DATABASE_URL - Box:
BOX_MCP_SERVER_PATH,BOX_CLIENT_ID, etc. - LLM:
OPENAI_API_KEY,LLM_MODEL,LLM_TEMPERATURE - Financial Data:
FINANCIAL_DATA_PROVIDER,ALPHA_VANTAGE_API_KEY - Application:
MAX_RETRIES,REQUEST_TIMEOUT,DATA_AGE_THRESHOLD_MONTHS
black .mypy app/ models/ services/flake8 app/ models/ services/[Your License Here]