Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

11 Commits

Folders and files

Repository files navigation

🏦 AI Financial Agent - Corporate React Application

A modern, professional React application featuring a corporate login system and AI-powered financial agent interface. Built with reusable components and a comprehensive design system.

Corporate Theme React Status

πŸš€ Quick Start

Prerequisites

  • Node.js 16.x or higher
  • npm 8.x or higher

Installation & Setup

  1. Clone the repository:

    git clone <repository-url>
    cd AiFrontend
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm start
  4. Open your browser:

    http://localhost:3000
    

That's it! πŸŽ‰ The application will be running with hot reload enabled.

πŸ”§ API Configuration

πŸ”‘ Setting Up the AI API

The application requires API keys to communicate with the AI backend. Follow these steps:

  1. Create a .env file in the project root:

    touch .env
  2. Add your API configuration to the .env file:

    # AI Agent API Configuration
    REACT_APP_AI_API_URL=https://your-api-gateway-url.amazonaws.com/prod/
    REACT_APP_AI_API_KEY=your-api-key-here
  3. Restart the development server after updating environment variables:

    npm start

⚠️ CORS Workaround (Temporary)

Current Implementation: Due to CORS restrictions from the API Gateway, the application uses a proxy configuration in package.json:

{
  "proxy": "https://fqmsebyf3j.execute-api.us-east-1.amazonaws.com"
}

How it works:

  • In development, API calls go to /prod/ (proxied to the actual endpoint)
  • In production, the app uses the full URL from REACT_APP_AI_API_URL
  • The aiApiService.js automatically switches between proxy and direct calls

⚠️ Security Note:

  • Never commit real API keys to version control
  • Use different API keys for development and production
  • Consider using AWS IAM roles for production deployments

πŸ“± Application Routes

Route Description Direct Access
/ or /login Corporate login page with validation βœ…
/ai-agent AI Financial Agent Dashboard βœ…
/demo Component library demonstration βœ…

πŸ”‘ Accessing the AI Agent

Option 1: Direct Access (Recommended)

  • Navigate to: http://localhost:3000/ai-agent
  • Ensure your API keys are configured (see API Configuration above)

Option 2: Through Login Form

  • Use any email (e.g., demo@company.com)
  • Use any password (6+ characters, e.g., password123)
  • Currently shows mock authentication (no actual redirect)

🎨 Features

✨ Corporate Login System

  • Professional corporate branding with dark header/footer
  • Real-time form validation with visual feedback
  • Responsive design optimized for all devices
  • FontAwesome icons and security indicators
  • Subtle corporate design patterns

πŸ€– AI Financial Agent Interface

  • Three-panel dashboard with professional layout
  • Interactive chat interface with AI avatar and real API integration
  • Error handling with visual feedback for API failures
  • Loading states with professional animations during API calls
  • Financial data visualization with extensible message formats
  • Quick actions panel for common financial queries
  • Live API connectivity via AWS Lambda backend (requires API key)
  • Responsive design that collapses gracefully on mobile

🧩 Reusable Component Library

  • 20+ modular components ready for reuse
  • Design system with consistent colors, typography, and spacing
  • Multiple button variants (primary, secondary, action)
  • Rich message components for financial data
  • Form inputs with validation states

πŸ— Architecture

Component Structure

src/
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ chat/             # Chat interface components
β”‚   β”‚   β”œβ”€β”€ AIAvatar.js   # AI avatar with status
β”‚   β”‚   β”œβ”€β”€ Message.js    # Client/AI message bubbles
β”‚   β”‚   └── ChatInput.js  # Professional chat input
β”‚   β”œβ”€β”€ forms/
β”‚   β”‚   └── FormInput.js  # Validated form inputs
β”‚   β”œβ”€β”€ layout/
β”‚   β”‚   β”œβ”€β”€ CorporateHeader.js  # Corporate header
β”‚   β”‚   └── CorporateFooter.js  # Compliance footer
β”‚   β”œβ”€β”€ login/
β”‚   β”‚   └── LoginCard.js  # Complete login form
β”‚   β”œβ”€β”€ panels/
β”‚   β”‚   β”œβ”€β”€ LeftPanel.js  # Actions & history
β”‚   β”‚   β”œβ”€β”€ CenterPanel.js # Main chat area
β”‚   β”‚   └── RightPanel.js # Data feeds & tools
β”‚   β”œβ”€β”€ ui/
β”‚   β”‚   └── Button.js     # Multi-variant buttons
β”‚   └── demo/
β”‚       └── ComponentDemo.js # Reusability showcase
β”œβ”€β”€ pages/
β”‚   β”œβ”€β”€ LoginPage.js      # Complete login experience
β”‚   └── AIAgentPage.js    # Three-panel dashboard
β”œβ”€β”€ data/
β”‚   └── mockData.js       # Structured mock data
└── styles/
    └── index.css         # Design system & global styles

🎯 Design System

Colors:

  • Brand Red: #9A0718 - Primary actions, highlights
  • Tamarillo: #96151d - Hover states, secondary actions
  • Brand Brown: #8d4900 - Supporting elements
  • Corporate Grays: Complete scale from #f9fafb to #111827

Typography:

  • Font Family: "ff-primary", Helvetica, Arial, sans-serif
  • Weights: 400 (regular), 700 (bold), 800 (heavy)
  • Scale: 10px root, 12px body, up to 24px+ headings

Responsive Breakpoints:

  • Mobile: ≀768px
  • Tablet: 769px-1024px
  • Desktop: 1025px-1600px
  • Large Desktop: β‰₯1601px

🧩 Component Examples

Button Component

import Button from './components/ui/Button';

// Primary action button
<Button variant="primary" size="large">
  Sign In
