Skip to content

Commit 8627d91

Browse files
authored
Merge pull request #3 from newrelic/ftr/chatbot
Ftr/chatbot
2 parents 77d63a3 + be3b406 commit 8627d91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2096
-476
lines changed

.env-example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
OPENAI_LOG=info
2+
OPENAI_API_KEY=key
3+
BASE_URL=openai_url
4+
NEW_RELIC_API_KEY=NEW_RELIC_USER_API_KEY
5+
NEW_RELIC_ACCOUNT_ID=NEW_RELIC_ACCOUNT_ID
6+
NEW_RELIC_LICENSE_KEY=NEW_RELIC_LICENSE_KEY
7+
APP_NAME=your_name

.gitignore

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,16 @@ terraform-initial-setup/terraform.tfstate
44
act-secrets.env
55
**/.DS_Store
66
**/keys.txt
7-
**/*.log*
7+
**/*.log*
8+
__pycache__/
9+
*.pyc
10+
.venv/
11+
env/
12+
venv/
13+
.env
14+
*.tar
15+
*.log
16+
.vscode/
17+
*.cache
18+
model/
19+
todos.md

README.md

Lines changed: 13 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,23 @@
11
# relibank
22

3-
TODOs
3+
---
44

5-
DB interface python with endpoints for auth service
6-
DONE placeholder for posts/puts, so we can implement adding new accounts later
5+
### ⚙️ Test connection to New Relic
76

8-
DONE In Transactions, add a DB table that stores outstanding balance on a loan/credit account, amount on a checking/savings account
9-
Add Transaction types:
10-
shopping | credit_card | loan | entertainment | utilities | groceries | gas | etc
7+
1. Connect to the service's container, docker example `docker exec -it bill-pay /bin/sh`
118

12-
DONE In Bill Pay, add from/to account
13-
DONE Enforce uniqueness on BillIDs
14-
Check that to/fromaccount is valid, check balance on each before initiating payment or cancel if it's impossible
9+
2. newrelic-admin validate-config LOCATION_OF_NEWRELIC.INI
1510

16-
In Accounts, add an account for Relibank that will handle all loan payments. Build out loan payments in the code
11+
3. If needed, add a logfile to newrelic.ini
12+
```[newrelic]
13+
log_file = /app/newrelic.log
14+
log_level = info
15+
```
1716

18-
Convert logging.info calls to json instead of flat logs
17+
4. Validate logs with ```docker exec -it bill-pay cat newrelic-agent.log```
1918

20-
## Ledger details and decision log
19+
---
2120

22-
Get Ledger/loan/credit card payment history
23-
{
24-
"TransactionID": 1,
25-
"EventType": "BillPaymentInitiated",
26-
"BillID": "BILL-TEST-068",
27-
"Amount": 76.0,
28-
"Currency": "USD",
29-
"ToAccount": 873657890,
30-
"FromAccount": 872347890,
31-
"Timestamp": 1755028460.4713438,
32-
"CancellationUserID": null,
33-
"CancellationTimestamp": null
34-
},
21+
### ⚙️ Formatting
3522

36-
For toaccount, query database and reduce total by amount
37-
for fromaccount, query database and reduce total by amount
38-
39-
Querying account 1234
40-
display ledger for current total
41-
query transaction database for every transaction with to or from containing the account 1234
42-
43-
Venmo example
44-
You paid x $3.50
45-
x paid you $4.50
46-
47-
Debit acct example
48-
Payment to AmEx -$x.xx
49-
To **xx-444 -$x.xx
50-
DIVIDEND
51-
52-
Credit acct example
53-
Pending
54-
Active - VendorName -$x.xx
55-
56-
Activity
57-
Credit Card Payment +$x.xx
58-
Vendor -$x.xx
59-
60-
Account balance in debit is reduced by $76
61-
{
62-
"TransactionID": 1,
63-
"EventType": "BillPaidToAccount",
64-
"BillID": "BILL-TEST-068",
65-
"Amount": 76.0,
66-
"Currency": "USD",
67-
"Account": 873657890,
68-
"Timestamp": 1755028460.4713438,
69-
"CancellationUserID": null,
70-
"CancellationTimestamp": null
71-
},
72-
73-
74-
Loan principal is reduced by $76
75-
{
76-
"TransactionID": 1,
77-
"EventType": "BillPaidFromAccount",
78-
"BillID": "BILL-TEST-068",
79-
"Amount": 76.0,
80-
"Currency": "USD",
81-
"Account": 873657890,
82-
"Timestamp": 1755028460.4713438,
83-
"CancellationUserID": null,
84-
"CancellationTimestamp": null
85-
},
86-
Get eventtype
87-
edit DB for Account 1234
88-
Reduce total by Amount
23+
1. ```ruff format``` https://docs.astral.sh/ruff/formatter/#ruff-format

accounts_service/Dockerfile

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,34 @@ FROM python:3.12-slim
44
# Set the working directory in the container
55
WORKDIR /app
66

7+
ARG NEW_RELIC_APP_NAME="${APP_NAME} - Accounts Service"
8+
ENV NEW_RELIC_APP_NAME=$NEW_RELIC_APP_NAME
9+
10+
ARG NEW_RELIC_USER_API_KEY
11+
ENV NEW_RELIC_API_KEY=$NEW_RELIC_USER_API_KEY
12+
13+
ARG NEW_RELIC_ACCOUNT_ID
14+
ENV NEW_RELIC_ACCOUNT_ID=$NEW_RELIC_ACCOUNT_ID
15+
16+
ARG NEW_RELIC_LICENSE_KEY
17+
ENV NEW_RELIC_LICENSE_KEY=$NEW_RELIC_LICENSE_KEY
18+
19+
ENV NEW_RELIC_DISTRIBUTED_TRACING_ENABLED=true
20+
721
# Install build dependencies required for psycopg2-binary
822
RUN apt-get update && apt-get install -y --no-install-recommends \
923
libpq-dev \
1024
gcc
1125

12-
# Copy the requirements file into the container
13-
COPY requirements.txt .
26+
# Copy the application code file
27+
COPY . .
1428

1529
# Install Python dependencies
16-
RUN pip install --no-cache-dir -r requirements.txt
17-
18-
# Copy the application code file
19-
COPY accounts_service.py .
30+
# RUN pip install --no-cache-dir -r requirements.txt
31+
RUN pip install uv && uv sync
2032

2133
# Expose the port the FastAPI app will run on
2234
EXPOSE 5000
2335

2436
# Command to run the application using Uvicorn
25-
CMD ["uvicorn", "accounts_service:app", "--host", "0.0.0.0", "--port", "5000", "--workers", "1"]
37+
CMD ["uv", "run", "newrelic-admin", "run-program", "uvicorn", "accounts_service:app", "--host", "0.0.0.0", "--port", "5000", "--workers", "1", "--log-config", "logging.conf"]

0 commit comments

Comments
 (0)