# app.py import streamlit as st import requests import time import plotly.express as px import os from dotenv import load_dotenv # Load environment variables load_dotenv() # Set up Streamlit page st.set_page_config( page_title="Legal Rights Explorer", page_icon="⚖️", layout="wide", initial_sidebar_state="collapsed" ) # Custom CSS for professional styling st.markdown(""" """, unsafe_allow_html=True) # Country data with flags COUNTRIES = { "🇺🇸 United States": "US", "🇬🇧 United Kingdom": "UK", "🇨🇦 Canada": "CA", "🇦🇺 Australia": "AU", "🇮🇳 India": "IN", "🇩🇪 Germany": "DE", "🇫🇷 France": "FR", "🇯🇵 Japan": "JP", "🇧🇷 Brazil": "BR", "🇿🇦 South Africa": "ZA", "🇪🇸 Spain": "ES", "🇮🇹 Italy": "IT" } # Common legal scenarios SCENARIOS = [ "Traffic Stop by Police", "Workplace Discrimination", "Rental Housing Issues", "Medical Emergency Rights", "Consumer Protection", "Arrest or Detention", "Border Crossing", "Online Privacy", "Employment Termination", "Debt Collection", "Freedom of Speech", "Immigration Rights" ] # Simulated API function def get_legal_rights(country, scenario): """Simulate API response with country-specific legal rights""" # In a real implementation, this would call an external API # For this demo, we'll return simulated responses # Simulate API delay time.sleep(1.5) # Base rights that apply to most countries base_rights = [ "Right to remain silent", "Right to legal representation", "Right to be treated with dignity and respect", "Right to understand the charges against you", "Right to a fair and impartial process" ] # Country-specific additions country_specific = { "US": [ "Right to refuse unwarranted searches (4th Amendment)", "Right to due process (5th Amendment)", "Right to a speedy and public trial (6th Amendment)" ], "UK": [ "Right to legal advice under the Police and Criminal Evidence Act", "Right to have someone informed of your arrest", "Protection under the Human Rights Act 1998" ], "CA": [ "Right to be informed of the reason for detention (Charter of Rights)", "Right to retain and instruct counsel without delay", "Right to habeas corpus" ], "AU": [ "Right to silence during police questioning", "Right to communicate with a friend or relative", "Protection under the Australian Human Rights Commission Act" ], "IN": [ "Right to free legal aid under Article 39A of the Constitution", "Protection against self-incrimination (Article 20)", "Right to be informed of grounds for arrest (Article 22)" ] } # Scenario-specific additions scenario_specific = { "Traffic Stop by Police": [ "Right to see official identification", "Right to know the reason for the stop", "Right to refuse a search without probable cause", "Right to record the interaction" ], "Workplace Discrimination": [ "Right to a discrimination-free workplace", "Right to report without retaliation", "Right to reasonable accommodations", "Right to equal pay for equal work" ], "Medical Emergency Rights": [ "Right to emergency treatment regardless of insurance", "Right to informed consent", "Right to access medical records", "Right to privacy of health information" ], "Arrest or Detention": [ "Right to be informed of charges", "Right to contact your embassy if foreign national", "Right to humane treatment", "Right to challenge the lawfulness of detention" ] } # Combine rights based on country and scenario rights = base_rights.copy() if country in country_specific: rights.extend(country_specific[country]) for key, value in scenario_specific.items(): if key in scenario: rights.extend(value) break # Format the response response = f"## 🔍 Your Rights in {country}\n" response += f"### Situation: {scenario}\n\n" response += "Based on the laws of your selected country, you have the following rights:\n\n" for i, right in enumerate(set(rights), 1): response += f"✅ **{right}**\n\n" response += "\n**Important Notes:**\n" response += "- This information is for educational purposes only\n" response += "- Laws vary by jurisdiction and circumstances\n" response += "- Consult a qualified attorney for legal advice\n" return response # Main app def main(): # Header section st.markdown("""
Know your rights in any situation, anywhere in the world
Understanding your legal rights empowers you to:
"Knowledge of the law is the first defense against injustice."