Skip to content

AWS Infrastructure

Garot Conklin edited this page Dec 17, 2024 · 2 revisions

AWS Infrastructure

Overview

RunOn! uses a serverless architecture on AWS, integrated with MongoDB Atlas and various Google APIs.

Core Services

AWS Lambda

  • Event Discovery Function

    Function: event-discovery
    Runtime: Python 3.11
    Memory: 256MB
    Timeout: 30s
    Environment:
      - GOOGLE_API_KEY
      - MONGODB_URI
      - REDIS_URL
  • User Management Function

    Function: user-management
    Runtime: Python 3.11
    Memory: 128MB
    Timeout: 10s
    Environment:
      - AUTH0_DOMAIN
      - MONGODB_URI

API Gateway

API: runon-api
Stage: v1
Endpoints:
  - /events:
      GET: event-discovery-function
      POST: event-save-function
  - /preferences:
      GET: user-preferences-function
      PUT: user-preferences-update-function
Security:
  - Auth0 Authorizer
  - API Key validation
  - Rate limiting

CloudWatch

  • Monitoring:
    • Lambda function metrics
    • API Gateway metrics
    • Custom metrics for event discovery
  • Alarms:
    • Error rate thresholds
    • Latency thresholds
    • Integration failures

Database

MongoDB Atlas

  • Clusters:
    • Production: M10 cluster
    • Development: M0 shared cluster
  • Configuration:
    Version: 6.0
    Backup: Daily
    Retention: 7 days
    Scaling:
      AutoScaling: enabled
      Min Instances: 1
      Max Instances: 3

Redis Cache

  • Configuration:
    Engine: Redis 7.0
    Instance: cache.t4g.micro
    Nodes: 1
    Auto Failover: disabled
    Backup: disabled
    TTL Settings:
      - Event Cache: 15 minutes
      - User Preferences: 1 hour
      - Static Data: 24 hours

Security

Auth0 Integration

Domain: runon.auth0.com
Applications:
  - Mobile App:
      Type: Native
      Allowed Callbacks: com.runon://callback
  - Backend:
      Type: Machine to Machine
      Permissions: 
        - read:events
        - write:events
        - manage:preferences

IAM Roles

- EventDiscoveryRole:
    Permissions:
      - lambda:InvokeFunction
      - dynamodb:Query
      - dynamodb:PutItem
      - logs:CreateLogGroup
      - logs:CreateLogStream
      - logs:PutLogEvents

- UserManagementRole:
    Permissions:
      - lambda:InvokeFunction
      - dynamodb:GetItem
      - dynamodb:PutItem
      - dynamodb:UpdateItem

Deployment

CI/CD Pipeline

Provider: GitHub Actions
Stages:
  - Build:
      - Install dependencies
      - Run tests
      - Package Lambda functions
  - Deploy:
      - Update Lambda functions
      - Update API Gateway
      - Update CloudWatch alarms
  - Post-Deploy:
      - Run integration tests
      - Verify endpoints
      - Check monitoring

Infrastructure as Code

Template: AWS SAM
Resources:
  - Lambda Functions
  - API Gateway
  - IAM Roles
  - CloudWatch Alarms
Version Control:
  Repository: fleXRPL/RunOn
  Branch: main

Cost Optimization

  • Lambda provisioned concurrency for high-traffic functions
  • Redis caching to reduce API calls
  • MongoDB Atlas tier optimization
  • CloudWatch Logs retention policy

Monitoring and Logging

  • CloudWatch Logs
  • X-Ray tracing
  • Custom metrics
  • Error tracking
  • Performance monitoring

Disaster Recovery

  • MongoDB Atlas continuous backup
  • Multi-region API Gateway
  • Lambda function versioning
  • Regular disaster recovery testing

Infrastructure Diagrams

Overall Architecture

graph TB
    Client[Mobile App] --> API[API Gateway]
    API --> Auth[Auth0 Authorizer]
    API --> Lambda[Lambda Functions]
    Lambda --> MongoDB[MongoDB Atlas]
    Lambda --> Redis[Redis Cache]
    Lambda --> Google[Google APIs]
    
    subgraph AWS
        API
        Auth
        Lambda
    end
    
    subgraph External Services
        MongoDB
        Redis
        Google
    end
    
    classDef aws fill:#FF9900,stroke:#232F3E,stroke-width:2px,color:black;
    classDef external fill:#85B09A,stroke:#232F3E,stroke-width:2px,color:black;
    
    class API,Auth,Lambda aws;
    class MongoDB,Redis,Google external;
Loading

Data Flow

sequenceDiagram
    participant App as Mobile App
    participant Gateway as API Gateway
    participant Auth as Auth0
    participant Lambda as Lambda Function
    participant Google as Google APIs
    participant Cache as Redis Cache
    participant DB as MongoDB Atlas

    App->>Gateway: Request Events
    Gateway->>Auth: Validate Token
    Auth-->>Gateway: Token Valid
    Gateway->>Lambda: Process Request
    
    alt Cache Hit
        Lambda->>Cache: Check Cache
        Cache-->>Lambda: Return Cached Data
    else Cache Miss
        Lambda->>Google: Search Events
        Google-->>Lambda: Event Data
        Lambda->>DB: Store Events
        Lambda->>Cache: Update Cache
    end
    
    Lambda-->>Gateway: Return Response
    Gateway-->>App: Events Data
Loading

Deployment Flow

graph LR
    Code[Code Repository] --> Actions[GitHub Actions]
    Actions --> Build[Build Stage]
    Build --> Test[Test Stage]
    Test --> Deploy[Deploy Stage]
    Deploy --> Lambda[Lambda Functions]
    Deploy --> Gateway[API Gateway]
    Deploy --> Monitoring[CloudWatch]
    
    classDef pipeline fill:#2088FF,stroke:#232F3E,stroke-width:2px,color:white;
    classDef aws fill:#FF9900,stroke:#232F3E,stroke-width:2px,color:black;
    
    class Code,Actions,Build,Test,Deploy pipeline;
    class Lambda,Gateway,Monitoring aws;
Loading

RunOn Documentation

MVP Documentation

Core Documentation

Archived (Full-Featured)

Full-Featured Documentation

Clone this wiki locally