An AI-powered Python application that helps construction project managers identify, analyze, and document project risks using the OpenAI API.
The Construction Risk Assistant is a practical AI automation tool designed for construction project risk management.
The user provides a construction risk description and a unique Risk ID. The application then uses the OpenAI API to generate a structured risk analysis covering:
- Risk Description
- Probability
- Impact
- Risk Level
- Preventive Actions
- Response Plan
- Project Manager Recommendation
Each analysis is automatically dated and saved as a TXT report inside the risk_reports folder.
- Python
- OpenAI API
- python-dotenv
- Git
- GitHub
- Interactive construction risk input
- Unique Risk ID
- Automatic date recording
- AI-powered risk analysis
- Probability assessment
- Impact assessment
- Risk level assessment
- Preventive action planning
- Risk response planning
- Project Manager recommendation
- Automatic TXT report generation
- Multiple risk analyses in one session
- Error handling
Construction_Risk_Assistant/
│
├── main.py
├── requirements.txt
├── .gitignore
├── README.md
└── risk_reports/
├── RISK-001.txt
├── RISK-002.txt
└── RISK-003.txt
Note: The
.envfile is created locally and is excluded from Git tracking because it contains the OpenAI API key.
The application follows this workflow:
User
│
▼
Enter Construction Risk
│
▼
Enter Risk ID
│
▼
OpenAI API
│
▼
AI Risk Analysis
│
├── Probability
├── Impact
├── Risk Level
├── Preventive Actions
├── Response Plan
└── PM Recommendation
│
▼
Display Analysis
│
▼
Save TXT Report
A project manager identifies the following construction risk:
Concrete delivery may be delayed due to supplier transportation issues.
The user enters a Risk ID such as:
RISK-004
The application sends the risk information to the OpenAI API and generates a structured analysis that can be saved as a project risk report.
A generated report follows this general structure:
Risk Analysis - RISK-001
Date Recorded: YYYY-MM-DD
## Risk Description
...
## Probability
...
## Impact
...
## Risk Level
...
## Preventive Actions
- ...
- ...
- ...
## Response Plan
- ...
- ...
- ...
## Project Manager Recommendation
...
Clone the repository:
git clone https://github.com/samehsaad87/Construction_Risk_Assistant.gitNavigate to the project directory:
cd Construction_Risk_AssistantCreate a Python virtual environment:
python -m venv .venvActivate the virtual environment on Windows:
.venv\Scripts\activateInstall the required packages:
pip install -r requirements.txtCreate a .env file in the project directory:
OPENAI_API_KEY=your_api_key_here
Replace your_api_key_here with your own OpenAI API key.
Never commit or publish your real API key.
The .env file is excluded from Git through .gitignore.
Run:
python main.pyThe application will ask for:
- A construction risk description
- A Risk ID
It will then generate the AI-powered risk analysis and save the report inside:
risk_reports/
The repository includes sample risk analysis reports:
RISK-001.txtRISK-002.txtRISK-003.txt
These demonstrate the type of output generated by the application.
The application includes basic error handling around the OpenAI API request so that API or runtime errors do not immediately terminate the application.
The OpenAI API key is stored locally in the .env file.
The .gitignore configuration prevents the following from being tracked by Git:
.env
__pycache__/
*.pyc
.venv/
API keys and other secrets should never be committed to a public repository.
This project demonstrates practical experience with:
- Python application development
- API integration
- Environment variable management
- AI automation
- Construction project risk management
- Automated report generation
- Git version control
- GitHub repository management
The project combines construction project management knowledge with practical AI automation and Python development.
Potential future enhancements include:
- Risk database storage using SQLite
- Excel risk register integration
- Risk scoring matrix
- Dashboard visualization
- PDF report generation
- CSV/Excel export
- Risk trend analysis
- Web interface
- Integration with project management workflows
Sameh Saad
Construction Project Management | AI Automation | Python