Tag: python

  • The Boring Stack Behind My API Side Product

    The Boring Stack Behind My API Side Product

    If you remember, SEO Score API started as my OpenClaw experiment on a single EC2 instance. Nine months later it’s still on one box, and honestly that’s on purpose.

    Here’s the whole stack:

    • FastAPI, as plain modules: one file for the app and one per job (audits, keys, billing, email).
    • SQLite in WAL mode for keys and usage, backed up off the box.
    • One EC2 instance behind nginx, in its own AWS account.
    • Blue-green deploys with systemd, run by GitHub Actions.
    • Amazon SES for email, Stripe for billing, Terraform for the infrastructure.

    That’s it. No Postgres, no containers, no orchestration platform.

    Why so boring? Because I work on this in the evenings. When something breaks at 11pm I want one box, one database file and one log. I know exactly where to look.

    SQLite surprises people the most. An API key lookup is a single indexed read, and I’ll move to Postgres the day it hurts, not before. The one setting that matters is write-ahead logging, so readers keep going while a write happens:

    conn.execute("PRAGMA journal_mode=WAL;")

    The catch is that the database is a file on one server, so backups aren’t optional. If the instance disappeared tomorrow I’d rebuild it with Terraform and restore the file.

    Blue-green is the part I’d recommend to anyone. Two systemd services run the same app on two ports. GitHub Actions puts the new code in the idle slot, a health check hits it, and only if it passes does nginx switch over. A bad build never takes traffic. Before this, a bad deploy meant downtime. Now deploys are boring too, which is exactly what I want.

    To be clear, EC2 is the right call for this product specifically. Audits can run long and some drive a headless browser, which suits a server that’s always on. Everywhere else my default is serverless.

    If I did it again, I’d put it in its own AWS account from day one. Moving it in October took longer than building most features!

    If you’re building an API side project and want to compare notes, feel free to reach out. The API docs are here if you want to poke at the result.

  • What I’ve added to GridIron Data in the last month

    What I’ve added to GridIron Data in the last month

    If you’ve been following my fantasy football posts, you know I run my team off a data set I’ve been building at gridirondata.com. Over the last month or so it went from “an API I use for my own team” to something I’d actually put up against the paid services. My team is 6-3 and in second place overall, though I’m on a two-week losing streak, so the data isn’t magic. I’ve been actively building and adding new features (and users!).

    It works inside your AI assistant now

    This is the big one. GridIron Data now has a hosted MCP server, so you can connect it to ChatGPT, Claude, Cursor, VS Code, Gemini CLI and a few others. You sign in with your GridIron account and then just ask questions:

    • “What are the top 10 RB projections for week 11 in half-PPR?”
    • “Any injury news on this player?”
    • “Who are the Bears’ starting wide receivers?”

    The assistant pulls the answer from live data instead of guessing. There’s a setup guide with a page for each assistant (ChatGPT, Claude, Cursor, Gemini CLI, GitHub Copilot), and it’s listed in the official MCP Registry. I’ve also submitted it to the Claude and Perplexity directories, and the ChatGPT plugin is in review.

    This fixed the exact problem I wrote about in week 7, when my AI agent didn’t know Trevor Lawrence and Josh Allen were on bye. It can look that up now.

    My own weekly projections

    Until now the projections came from outside sources. GridIron now makes its own. They start from public play-by-play data and weather, then blend in sportsbook player prop lines, snap share and a bias correction. On game day they refresh as inactives come out, and they freeze at kickoff.

    Every Tuesday a report card grades last week’s projections against what actually happened. If they’re off, you’ll see it.

    Injuries within minutes

    Injury statuses now update within a couple of minutes of a change, with a daily cross-check against a second source. Pro accounts can get those changes pushed to them by webhook, so you don’t have to keep asking.

    Injury and news history is kept for about three years now, which is what made my in-game injury backtest possible.

    Betting and prop data

    A note first: I don’t condone or support gambling. This section is for people who build their own models and like the numbers, and nothing here is betting advice.

    For the people who build their own prop models:

    • Player-prop probabilities: give it a stat line and it returns the chance of going over or under, plus fair no-vig odds. It’s a model estimate.
    • Per-stat projections, odds on the schedule and defense vs position.
    • A usage endpoint with target share and carry share, and box score lines on the stats.
    • A Friday post with the week’s usage data for prop modelers, and a guide for pricing props yourself.

    More of the data you need on game day

    • Depth charts for all 32 teams, with the real starter at every position on offense and defense.
    • Official game-day inactives.
    • Offensive line injury data, because a missing left tackle matters more than people think.
    • Rest-of-season projections, the schedule and bye weeks.
    • Lookups by ESPN or NFL player id, so it’s easier to match against other data sets.
    • The news desk now follows the top 300 players instead of 150.

    Easier to start, easier to pay for

    • Sign in with Google or GitHub.
    • A free plan that covers player lookups and this week’s projections.
    • Yearly billing: Basic is $45 a year and Pro is $249 a year.
    • A Pro + Commercial plan ($49 a month or $490 a year) for anyone building a product on the data, with a commercial license.
    • An off-season pause, so you’re not paying in March. It picks back up August 1.
    • An affiliate program that pays out through Stripe.

    Guides and videos

    Most of the guides now have a short narrated video walkthrough: start/sit, streaming by matchup history, backtesting projections, pricing props, the trade analyzer and connecting an AI assistant. They’re all on the guides page. There’s also a Python client and a published OpenAPI spec if you’d rather skip straight to code.

    You can also follow along on X at @gridirondata_ai. It posts the Friday prop notes and the Wednesday projection grades automatically.

    What’s next

    Next up is getting ready for the off-season: rookies, the draft and dynasty data, so there’s something useful between February and August.

    If you play fantasy football or tinker with sports data, a free account is at gridirondata.com. If you connect it to your AI assistant, let me know what you ask it. That’s where most of my ideas for this have come from.

  • Cloudwatch Alarm AI Agent

    I think one of the biggest time sucks is getting a vague alert or issue and not having a clue on where to start with troubleshooting.

    I covered this in the past when I built an agent that can review your AWS bill and find practical ways to save money within your account. This application wasn’t event driven but rather a container that you could spin up when you needed a review or something you could leave running in your environment. If we take a same read-only approach to building an AWS Agent we can have have a new event driven teammate that helps us with our initial troubleshooting.

    The process flow is straight forward:

    1. Given a Cloudwatch Alarm
    2. Send a notification to SNS
    3. Subscribe a Lambda function to the topic (this is our teammate)
    4. The function utilizes the AWS Nova Lite model to investigate the contents of the alarm and utilizes its read only capabilities to find potential solutions
    5. The agent sends its findings to you on your preferred platform

    For my environment I primarily utilize Slack for alerting and messaging so I built that integration. Here is an architecture diagram:

    When the alarm triggers we should see a message in Slack like:

    The AI is capable of providing you actionable steps to either find the root cause of the problem or in some cases, present you with steps to solve the problem.

    This workflow significantly reduces your troubleshooting time and by reducing the troubleshooting time it reduces your downtime.

    So, if this is something you are interested in deploying I have created a Terraform module so you can quickly deploy it into your own environment to reduce your troubleshooting steps!

    Check it out here: https://aiopscrew.com

    If you have questions feel free to reach out to me at anytime!

  • Fantasy Football and AI – Playoffs Round 1

    So I was wrong in last weeks post! Our playoffs started this week. In my league all the teams go to the playoffs and if you lose then there is a loser’s bracket.

    Our AI run team was seeded at number 3. We were in a three way tie for first place and we ended the “regular season” with 2054.76 points. The leader had 2114.12. So, we weren’t far off the front!

    Anyway, enough of that. You all just want to know the outcome. Here is our point totals from our first round in the playoffs:

    I ran the AI on Saturday and it suggested pulling out Josh Jacobs in favor of TreVeyon Henderson. This ended up getting us an extra 10 points. Josh Jacobs still put up 24.2 points this week. Everyone played really well this week except Sam Darnold. I’m not sure if his hot streak is over or what is going on with him but its been rough. Christian Watson took a nasty hit in his game and left early but he is expected to be just fine.

    So, did we win? We sure did! We’re on to the next round of the playoffs and we’re going to be up against Jahmyr Gibbs so we have to hope for our best performance of the season next week. Here is the currently proposed roster:

    We have a lot of injuries and questionable players so I expect this to change. We picked up the Bills defense as they play Cleveland and they should have a good time against that struggling offense.

    As we look to the off season I hope to build up my API website https://gridirondata.com and start training the model that we will use for next year. I have been working on the overall workflow and looking into how I can have both the scrapers running in the cloud and in my homelab so that I can easily work with the data locally and not incur a lot of cloud cost.

    Stay tuned for more Fantasy Football news next week!

  • Fantasy Football and AI – Week 12

    Well, unfortunately we took a big loss and are now in a three way tie for first place. Here are the actual results:

    I think the biggest hit was how poorly Josh Allen played. What is interesting is that I was reviewing his passed performance against Houston and he has had his worst outings of his career there. This week was no different… The other interesting thing is that Saquon Barkley just isn’t the same back as he was last year. He is trending down.

    In response to Josh Allen’s poor outing I added a deviation and historical performance analysis against and opponent to the data set so now we have a value like:

    "HOU": {
       "avg_actual": 11.6,
       "avg_deviation": -2.67,
       "avg_deviation_percentage": -18.69,
       "avg_projected": 14.27,
       "by_season": {
        "2024": {
         "avg_actual": 14.6,
         "avg_deviation": 0,
         "avg_deviation_percentage": 0,
         "avg_projected": 0,
         "games_played": 1,
         "games_with_projections": 0
        },
        "2025": {
         "avg_actual": 5.05,
         "avg_deviation": -5.65,
         "avg_deviation_percentage": -52.8,
         "avg_projected": 10.7,
         "games_played": 2,
         "total_actual": 10.1,
         "total_projected": 21.4
        }
       },

    I then coded a new tool inside of the AI to reference this data set to assist with its final calculations.

    So, when we ask the tool about Josh Allen’s performance against a team we get something like:

    Found exactly what you're looking for in Josh Allen's performance data.
    
    Josh Allen vs Kansas City (Week 9, 2025):
    - 28.8 fantasy points - That's a STRONG performance!
    - He was projected for 22.0 points but exceeded by 6.8 points (+30.9%)
    - This was one of his better games this season
    
    Historical Context (2024 vs KC):
    - Week 11, 2024: 24.0 fantasy points vs Kansas City
    
    Bottom Line: Josh Allen has performed WELL against Kansas City in recent matchups. In their two most recent meetings:
    - 2025 (Week 9): 28.8 points
    - 2024 (Week 11): 24.0 points
    
    That's an average of 26.4 fantasy points against KC - well above his season average. Allen seems to rise to the occasion against elite competition like Kansas City. The Chiefs' defense can be vulnerable to mobile QBs who can extend plays, and Allen's dual-threat ability has historically given them problems.
    
    The takeaway: When Allen faces KC, he typically delivers QB1 numbers. That 28.8-point performance this season shows he can still light up even the defending champs!

    I need to backload some more historical data yet but that is a problem for a different day. Looking forward, I hope to build my own model based on this data and setup an automated workflow that will include data ingestion and automated model building so that I can consistently build predictions.

    So, on to week 13. We have a bunch of injuries this week to contend with so this lineup will likely be changing once people are reporting. Here is the current lineup:

    In other news I built and launched https://gridirondata.com which is an API to reference all of the data I have collected so far.

    Unfortunately, its not free. But if you message me about it I’ll probably hook you up!

  • Building jsontotoon.io: A Free Tool to Cut Your LLM API Costs

    If you’re working with LLM APIs, you’re probably watching your token counts like a hawk. Every JSON object you send to Claude, GPT-4, or Gemini costs tokens, and those curly braces and quotes add up fast. I built https://jsontotoon.io to solve this exact problem—and it’s completely free to use.

    The Problem: JSON is Token-Inefficient

    Here’s the thing: JSON is fantastic for machine-to-machine communication. It’s ubiquitous, well-supported, and everyone knows how to work with it. But when you’re paying per token to send data to an LLM? It’s wasteful.

    Look at a simple example:

    [
      {"name": "Alice", "age": 30, "city": "NYC"},
      {"name": "Bob", "age": 25, "city": "LA"},
      {"name": "Carol", "age": 35, "city": "Chicago"}
    ]

    That’s 125 tokens. All those quotes, braces, and commas? The LLM doesn’t need them to understand the structure. You’re literally paying to send redundant syntax.

    Enter TOON Format

    TOON (Token-Oriented Object Notation) converts that same data to:

    name, age, city
    Alice, 30, NYC
    Bob, 25, LA
    Carol, 35, Chicago

    68 tokens. That’s a 46% reduction. The same information, fully reversible back to JSON, but nearly half the cost.

    I realize this sounds too good to be true, but the math checks out. I tested it across real-world datasets—API responses, database dumps, RAG context—and consistently saw 35-45% token reduction. Your mileage will vary depending on data structure, but the savings are real.

    How I Built It

    The backend is straightforward Python running on AWS Lambda. The TOON parser itself is deterministic—same JSON always produces the same TOON output, and round-trip conversion is lossless. No data gets mangled, no weird edge cases (well, I fixed those during testing).

    Infrastructure-wise:

    – CloudFront + S3 for the static frontend

    – API Gateway + Lambda for the conversion endpoint

    – DynamoDB for API key storage (with email verification via SES)

    – WAF with rate limiting to prevent abuse (10 requests per 5 minutes on API endpoints)

    – CloudWatch dashboards for monitoring

    The whole setup costs me about $8-15/month in AWS fees, mostly for WAF. The conversion itself is so fast (< 100ms average) and cheap that I can offer unlimited free API keys without worrying about runaway costs.

    Real Use Cases

    I built this because I was spending way too much on Claude API calls for my fantasy football AI agent project. Every week I send player stats, injury reports, and matchup data in prompts. Converting to TOON saved me about 38% on tokens—which adds up when you’re making hundreds of calls per week.

    But the use cases go beyond my specific problem:

    – RAG systems: Fit more context documents in your prompts without hitting limits

    – Data analysis agents: Send larger datasets for analysis at lower cost

    – Few-shot learning: Include more examples without token bloat

    – Structured outputs: LLMs can generate TOON that’s easier to parse than JSON

    Try It Yourself

    The web interface at https://jsontotoon.io is free to use—no signup required. Just paste your JSON, get TOON. If you want to integrate it into your application, grab a free API key (also no cost, no expiration).

    Full API docs are available at https://jsontotoon.io/docs.html, with code examples in Python, JavaScript, Go, and cURL.

  • Fantasy Football and AI – Week 10

    Well, week 10 has completed. And, WE WON AGAIN! It was a close one that came down to Monday Night Football. I had to buy a day pass to SlingTV so that I could watch the game due to the Youtube TV and Disney dispute. But, Josh Jacobs squared off against Saquon Barkley in the most BORING of football games. At any point in time, if AJ Brown had scored a touchdown I think we would have lost the matchup. Here are the final results.

    For week 11 we dropped the Panther’s defense. Honestly, im not sure why the AI recommend them. I know the Saint’s are bad, but I think the Panther’s defense is worse. Anyway, we picked up the Bear’s for week 11. Badgley and the Colts have a bye this week so anyone playing against Jonathan Taylor can breathe a sigh of relief. The AI also suggested grabbing Riley Patterson and Zach Ertz. Here is our current lineup for week 11:

    Marvin Harrison Jr. Is out with appendicitis which is a big bummer for his divisional matchup.

    From a technical standpoint, I added in a data source and tool for the AI to check depth charts in order to assist in picking up players. This way it won’t suggest lower players. We can also research picks based on injury. In Marvin Harrison Jr.’s case we can see this:

    Cardinals WR Depth Chart:
    1. Marvin Harrison Jr. - OUT (your guy who's hurting)
    2. Zay Jones - This cat becomes the clear WR1 with Harrison out. He's got experience and should see a big target bump
    3. Simi Fehoko - Depth piece, might see some snaps but not a fantasy factor
    4. Michael Wilson - Could be interesting as a deeper option, might get more looks
    5. Greg Dortch - Slot guy who could see increased usage in 3-WR sets
    6. Xavier Weaver - Rookie, probably not fantasy relevant yet

    One thing to note is that it doesn’t know about other injury statuses yet. So I will be looking to add that in shortly.

    Tied for 1st. Playoffs start soon. Here comes the big push to finish out this season!

  • Fantasy Football and AI – Week 7

    Well, our win streak was too good to be true. Unfortunately we lost a close one in week 6. It came down to the Monday night games and Sam Darnold just wasn’t able to get it going over the Texans even though the Seahawks still pulled out the win.

    Our running back group also did not preform well outside of Josh Jacobs. The loss was by a difference of about 7 points so if anyone had put up another touchdown we could have won.

    Anyway, on to week week 8. A few byes to contend with but otherwise most of are starts will be playing. The AI suggested grabbing the Colts defense and kicker as they are playing Tennessee. Breece Hall is currently questionable to play so we will have to keep an eye on that but he has a favorable matchup against the Bengals. The current roster is below.

    I promised to work on MCP this week but have only made a little bit of progress. I’ve been doing a lot of research on doing it in a cost effective manner as this project makes ZERO dollars and so I can’t afford to setup a bunch of expensive infrastructure. SO – this week I worked on combining the waiver table and the stats table into one table so that we can minimize DynamoDB calls throughout the application. The other thing I did was setup DynamoDB streams which are then converted into text files for each player and placed into an S3 bucket. This is what I think will be the first step in setting up a RAG pipeline so that a model can begin to be more “aware” of current NFL and Fantasy Football landscape.

    Here is an updated architecture diagram. You’ll notice the S3 bucket on the right side. This is the eventual start of our knowledgebase.

    You’ll also notice the waiver table removed. The new player structure looks like this:

    {
     "player_id": "George Kittle#TE",
     "espn_player_id": 3040151,
     "player_name": "George Kittle",
     "position": "TE",
     "seasons": {
      "2024": {
       "season_totals": {
        "MISC_FL": 0,
        "MISC_FPTS": 158.6,
        "MISC_FPTS/G": 10.6,
        "MISC_G": 15,
        "MISC_ROST": "99.4%",
        "Player": "George Kittle",
        "Rank": 1,
        "RECEIVING_20+": 21,
        "RECEIVING_LG": 43,
        "RECEIVING_REC": 78,
        "RECEIVING_TD": 8,
        "RECEIVING_TGT": 94,
        "RECEIVING_Y/R": 14.2,
        "RECEIVING_YDS": 1106,
        "RUSHING_ATT": 0,
        "RUSHING_TD": 0,
        "RUSHING_YDS": 0
       },
       "weekly_stats": {
        "1": {
         "fantasy_points": 4,
         "opponent": "NYJ"
        },
        "2": {
         "fantasy_points": 13.6,
         "opponent": "MIN"
        },
        "4": {
         "fantasy_points": 10.5,
         "opponent": "NE"
        },
        "5": {
         "fantasy_points": 12.4,
         "opponent": "ARI"
        },
        "6": {
         "fantasy_points": 17.8,
         "opponent": "SEA"
        },
        "7": {
         "fantasy_points": 9.2,
         "opponent": "KC"
        },
        "8": {
         "fantasy_points": 18.8,
         "opponent": "DAL"
        },
        "10": {
         "fantasy_points": 11.7,
         "opponent": "TB"
        },
        "12": {
         "fantasy_points": 14.2,
         "opponent": "GB"
        },
        "13": {
         "fantasy_points": 0.7,
         "opponent": "BUF"
        },
        "14": {
         "fantasy_points": 15.1,
         "opponent": "CHI"
        },
        "15": {
         "fantasy_points": 6.1,
         "opponent": "LA"
        },
        "16": {
         "fantasy_points": 10.6,
         "opponent": "MIA"
        },
        "17": {
         "fantasy_points": 11.2,
         "opponent": "DET"
        },
        "18": {
         "fantasy_points": 2.7,
         "opponent": "ARI"
        }
       }
      },
      "2025": {
       "injury_status": "ACTIVE",
       "jersey_number": "85",
       "percent_owned": 98.97,
       "pro_team_id": 25,
       "season_projections": {
        "MISC_FL": 0.5,
        "MISC_FPTS": 147.6,
        "RECEIVING_REC": 76,
        "RECEIVING_TD": 7.5,
        "RECEIVING_YDS": 1036.9
       },
       "team": "SF",
       "weekly_outlooks": {
        "1": "George Kittle is healthy and wealthy for the 49ers' Week 1 matchup against Seattle after signing a big four-year contract extension in the offseason. Kittle's role as a pass catcher should be intensified early on with WR Brandon Aiyuk (ACL) on the PUP list to begin the campaign and Jauan Jennings (calf, contract) uncertain to suit up against the Seahawks. Kittle is coming off a 78-catch, 1,106-yard, eight-TD 2024 campaign, further cementing his place as one of the NFL's elite producers at tight end. The Seahawks were middle-of-the-pack against the position last year, giving up an average of 51.5 receiving yards per game.",
        "2": "George Kittle won't play in San Francisco's Week 2 matchup against New Orleans due to a hamstring injury that landed him on IR. Luke Farrell and Jake Tonges, who caught a TD in Kittle's absence last week against the Seahawks, will be asked to step in at tight end for the 49ers.",
        "3": "George Kittle will miss his second straight game for the 49ers in Week 3 against the Cardinals while he remains on IR due to a hamstring injury. Jake Tonges and Luke Farrell should continue to hold down the fort at TE for Kittle until the latter is able to return. Kittle won't be eligible to suit up again until Week 6."
       },
       "weekly_projections": {
        "5": 12.7,
        "6": 13.1,
        "7": 13.4,
        "8": 11.7,
        "10": 14.6,
        "12": 11.6,
        "13": 13.2,
        "14": 13.4,
        "15": 14.1,
        "16": 14.1,
        "17": 14.5
       },
       "weekly_stats": {
        "1": {
         "fantasy_points": 12.5,
         "opponent": "SEA",
         "team": "SF",
         "updated_at": "2025-10-15T17:40:58.625370"
        },
        "2": {
         "fantasy_points": 12.5,
         "opponent": "NO",
         "team": "SF",
         "updated_at": "2025-09-16T17:08:05.179797"
        },
        "3": {
         "fantasy_points": 12.5,
         "opponent": "ARI",
         "team": "SF",
         "updated_at": "2025-09-23T15:00:13.907272"
        },
        "4": {
         "fantasy_points": 12.5,
         "opponent": "JAX",
         "team": "SF",
         "updated_at": "2025-09-30T15:00:14.035733"
        },
        "5": {
         "fantasy_points": 12.5,
         "opponent": "LAR",
         "team": "SF",
         "updated_at": "2025-10-07T15:00:13.665217"
        },
        "6": {
         "fantasy_points": 12.5,
         "opponent": "TB",
         "team": "SF",
         "updated_at": "2025-10-14T15:00:14.748804"
        }
       }
      }
     },
     "updated_at": "2025-10-22T18:11:05.039158"
    }

    I hope to continue to refine this so that it can be used for future seasons. Then we can continue to use the bot into 2026’s season.

    Anyway, hopefully I can figure out MCP and the knowledgebase this week. Winter is coming so its time to hunker down and build AWS Architectures!

  • Using Strands to build an AWS Cost Analysis Agent

    Taking a break from Fantasy Football today to talk about a quick weekend project I put together.

    A friend of mine was chatting about how their AWS costs are getting out of control and they aren’t sure where to start when it comes to cleaning up the account. This prompted me with an idea to utilize AI to build an Agent that can interact with your AWS account to review resources, provide cost analysis and give you clear CLI commands or console instructions to help clean up the account.

    In order to do this, I wanted to incur as little cost as possible. So, I built a Docker image in order to run it locally. First, there is a shell script that will build an IAM User in your account that provides read-only access to the account, Cost Explorer access and access to Bedrock (to communicate with an AI model).

    The Docker image runs and builds an Agent that interacts with whichever model you want to utilize. I picked Amazon’s Nova model just to keep the costs down. The container then presents a web interface where the account’s bill break down will be displayed:

    It will also display some common costly resources and their counts:

    The next block is where things get very helpful. The AI will present to you suggestions as to how to save some money as well as some risk calculations. Because I ran this against my real account I had to blur out some information but you get the idea:

    So, now you have some actionable activities to work through to help you save money on your AWS bill. But what if you have more questions? I also included a simple chat box to help you work with the bot to come up with other explanations or find other ways to save cost.

    So I asked the AI to find the largest instance in my account and then determine the right size for it. Here is the response:

    Why would this be important? Well, if you had the AI review all of the instances in your account you could identify EC2 instances that are oversized and have them be changed accordingly. After I implemented a few of the changes that the AI recommended (and verified they didn’t break anything), my account billing decreased by about $100.

    If this is something you are interested in running on your own account feel free to reach out! I’d be happy to help you setup up the container on your machine and make suggestions as to how to save some money!

  • Week 2 – Fantasy Football and AI

    Week 2 – Fantasy Football and AI

    After a heartbreaking (lol) loss in week one, our agent is back with its picks for week two!

    But, before we start talking about rosters and picks and how I think AI is going to lose week two, let’s talk about the overall architecture of the application.

    Current Architecture diagram

    You may notice that after my post on Tuesday I have substantially reduced the data storage. I’m now using three DynamoDB tables to handle everything.

    1. Current Roster – This table is populated by an automated scraper that pulls the rosters for all the teams in the league.
    2. Player Data Table – This table populates all the historical data from the draft as well as projected stats for the 2025 season. It also holds the actual points received after the week has completed.
    3. Waiver Table – this is probably the most notable addition to the overall Agent. This table is populated by both ESPN and FantasyPros

    The waiver wire functionality is a massive addition to the Agent. It now has the ability to know what players are available for me to add to the team. If we combine that with the player stats in the Player Data Table we can get a clear picture as to how the player MIGHT preform on a week to week basis.

    The waiver table is populated by a lambda function that goes out and scrapes the ESPN Fantasy Platform. It is quite involved code as there is no API for ESPN. I’m still not sure why they don’t build one. It seems like an easy win for them especially as they get into more sports gambling. You can read the code here. This Lambda function runs on a CRON every day so that the Agent always has daily updated data.

    The other major addition is a web interface. I realized that accessing this via a terminal is great but, it would be way more interesting to have something to look at. Especially if I am away from the computer.

    The web interface consists of a display of the roster:

    Roster Screenshot

    There are a couple things I need to fix. You’ll notice that a few players “have points” this is a problem with the data in the Player Data Table from when I was merging all the sources. Ideally, this will display the points the player has received for the week. Eventually I would like to add some live streaming of the point totals.

    Bench Players

    It also displays the bench (notice the same data glitch). On my list of things to do is to make these boxes drag and drop and auto update the roster table so that we can move players around. I also want to add their projections to each block so I can see the projected points per week for each player.

    The BEST part (in my opinion) is the prediction functionality. There is a box that we can choose which week to get a prediction for and then it will return output from the agent.

    So, let’s take a look at week two!

    Optimal Week 2 Lineup

    Here is a screenshot of the week two optimal lineup. This is the lineup I will be starting for week two unless one of my tight-ends becomes healthy. With George Kittle on injured reserve and Evan Engram also questionable, the AI suggested picking up Hunter Henry.

    The Agent will also provide up with some waiver targets as well as matchup analysis

    It will also output the full response for each week. Here is the full text of what the Agent has predicted for week two:

    LINEUP OPTIMIZATION FOR WEEK 2

    Starting Lineup Strategy:
    – Josh Allen (QB): Elite QB1 with 38.8 points in Week 1, facing NYJ defense that allowed significant passing yards. His 2024 average of 31.85 and strong 2025 projection make him a must-start.
    – Josh Jacobs (RB1): Top projected RB at 18.4 points, facing Washington at home. Green Bay’s new offensive system should benefit Jacobs significantly.
    – Saquon Barkley (RB2): Projected 18.1 points against Kansas City. His 2024 average of 15.93 and strong 2025 projection of 273.2 season points make him a core play.
    – DK Metcalf (WR1): Highest projected WR at 14.3 points. Pittsburgh vs Seattle should be a competitive game with passing volume.
    – Marvin Harrison Jr. (WR2): Rookie with 14.2 projection facing Carolina. His 154.5 season projection suggests breakout potential.
    – Hunter Henry (TE): Best available TE option at 9.3 projected points with Kittle on IR and Engram questionable.
    – DJ Moore (FLEX): Solid 13.9 projection against Detroit. Chicago’s passing game should see volume in what could be a high-scoring affair.
    – Breece Hall (OP): Critical OP selection at 14.9 projected points. Hall offers RB1 upside against Buffalo, and using an RB in the OP slot provides higher floor than WR options.

    CRITICAL WAIVER WIRE TARGETS:

    Roster analysis shows no critical positional needs. Your team has excellent depth across all positions with 19 total players and strong projections.

    TOP DEFENSE WAIVER PICKUP:
    No specific waiver targets identified in the data, but consider streaming defenses based on matchups. Look for teams facing backup QBs or offenses with high turnover rates.

    INJURY CONCERNS:
    – George Kittle: On Injury Reserve, unavailable for Week 2
    – Evan Engram: Listed as Questionable, monitor his status throughout the week

    MATCHUP ANALYSIS:
    – Josh Allen vs NYJ: Excellent matchup for Allen, Jets defense struggled in Week 1
    – Jacobs vs WSH: Home game advantage for Green Bay, Washington’s run defense showed vulnerabilities
    – Barkley vs KC: High-scoring game potential, Eagles should stay competitive requiring rushing attempts
    – DK Metcalf vs SEA: Revenge game narrative, Pittsburgh’s passing attack should be featured

    BEST DEFENSE MATCHUPS

    Detroit DST faces Chicago at home, which presents a solid matchup. Other potential streaming options to consider:
    – Teams facing rookie QBs or backup quarterbacks
    – Defenses at home against struggling offensive lines
    – Units facing teams with high turnover rates from Week 1

    WAIVER PRIORITY:
    1. Streaming Defense: Look for defenses with favorable Week 3 matchups
    2. Handcuff RBs: Target backup RBs for your elite runners (Jacobs, Barkley, Hall)
    3. High-Upside WRs: Monitor snap counts and target shares from Week 2 for emerging receivers

    Final Comments:
    Your roster is exceptionally deep and well-constructed. The OP position selection of Breece Hall provides excellent upside, as RBs typically offer higher floors than WRs in flex positions. Focus on matchup-based streaming for defense and monitor the waiver wire for breakout players rather than addressing positional needs. Your core lineup projects for strong Week 2 performance with multiple players having 15+ point upside.

    What’s Next?

    So we have a pretty solid week two prediction. Josh Allen and Saquon Barkley I have faith in. The rest of the team is hit or miss. Chicago faces Detroit at Ford Field (Go Lions!) and both teams lost week one. But Ben Johnson facing his old team for the first time has me nervous.

    This brings up a few of my to-dos for the overall program.

    1. Defensive matchups – I need to get data for the Defenses to find the best matchups week to week. Having a good defense play is an easy way to get an advantage every week.
    2. Add authentication – I added a really simple authentication method to the code just for the time being. But, it would be nice to have a Single Sign On or something a little bit more secure.
    3. Drag-n-drop interface – I need to add functionality to be able to modify the roster on the web interface. It would be nice if this could also update ESPN.
    4. Slow Output – I’m always looking for ways to optimize the Agent’s output. Currently it takes about 45 seconds to a minute to return the output.

    Thoughts? I hope this series is entertaining. If you have ideas for the Agent please comment below or shoot me a message somewhere!