File size: 5,442 Bytes
e34506d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env python3
"""
Example script demonstrating how to use the AWS S3 storage utilities.
"""

import os
from dotenv import load_dotenv
from app.utils.aws_storage import AWSS3Storage

def aws_storage_example():
    """
    Example of using the AWSS3Storage class to save and retrieve pitch data.
    """
    # Load environment variables
    load_dotenv()
    
    # Check if AWS credentials are configured
    if not all([
        os.getenv('AWS_ACCESS_KEY_ID'),
        os.getenv('AWS_SECRET_ACCESS_KEY'),
        os.getenv('AWS_S3_BUCKET_NAME')
    ]):
        print("AWS credentials not properly configured. Example will not work.")
        return
    
    # Initialize S3 storage
    s3_storage = AWSS3Storage()
    
    # Example pitch data
    example_script_id = f"example_pitch_{os.urandom(4).hex()}"
    example_elevator_pitch = "We're revolutionizing logistics with AI-powered optimization."
    example_full_pitch = """
    Our company, LogiTech AI, is addressing the critical inefficiencies in global supply chains.
    
    The Problem:
    Current logistics solutions fail to adapt in real-time to changing conditions, resulting in delays, wasted resources, and environmental impact.
    
    Our Solution:
    Our platform uses machine learning to dynamically optimize shipping routes and packaging in real-time, responding to disruptions within minutes instead of hours.
    
    Market Opportunity:
    The global logistics optimization market is projected to reach $30B by 2026, growing at 16% CAGR.
    
    Traction:
    We've already partnered with 3 Fortune 500 retailers for pilot programs, reducing their shipping costs by an average of 23%.
    
    Team:
    Our founding team combines 25+ years of logistics experience with cutting-edge AI expertise from MIT and Stanford.
    
    We're seeking $2M in funding to scale our technology and expand our customer base in the e-commerce sector.
    """
    
    # Example competitors and market insights
    example_competitors = """
    ## Competitor Analysis
    
    ### OptimizeShip
    A logistics optimization platform focused on route planning.
    
    **Strengths:**
    - Strong route optimization algorithms
    - Established market presence
    
    **Weaknesses:**
    - Lacks real-time adaptation
    - No packaging optimization
    
    ### PackTech
    Specializes in packaging optimization for shipping.
    
    **Strengths:**
    - Deep expertise in packaging materials
    - Integration with major e-commerce platforms
    
    **Weaknesses:**
    - No route optimization capabilities
    - Limited AI implementation
    """
    
    example_market_insights = """
    ## Market Insights
    
    The logistics optimization market is experiencing rapid growth due to:
    
    1. Increasing e-commerce sales globally
    2. Rising shipping costs and supply chain disruptions
    3. Growing emphasis on sustainability in shipping
    4. Advancements in AI and machine learning technologies
    
    Major trends include:
    - Integration of IoT devices for real-time tracking
    - Demand for environmentally-friendly shipping solutions
    - Consolidation among logistics technology providers
    """
    
    print("=== AWS S3 Storage Example ===")
    print(f"Using bucket: {s3_storage.bucket_name}")
    print(f"Example script ID: {example_script_id}")
    
    # Step 1: Save pitch data
    print("\n--- Step 1: Saving pitch data ---")
    save_result = s3_storage.save_pitch_data(
        script_id=example_script_id,
        elevator_pitch=example_elevator_pitch,
        full_pitch=example_full_pitch,
        competitors_data=example_competitors,
        market_insights=example_market_insights
    )
    
    if save_result["success"]:
        print(f"βœ… Successfully saved pitch data")
        print(f"S3 path: {save_result['s3_path']}")
    else:
        print(f"❌ Failed to save pitch data: {save_result['message']}")
        return
    
    # Step 2: Retrieve pitch data
    print("\n--- Step 2: Retrieving pitch data ---")
    retrieve_result = s3_storage.get_pitch_data(example_script_id)
    
    if retrieve_result["success"]:
        pitch_data = retrieve_result["data"]
        print("βœ… Successfully retrieved pitch data")
        print(f"Retrieved script ID: {pitch_data['script_id']}")
        print(f"Created at: {pitch_data['created_at']}")
        print("\nElevator pitch preview:")
        print(f""{pitch_data['elevator_pitch']}"")
    else:
        print(f"❌ Failed to retrieve pitch data: {retrieve_result['message']}")
    
    # Step 3: List pitches
    print("\n--- Step 3: Listing pitches ---")
    list_result = s3_storage.list_pitches(limit=5)
    
    if list_result["success"]:
        pitches = list_result["pitches"]
        print(f"βœ… Successfully listed pitches. Total count: {list_result['count']}")
        
        if list_result["count"] > 0:
            print("\nRecent pitches:")
            for i, pitch in enumerate(pitches[:5], 1):  # Show up to 5 pitches
                print(f"{i}. {pitch['script_id']} (modified: {pitch['last_modified'].split('T')[0]})")
    else:
        print(f"❌ Failed to list pitches: {list_result['message']}")
    
    print("\n=== Example Complete ===")
    print(f"You can view this example pitch using the command:")
    print(f"python -m app.scripts_storage.get_pitch_details {example_script_id}")

if __name__ == "__main__":
    aws_storage_example()