</Button>

// Secondary button with icon
<Button variant="secondary" icon="fas fa-download">
  Export Report
</Button>

// Action button for panels
<Button variant="action">
  Market Analysis
</Button>

Message Component

import Message from './components/chat/Message';

// Client message
<Message 
  type="client" 
  content="Analyze my portfolio performance" 
  timestamp="2:30 PM"
/>

// AI response with financial data
<Message 
  type="ai"
  content={{
    header: { title: "Portfolio Analysis", type: "Market Review" },
    financialData: { totalReturn: "+12.4%", riskScore: "7.2/10" },
    insights: ["Tech exposure above optimal", "Consider rebalancing"],
    recommendations: [{ priority: "high", action: "Reduce tech allocation" }]
  }}
  timestamp="2:34 PM"
/>

Corporate Header

import CorporateHeader from './components/layout/CorporateHeader';

<CorporateHeader 
  brandName="Corporate Portal"
  statusItems={[
    { icon: "fas fa-shield-alt", text: "Secure Login" },
    { icon: "fas fa-certificate", text: "Verified" }
  ]}
/>

πŸ›  Development

Available Scripts

npm start          # Start development server
npm build          # Build for production
npm test           # Run test suite
npm eject          # Eject from Create React App

πŸ§ͺ Component Demo

Visit /demo to see all components in action with different configurations:

  • Interactive showcase of all components
  • Multiple variants and states demonstrated
  • Real-time examples of reusability
  • Copy-paste code examples

πŸ“± Responsive Testing

The application is optimized for:

  • Mobile devices (320px+)
  • Tablets (768px+)
  • Desktop screens (1024px+)
  • Large displays (1600px+)

🎨 Customization

Updating Colors

Modify CSS variables in src/styles/index.css:

:root {
  --color-brand-red: #9A0718;    /* Change primary brand color */
  --color-tamarillo: #96151d;    /* Change hover/accent color */
  --color-brand-brown: #8d4900;  /* Change supporting color */
}

Adding New Components

  1. Create component in appropriate src/components/ subfolder
  2. Follow existing patterns for props and styling
  3. Add to ComponentDemo.js for showcase
  4. Update this README with examples

Modifying Layout

  • Three-panel layout: Edit AIAgentPage.js and panel components
  • Login layout: Edit LoginPage.js and LoginCard.js
  • Global layout: Edit CorporateHeader.js and CorporateFooter.js

πŸ”Œ Backend Integration

The application is designed for easy backend integration:

Mock Data Structure

Current mock data in src/data/mockData.js includes:

  • User authentication flows
  • Financial market data
  • Chat conversation history
  • Corporate compliance information

API Integration Points

Replace mock functions in:

  • LoginCard.js - Authentication endpoint
  • ChatInput.js - AI chat API
  • RightPanel.js - Live market data feeds
  • LeftPanel.js - User history/preferences

Example API Integration

// Replace this in LoginCard.js:
const mockLogin = async (credentials) => {
  return new Promise(resolve => setTimeout(resolve, 2000));
};

// With actual API call:
const login = async (credentials) => {
  const response = await fetch('/api/auth/login', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(credentials)
  });
  return response.json();
};

πŸš€ Deployment

Build for Production

npm run build

Deploy to Popular Platforms

Netlify:

npm run build
# Drag and drop the `build` folder to Netlify

Vercel:

npm install -g vercel
vercel

AWS S3 + CloudFront:

aws s3 sync build/ s3://your-bucket-name

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/new-component
  3. Commit changes: git commit -m 'Add new component'
  4. Push to branch: git push origin feature/new-component
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

Common Issues

Components not loading:

  • Ensure all dependencies are installed: npm install
  • Clear node_modules and reinstall: rm -rf node_modules && npm install

Styles not applying:

  • Check that src/styles/index.css is imported in src/index.js
  • Verify CSS variable names match between components and stylesheets

Build errors:

  • Run npm run build to check for production build issues
  • Update Node.js to version 16+ if encountering compatibility issues

API Connection Issues

"CORS or Network error":

  • Check if your API Gateway has CORS properly configured
  • Verify the proxy setting in package.json matches your API endpoint
  • In production, ensure REACT_APP_AI_API_URL is correctly set

"AI API key missing":

  • Ensure your .env file exists and contains REACT_APP_AI_API_KEY
  • Restart the development server after adding environment variables
  • Check that the API key is valid and has the correct permissions

API Timeout errors:

  • The service has a 30-second timeout limit
  • Check if your API Gateway/Lambda function is responding within this timeframe
  • Monitor AWS CloudWatch logs for backend issues

Getting Help

  • πŸ“§ Create an issue in the repository
  • πŸ’¬ Check existing issues for similar problems
  • πŸ“š Review component examples in /demo route

🚧 Known Issues & Future Improvements

CORS Workaround (Tracking Issue: #4)

Current State: The application uses a development proxy to work around CORS restrictions from the API Gateway.

Files involved:

  • package.json - Contains proxy configuration
  • src/services/aiApiService.js - Handles environment-based URL switching
  • .env - Contains production API configuration

Required API Gateway Changes:

{
  "Access-Control-Allow-Origin": "*",
  "Access-Control-Allow-Headers": "Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,x-api-key",
  "Access-Control-Allow-Methods": "GET,POST,OPTIONS"
}

Once CORS is fixed:

  1. Remove proxy configuration from package.json
  2. Update aiApiService.js to use direct API calls in all environments
  3. Test production builds to ensure direct API connectivity
  4. Update documentation to remove CORS workaround instructions

Built with ❀️ using React and modern web technologies

This application demonstrates professional-grade component architecture while maintaining pixel-perfect design fidelity from HTML mockups.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages