Skip to content

charsree/chariot

Repository files navigation

Chariot

A cross-platform AI chat application built with Flutter, supporting Claude, DeepSeek, and Mistral models via AWS Bedrock.

Screenshots

Home Screen Chat Interface Model Selector

Features

  • Multi-model support: Claude Opus/Sonnet/Haiku, DeepSeek R1, Mistral Large
  • Real-time streaming: Token-by-token response streaming
  • DeepSeek thinking: Expandable reasoning section for DeepSeek R1
  • File attachments: Images, PDFs, documents, code files
  • End-to-end encryption: Client-side AES-GCM encryption with PBKDF2 key derivation
  • Cross-device sync: Encrypted chat storage via S3
  • Local caching: Instant load with background sync
  • Dark/Light themes: System-aware theming

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    Flutter App (Web/iOS/Android)            │
│                                                             │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────────────┐  │
│  │   Cognito   │  │  WebSocket  │  │   Local Storage     │  │
│  │    Auth     │  │   Client    │  │   (SharedPrefs)     │  │
│  └──────┬──────┘  └──────┬──────┘  └──────────┬──────────┘  │
└─────────┼────────────────┼────────────────────┼─────────────┘
          │                │                    │
          ▼                ▼                    │
┌─────────────────┐  ┌─────────────────────┐    │
│  Cognito User   │  │  API Gateway        │    │
│     Pool        │  │  (WebSocket)        │    │
└─────────────────┘  └──────────┬──────────┘    │
                               │                │ 
                               ▼                │
                     ┌─────────────────────┐    │
                     │      Lambda         │    │
                     │  (bedrock-proxy)    │    │
                     │                     │    │
                     │  • Origin check     │    │
                     │  • Chat streaming   │    │
                     │  • S3 operations    │    │
                     └──────────┬──────────┘    │
                               │                │
                    ┌──────────┴──────────┐     │
                    ▼                     ▼     │
          ┌─────────────────┐   ┌─────────────────┐
          │    Bedrock      │   │       S3        │
          │  (AI Models)    │   │  (Encrypted     │
          │                 │   │   Chat Storage) │
          └─────────────────┘   └─────────────────┘

Prerequisites

  • Flutter SDK 3.19+
  • AWS CLI configured
  • Xcode (for iOS)
  • Android Studio (for Android)

Quick Start

1. Clone and Install Dependencies

git clone https://github.com/charsree/chariot.git
cd chariot
flutter pub get

2. Configure AWS (see SETUP.md for full AWS setup)

Create config.local.json in the project root:

{
  "AWS_REGION": "us-east-1",
  "COGNITO_USER_POOL_ID": "YOUR_USER_POOL_ID",
  "COGNITO_CLIENT_ID": "YOUR_CLIENT_ID",
  "WS_ENDPOINT": "wss://YOUR_API_ID.execute-api.us-east-1.amazonaws.com/prod",
  "S3_BUCKET_NAME": "your-chat-storage-bucket"
}

See config.local.json.example for template.

3. Run Development Server

Set environment variables for Flutter build:

# Web
flutter run -d chrome \
  --dart-define=AWS_REGION=us-east-1 \
  --dart-define=COGNITO_USER_POOL_ID=YOUR_USER_POOL_ID \
  --dart-define=COGNITO_CLIENT_ID=YOUR_CLIENT_ID \
  --dart-define=WS_ENDPOINT=wss://YOUR_API_ID.execute-api.us-east-1.amazonaws.com/prod

# Or use config.local.json with a build script
./scripts/build.sh

Building for Production

Build All Platforms

./build.sh

Or build individually:

Web

flutter build web --release

# Output: build/web/
# Deploy to Cloudflare Pages, S3+CloudFront, or any static host

Android

# APK (for direct install)
flutter build apk --release

# Output: build/app/outputs/flutter-apk/app-release.apk

# App Bundle (for Play Store)
flutter build appbundle --release

# Output: build/app/outputs/bundle/release/app-release.aab

iOS

# Build for App Store
flutter build ios --release

# Then open in Xcode for archive/upload
open ios/Runner.xcworkspace

Project Structure

chariot/
├── lib/
│   ├── config/
│   │   ├── aws_config.dart      # AWS configuration
│   │   └── theme.dart           # App themes
│   ├── models/
│   │   ├── ai_model.dart        # AI model definition
│   │   ├── chat.dart            # Conversation/Message models
│   │   └── user_settings.dart   # User preferences
│   ├── providers/
│   │   └── app_providers.dart   # Riverpod state management
│   ├── screens/
│   │   ├── home_screen.dart     # Main chat interface
│   │   ├── login_screen.dart    # Authentication
│   │   ├── signup_screen.dart   # Registration
│   │   ├── verify_screen.dart   # Email verification
│   │   └── settings_screen.dart # User settings
│   ├── services/
│   │   ├── auth_service.dart    # Cognito authentication
│   │   ├── bedrock_service.dart # AI model streaming
│   │   ├── config_service.dart  # Remote config
│   │   ├── encryption_service.dart # E2E encryption
│   │   ├── s3_sync_service.dart # S3 operations
│   │   └── storage_service.dart # Local + remote storage
│   ├── widgets/
│   │   ├── chat_view.dart       # Chat messages UI
│   │   ├── chat_drawer.dart     # Conversation list
│   │   └── model_selector.dart  # Model picker
│   └── main.dart                # App entry point
├── infrastructure/
│   ├── lambda/
│   │   └── bedrock_proxy.py     # Lambda function
│   └── template.yaml            # CloudFormation template
├── web/
│   └── _redirects               # SPA routing for Cloudflare
├── SETUP.md                     # AWS setup guide
└── README.md                    # This file

Development

Adding a New AI Model

  1. Add to Lambda MODELS list in infrastructure/lambda/bedrock_proxy.py
  2. Deploy Lambda: ./deploy-lambda.sh
  3. App fetches updated models automatically

Modifying Streaming Behavior

Edit infrastructure/lambda/bedrock_proxy.py:

  • Chunk buffering: Adjust > 0 threshold
  • Timeout: Modify Lambda timeout in template.yaml

Local Development Without AWS

For UI development without backend:

  1. Comment out S3 sync calls in storage_service.dart
  2. Data persists in local SharedPreferences only

Deployment

Lambda

cd infrastructure/lambda
zip -r ../function.zip bedrock_proxy.py
aws lambda update-function-code \
  --function-name chariot-bedrock-proxy \
  --zip-file fileb://../function.zip \
  --region us-east-1

CloudFormation

cd infrastructure
aws cloudformation deploy \
  --template-file template.yaml \
  --stack-name chariot-api \
  --capabilities CAPABILITY_NAMED_IAM \
  --region us-east-1

License

MIT

About

AI chat app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors