eventbooking-cloud 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: eventbooking-cloud
3
+ Version: 0.1.0
4
+ Summary: Reusable AWS cloud workflow helpers for event booking applications.
5
+ Author: Lakshmi
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://pypi.org/project/eventbooking-cloud/
8
+ Project-URL: Repository, https://github.com/lakshmikalavathi2004/cpp-project
9
+ Keywords: aws,event-booking,dynamodb,sqs,sns,lambda,s3
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: boto3>=1.28
21
+ Dynamic: license-file
22
+
23
+ # eventbooking-cloud
24
+
25
+ `eventbooking-cloud` is a reusable Python library extracted from this project's AWS booking workflow. It helps applications coordinate the same core cloud services used in the app:
26
+
27
+ - `DynamoDB` for booking records
28
+ - `SQS` for queueing booking jobs
29
+ - `AWS Lambda` for booking processing
30
+ - `SNS` for email notifications
31
+ - `S3` for ticket storage
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install eventbooking-cloud
37
+ ```
38
+
39
+ ## What the library provides
40
+
41
+ - A `BookingRequest` model for normalized booking input
42
+ - A `BookingResult` model for normalized booking output
43
+ - An `EventBookingCloudClient` class for:
44
+ - saving booking records to DynamoDB
45
+ - sending booking messages to SQS
46
+ - subscribing user emails to SNS
47
+ - invoking a booking Lambda function
48
+ - building a safe app ticket URL
49
+
50
+ ## Example
51
+
52
+ ```python
53
+ from eventbooking_cloud import BookingRequest, EventBookingCloudClient
54
+
55
+ client = EventBookingCloudClient(
56
+ region_name="us-east-1",
57
+ users_table="Users",
58
+ events_table="Events",
59
+ bookings_table="Bookings",
60
+ bucket_name="elasticbeanstalk-us-east-1-864148790210",
61
+ queue_name="BookingQueue",
62
+ topic_name="EventNotifications",
63
+ lambda_name="event-booking-processor",
64
+ app_base_url="https://example.com",
65
+ )
66
+
67
+ request = BookingRequest(
68
+ booking_id="booking-123",
69
+ event_id="event-456",
70
+ event_name="Kala Events",
71
+ username="lakshmi",
72
+ email="lakshmi@example.com",
73
+ ticket_access_token="secure-token",
74
+ booked_at="2026-04-15T08:00:00+00:00",
75
+ )
76
+
77
+ client.store_booking(request)
78
+ client.enqueue_booking(request)
79
+ client.subscribe_email(request.email)
80
+ result = client.invoke_processor(request)
81
+
82
+ print(result.ticket_url)
83
+ ```
84
+
85
+ ## Build for PyPI
86
+
87
+ From the project root:
88
+
89
+ ```bash
90
+ python -m pip install --upgrade build twine
91
+ python -m build
92
+ python -m twine check dist/*
93
+ ```
94
+
95
+ This creates:
96
+
97
+ - `dist/*.tar.gz`
98
+ - `dist/*.whl`
99
+
100
+ ## Upload to TestPyPI
101
+
102
+ ```bash
103
+ python -m twine upload --repository testpypi dist/*
104
+ ```
105
+
106
+ ## Upload to PyPI
107
+
108
+ ```bash
109
+ python -m twine upload dist/*
110
+ ```
111
+
112
+ ## Recommended PyPI checklist
113
+
114
+ - Create a PyPI account
115
+ - Create a TestPyPI account
116
+ - Generate an API token
117
+ - Use the API token with `twine`
118
+ - Verify the package page after upload
119
+
120
+ ## Notes for your viva
121
+
122
+ You can explain that the app itself is a Flask project, but the reusable AWS cloud workflow was separated into a Python package so the same booking logic can be reused in other projects and published through PyPI.
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ ./.codex-egg-info/eventbooking_cloud.egg-info/PKG-INFO
6
+ ./.codex-egg-info/eventbooking_cloud.egg-info/SOURCES.txt
7
+ ./.codex-egg-info/eventbooking_cloud.egg-info/dependency_links.txt
8
+ ./.codex-egg-info/eventbooking_cloud.egg-info/requires.txt
9
+ ./.codex-egg-info/eventbooking_cloud.egg-info/top_level.txt
10
+ .codex-egg-info/eventbooking_cloud.egg-info/SOURCES.txt
11
+ src/eventbooking_cloud/__init__.py
12
+ src/eventbooking_cloud/client.py
13
+ src/eventbooking_cloud/models.py
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lakshmi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.4
2
+ Name: eventbooking-cloud
3
+ Version: 0.1.0
4
+ Summary: Reusable AWS cloud workflow helpers for event booking applications.
5
+ Author: Lakshmi
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://pypi.org/project/eventbooking-cloud/
8
+ Project-URL: Repository, https://github.com/lakshmikalavathi2004/cpp-project
9
+ Keywords: aws,event-booking,dynamodb,sqs,sns,lambda,s3
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: boto3>=1.28
21
+ Dynamic: license-file
22
+
23
+ # eventbooking-cloud
24
+
25
+ `eventbooking-cloud` is a reusable Python library extracted from this project's AWS booking workflow. It helps applications coordinate the same core cloud services used in the app:
26
+
27
+ - `DynamoDB` for booking records
28
+ - `SQS` for queueing booking jobs
29
+ - `AWS Lambda` for booking processing
30
+ - `SNS` for email notifications
31
+ - `S3` for ticket storage
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install eventbooking-cloud
37
+ ```
38
+
39
+ ## What the library provides
40
+
41
+ - A `BookingRequest` model for normalized booking input
42
+ - A `BookingResult` model for normalized booking output
43
+ - An `EventBookingCloudClient` class for:
44
+ - saving booking records to DynamoDB
45
+ - sending booking messages to SQS
46
+ - subscribing user emails to SNS
47
+ - invoking a booking Lambda function
48
+ - building a safe app ticket URL
49
+
50
+ ## Example
51
+
52
+ ```python
53
+ from eventbooking_cloud import BookingRequest, EventBookingCloudClient
54
+
55
+ client = EventBookingCloudClient(
56
+ region_name="us-east-1",
57
+ users_table="Users",
58
+ events_table="Events",
59
+ bookings_table="Bookings",
60
+ bucket_name="elasticbeanstalk-us-east-1-864148790210",
61
+ queue_name="BookingQueue",
62
+ topic_name="EventNotifications",
63
+ lambda_name="event-booking-processor",
64
+ app_base_url="https://example.com",
65
+ )
66
+
67
+ request = BookingRequest(
68
+ booking_id="booking-123",
69
+ event_id="event-456",
70
+ event_name="Kala Events",
71
+ username="lakshmi",
72
+ email="lakshmi@example.com",
73
+ ticket_access_token="secure-token",
74
+ booked_at="2026-04-15T08:00:00+00:00",
75
+ )
76
+
77
+ client.store_booking(request)
78
+ client.enqueue_booking(request)
79
+ client.subscribe_email(request.email)
80
+ result = client.invoke_processor(request)
81
+
82
+ print(result.ticket_url)
83
+ ```
84
+
85
+ ## Build for PyPI
86
+
87
+ From the project root:
88
+
89
+ ```bash
90
+ python -m pip install --upgrade build twine
91
+ python -m build
92
+ python -m twine check dist/*
93
+ ```
94
+
95
+ This creates:
96
+
97
+ - `dist/*.tar.gz`
98
+ - `dist/*.whl`
99
+
100
+ ## Upload to TestPyPI
101
+
102
+ ```bash
103
+ python -m twine upload --repository testpypi dist/*
104
+ ```
105
+
106
+ ## Upload to PyPI
107
+
108
+ ```bash
109
+ python -m twine upload dist/*
110
+ ```
111
+
112
+ ## Recommended PyPI checklist
113
+
114
+ - Create a PyPI account
115
+ - Create a TestPyPI account
116
+ - Generate an API token
117
+ - Use the API token with `twine`
118
+ - Verify the package page after upload
119
+
120
+ ## Notes for your viva
121
+
122
+ You can explain that the app itself is a Flask project, but the reusable AWS cloud workflow was separated into a Python package so the same booking logic can be reused in other projects and published through PyPI.
@@ -0,0 +1,100 @@
1
+ # eventbooking-cloud
2
+
3
+ `eventbooking-cloud` is a reusable Python library extracted from this project's AWS booking workflow. It helps applications coordinate the same core cloud services used in the app:
4
+
5
+ - `DynamoDB` for booking records
6
+ - `SQS` for queueing booking jobs
7
+ - `AWS Lambda` for booking processing
8
+ - `SNS` for email notifications
9
+ - `S3` for ticket storage
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pip install eventbooking-cloud
15
+ ```
16
+
17
+ ## What the library provides
18
+
19
+ - A `BookingRequest` model for normalized booking input
20
+ - A `BookingResult` model for normalized booking output
21
+ - An `EventBookingCloudClient` class for:
22
+ - saving booking records to DynamoDB
23
+ - sending booking messages to SQS
24
+ - subscribing user emails to SNS
25
+ - invoking a booking Lambda function
26
+ - building a safe app ticket URL
27
+
28
+ ## Example
29
+
30
+ ```python
31
+ from eventbooking_cloud import BookingRequest, EventBookingCloudClient
32
+
33
+ client = EventBookingCloudClient(
34
+ region_name="us-east-1",
35
+ users_table="Users",
36
+ events_table="Events",
37
+ bookings_table="Bookings",
38
+ bucket_name="elasticbeanstalk-us-east-1-864148790210",
39
+ queue_name="BookingQueue",
40
+ topic_name="EventNotifications",
41
+ lambda_name="event-booking-processor",
42
+ app_base_url="https://example.com",
43
+ )
44
+
45
+ request = BookingRequest(
46
+ booking_id="booking-123",
47
+ event_id="event-456",
48
+ event_name="Kala Events",
49
+ username="lakshmi",
50
+ email="lakshmi@example.com",
51
+ ticket_access_token="secure-token",
52
+ booked_at="2026-04-15T08:00:00+00:00",
53
+ )
54
+
55
+ client.store_booking(request)
56
+ client.enqueue_booking(request)
57
+ client.subscribe_email(request.email)
58
+ result = client.invoke_processor(request)
59
+
60
+ print(result.ticket_url)
61
+ ```
62
+
63
+ ## Build for PyPI
64
+
65
+ From the project root:
66
+
67
+ ```bash
68
+ python -m pip install --upgrade build twine
69
+ python -m build
70
+ python -m twine check dist/*
71
+ ```
72
+
73
+ This creates:
74
+
75
+ - `dist/*.tar.gz`
76
+ - `dist/*.whl`
77
+
78
+ ## Upload to TestPyPI
79
+
80
+ ```bash
81
+ python -m twine upload --repository testpypi dist/*
82
+ ```
83
+
84
+ ## Upload to PyPI
85
+
86
+ ```bash
87
+ python -m twine upload dist/*
88
+ ```
89
+
90
+ ## Recommended PyPI checklist
91
+
92
+ - Create a PyPI account
93
+ - Create a TestPyPI account
94
+ - Generate an API token
95
+ - Use the API token with `twine`
96
+ - Verify the package page after upload
97
+
98
+ ## Notes for your viva
99
+
100
+ You can explain that the app itself is a Flask project, but the reusable AWS cloud workflow was separated into a Python package so the same booking logic can be reused in other projects and published through PyPI.
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "eventbooking-cloud"
7
+ version = "0.1.0"
8
+ description = "Reusable AWS cloud workflow helpers for event booking applications."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [
13
+ { name = "Lakshmi" }
14
+ ]
15
+ keywords = ["aws", "event-booking", "dynamodb", "sqs", "sns", "lambda", "s3"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ ]
25
+ dependencies = [
26
+ "boto3>=1.28"
27
+ ]
28
+
29
+ [project.urls]
30
+ Homepage = "https://pypi.org/project/eventbooking-cloud/"
31
+ Repository = "https://github.com/lakshmikalavathi2004/cpp-project"
32
+
33
+ [tool.setuptools]
34
+ package-dir = {"" = "src"}
35
+
36
+ [tool.setuptools.packages.find]
37
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ from setuptools import setup
2
+
3
+
4
+ setup()
@@ -0,0 +1,8 @@
1
+ from .client import EventBookingCloudClient
2
+ from .models import BookingRequest, BookingResult
3
+
4
+ __all__ = [
5
+ "BookingRequest",
6
+ "BookingResult",
7
+ "EventBookingCloudClient",
8
+ ]
@@ -0,0 +1,120 @@
1
+ import json
2
+ from typing import Any
3
+
4
+ import boto3
5
+
6
+ from .models import BookingRequest, BookingResult
7
+
8
+
9
+ class EventBookingCloudClient:
10
+ def __init__(
11
+ self,
12
+ *,
13
+ region_name: str,
14
+ users_table: str,
15
+ events_table: str,
16
+ bookings_table: str,
17
+ bucket_name: str,
18
+ queue_name: str,
19
+ topic_name: str,
20
+ app_base_url: str,
21
+ lambda_name: str = "",
22
+ aws_access_key_id: str | None = None,
23
+ aws_secret_access_key: str | None = None,
24
+ aws_session_token: str | None = None,
25
+ ) -> None:
26
+ session_kwargs: dict[str, Any] = {"region_name": region_name}
27
+ if aws_access_key_id and aws_secret_access_key:
28
+ session_kwargs.update(
29
+ {
30
+ "aws_access_key_id": aws_access_key_id,
31
+ "aws_secret_access_key": aws_secret_access_key,
32
+ "aws_session_token": aws_session_token,
33
+ }
34
+ )
35
+
36
+ self.session = boto3.Session(**session_kwargs)
37
+ self.region_name = region_name
38
+ self.users_table_name = users_table
39
+ self.events_table_name = events_table
40
+ self.bookings_table_name = bookings_table
41
+ self.bucket_name = bucket_name
42
+ self.queue_name = queue_name
43
+ self.topic_name = topic_name
44
+ self.lambda_name = lambda_name
45
+ self.app_base_url = app_base_url.rstrip("/")
46
+
47
+ self.dynamodb = self.session.resource("dynamodb")
48
+ self.s3 = self.session.client("s3")
49
+ self.sqs = self.session.client("sqs")
50
+ self.sns = self.session.client("sns")
51
+ self.lambda_client = self.session.client("lambda")
52
+
53
+ self.bookings_table = self.dynamodb.Table(self.bookings_table_name)
54
+
55
+ def get_topic_arn(self) -> str:
56
+ response = self.sns.create_topic(Name=self.topic_name)
57
+ return response["TopicArn"]
58
+
59
+ def build_ticket_view_url(self, booking_id: str, access_token: str) -> str:
60
+ return f"{self.app_base_url}/ticket/{booking_id}?token={access_token}"
61
+
62
+ def store_booking(self, request: BookingRequest) -> None:
63
+ self.bookings_table.put_item(Item=request.to_item())
64
+
65
+ def enqueue_booking(self, request: BookingRequest) -> bool:
66
+ try:
67
+ queue_url = self.sqs.get_queue_url(QueueName=self.queue_name)["QueueUrl"]
68
+ self.sqs.send_message(
69
+ QueueUrl=queue_url,
70
+ MessageBody=json.dumps(request.to_item()),
71
+ )
72
+ return True
73
+ except Exception:
74
+ return False
75
+
76
+ def subscribe_email(self, email: str) -> str | None:
77
+ try:
78
+ topic_arn = self.get_topic_arn()
79
+ response = self.sns.list_subscriptions_by_topic(TopicArn=topic_arn)
80
+ for subscription in response.get("Subscriptions", []):
81
+ if subscription.get("Protocol") == "email" and subscription.get("Endpoint") == email:
82
+ return subscription.get("SubscriptionArn")
83
+
84
+ created = self.sns.subscribe(
85
+ TopicArn=topic_arn,
86
+ Protocol="email",
87
+ Endpoint=email,
88
+ )
89
+ return created.get("SubscriptionArn")
90
+ except Exception:
91
+ return None
92
+
93
+ def invoke_processor(self, request: BookingRequest) -> BookingResult:
94
+ fallback_url = self.build_ticket_view_url(request.booking_id, request.ticket_access_token)
95
+
96
+ if not self.lambda_name:
97
+ return BookingResult(
98
+ booking_id=request.booking_id,
99
+ message="Lambda processor name not configured.",
100
+ ticket_url=fallback_url,
101
+ )
102
+
103
+ response = self.lambda_client.invoke(
104
+ FunctionName=self.lambda_name,
105
+ InvocationType="RequestResponse",
106
+ Payload=json.dumps({"Records": [{"body": json.dumps(request.to_item())}]}).encode("utf-8"),
107
+ )
108
+
109
+ payload_stream = response.get("Payload")
110
+ raw_payload = payload_stream.read().decode("utf-8") if payload_stream else ""
111
+ parsed = json.loads(raw_payload) if raw_payload else {}
112
+ body = parsed.get("body", parsed)
113
+ if isinstance(body, str):
114
+ body = json.loads(body)
115
+
116
+ return BookingResult(
117
+ booking_id=body.get("booking_id", request.booking_id),
118
+ message=body.get("message", "Booking processed."),
119
+ ticket_url=body.get("ticket_url", fallback_url),
120
+ )
@@ -0,0 +1,31 @@
1
+ from dataclasses import asdict, dataclass
2
+
3
+
4
+ @dataclass(slots=True)
5
+ class BookingRequest:
6
+ booking_id: str
7
+ event_id: str
8
+ event_name: str
9
+ username: str
10
+ email: str
11
+ ticket_access_token: str
12
+ booked_at: str
13
+ booking_status: str = "pending"
14
+ message_type: str = "NEW_BOOKING"
15
+
16
+ def to_item(self) -> dict:
17
+ item = asdict(self)
18
+ item["type"] = item.pop("message_type")
19
+ return item
20
+
21
+
22
+ @dataclass(slots=True)
23
+ class BookingResult:
24
+ booking_id: str
25
+ message: str
26
+ ticket_url: str | None = None
27
+ queue_sent: bool = False
28
+ subscription_arn: str | None = None
29
+
30
+ def to_dict(self) -> dict:
31
+ return asdict(self)