roshana1s/RupeeLogic
A rule-based expert system, that provides personalized investment portfolio advice for Sri Lankans
π° RupeeLogic - Financial Advisory Expert System for Sri Lankans
A rule-based expert system, that provides personalized investment portfolio advice for Sri Lankans
βEmpowering Sri Lankans with personalized investment adviceβ
β¨ System Architecture
-
Knowledge Base: Stores all investment options, rules from financial experts, and Sri Lankan market data.β
-
Inference Engine: Takes your financial information and applies investment rules to figure out the best portfolios for you.β
-
User Interface: Lets you enter your details through a form and chat naturally to get personalized investment advice.
β¨ System Features
-
Operates in Narrow Domain: Specializes only in Sri Lankan personal investment and portfolio managementβ
-
Dominates in Asking Questions: Actively asks clarifying questions about income, goals, risk tolerance, and time horizonβ
-
Processes Incomplete Information: Makes reasonable assumptions, ignores irrelevant data, or prompts users for missing detailsβ
-
Provides Alternative Solutions: Offers multiple portfolio options (Conservative, Moderate, Aggressive) based on user profileβ
-
Gives a Level of Assurance: Shows confidence level (certainty/uncertainty) for each recommendation based on data completenessβ
-
Provides Recommendations Over Exact Answers: Categorizes advice for different investor types (Beginner-friendly FDs, Intermediate Unit Trusts, Advanced CSE Stocks)β
-
Explainability: Shows which investment rules were fired and reasoning behind portfolio allocation decisions
π Quick Start
Prerequisites
- Python 3.8 or higher
- OpenAI API key (for chat mode only)
Installation
- Clone the repository
git clone https://github.com/roshana1s/RupeeLogic.git
cd RupeeLogic- Create and activate virtual environment
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate- Install dependencies
pip install -r requirements.txt --no-depsNote: The
--no-depsflag is used to avoid dependency conflicts. All required packages are specified inrequirements.txt.
- Set up environment variables (Optional - only for Chat Mode)
# Copy the example environment file
copy .env.example .env
# Edit .env and add your OpenAI API key
# OPENAI_API_KEY=your_api_key_hereπ― How to Run
Start the Application
Run the Streamlit application on port 8000:
streamlit run app/main.py --server.port 8000The application will open in your default browser at: http://localhost:8000
Using the Application
Form Mode (No API key required)
- Select "Form Mode" from the sidebar
- Fill in your financial information:
- Age, income, expenses, savings
- Investment goals and timeline
- Risk tolerance level
- Leave fields empty to use default assumptions
- Click "π Generate My Investment Portfolio"
- Review your personalized recommendations
Chat Mode (Requires OpenAI API key)
- Set up your OpenAI API key in
.envfile - Select "Chat Mode" from the sidebar
- Have a natural conversation about your finances
- The AI assistant will guide you through the process
- Generate recommendations directly from the chat
π Project Structure
RupeeLogic/
βββ app/
β βββ data/
β β βββ knowledge_base.json # Asset class definitions
β βββ es/
β β βββ RupeeLogicEngine.py # Expert system rules & engine
β βββ main.py # Main application entry
β βββ form.py # Form mode interface
β βββ chat.py # Chat mode interface
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ README.md # This file
π οΈ Technologies Used
- Streamlit - Web application framework
- Experta - Expert system / rule-based AI engine
- OpenAI GPT-4o-mini - Natural language processing (chat mode)
- Plotly - Interactive data visualizations
- Pandas - Data manipulation and analysis
- Python 3.8+ - Core programming language
π Investment Rules Coverage
The expert system includes 20+ rules covering:
- β Emergency fund prioritization
- β High-interest debt payoff strategies
- β Budget crisis management
- β Short-term goals (< 3 years)
- β Retirement planning (age-based)
- β Aggressive growth portfolios
- β Balanced/moderate allocations
- β Conservative portfolios
- β Goal-based planning (education, home purchase, etc.)
- β Special scenarios (high net worth, beginners, FIRE, etc.)