listenForNotifications' notification-forwarding goroutine sent on ch unconditionally after each WaitForNotification. If ProcessEvents' main loop had already exited (ctx cancelled) at the exact moment this goroutine had a notification to forward, nobody was left reading from the unbuffered channel - the send blocked forever, the goroutine never reached its deferred pc.Release(), and the pooled connection leaked permanently. Real in production (a shutdown racing an in-flight NOTIFY), not just a test artifact. Surfaced by a go test ./... hang inside domains/amazon (a goroutine stuck in pgxpool.Pool.Close's WaitGroup.Wait) - increased cross-package NOTIFY traffic from domains/reports' Amazon-platform fixtures made the race easy to hit, but didn't cause it. Fixed with a select alongside the send so the goroutine notices ctx.Done() instead of blocking forever when nobody's listening anymore. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XEDaCB7C2NEBgyvqEtZuxY
WIP!
This is an application intended to ease the process of managing multiple online stores. The benefits provided by this application will be to automatically manage shared inventory between stores, reducing the amount of time needed to synchronize inventory between stores.
Deploying
The application runs locally, from this directory. It is deployed simply by running either from the root of the project,
make run
or
go run .
Development
Testing
There's a Makefile with a number of operations for running and testing the application
Technology
Languages
Server side
Golang, Go Templates,
Front end
HTML, CSS, Javascript
Databases
Postgres, in docker
Management
Using migrate to manage build out the database schema, and to run migrations.
Tooling
Server side
- github.com/angelbeltran/templater: for wiring up template directories for serving over the web and improving the task of composing template together.
- go templates: generating html declaratively from the server.
- github.com/jackc/pgx/v5: for postgres db interfacing
Front end
- htmx: for strong hypermedia support
- hyperscript: for minimal, inline scripting, with strong integration with htmx
- tailwind: for styling the front end, using tried and testing styling paradigms, conventions, and templates.
Roadmap
- Etsy (WIP)
- GET ETSY AUTH (WIP)
- move auth state stuff to database (out of cache)
- only generate a sign up link IF they click the link on the accounts page
- get api key approved
- automatically clean up access tokens and state when expired
- access tokens
- state
- [?] Get new access token using refresh token flow
- make a FK between the etsy_store_events table and etsy_users table (store_id columns don't match types)
- GET ETSY AUTH (WIP)
- Auth0
- get off dev api key?
- Get new access token using refresh token flow
- test
- when token is expired, redirect them to the login page, then redirect them back to where they were heading to.
- Social connections login
- automatically clean up access tokens and state when expired
- access tokens
- state
- Complete this design document?
- Complete defining this roadmap checklist
- Website displaying an audit of store events
- Start with just a list of events for a given store (use a static test store)
- ...
- Dark mode
- don't let a listing be in multiple sync groups
- Next stores on the list (at least hypothetically)
- Shopify
- WooCommerce
- BigCommerce
- Wix
- Squarespace
- Square Online
- Zoho
- Ecwid
- Big Cartel
Bigger marketplaces:
- Amazon
- Walmart Marketplace
- Ebay
Nice to haves
- Drop in a good logger
- log all errors caught by the http server
Constraints
- Etsy
- API Licensed Uses and Restrictions:
- Link directly back to the product information and/or image Content on Etsy, where the Application utilizes product information and/or images.
- Provide a prominently displayed email address on Your Application for third parties to contact You with any questions or issues. You shall respond to such inquiries in a timely manner.
- Use commercially reasonable efforts to provide a terms of service and privacy policy in a visible location on your Application.
- Display item Content or product information and/or images which is more than six (6) hours older than such information is on the Website, and other Etsy Content cannot be more than twenty-four (24) hours older than such Content on the Website.
- Use the API in a manner that exceeds reasonable request volume or constitutes excessive or abusive usage. Users are allocated by default, 10,000 calls per day.
- You shall not use or alter any text, logos, Etsy's Trademarks, Etsy's signature colors, Etsy's layout, or a confusingly similar layout to Etsy's layout in such a way which may suggest endorsement or affiliation by Etsy.
- Any use of the Etsy logo or Etsy's Trademarks must be used in its entirety and must not be altered or used in a misleading way.
- You shall not use a mark which is confusingly similar to Etsy's Trademarks.
- Any use of the Etsy logo or Etsy's Trademarks in Your Application shall be less prominent than the logo or mark that primarily describes the Application and Your use of the Etsy logo shall not imply any endorsement or affiliation by Etsy.
- You may publicize, issue press or blog releases of Your Application only if You state that it was created using the Etsy API and that You in no way imply that Your Application is endorsed or certified by Etsy.
- You must place or display the following notice prominently on Your Application: "The term 'Etsy' is a trademark of Etsy, Inc. This application uses the Etsy API but is not endorsed or certified by Etsy, Inc."
- Immediately report any security deficiencies You discover to Etsy by emailing developer@etsy.com.
- API Licensed Uses and Restrictions:
Looking to follow the CQRS pattern.
The database will follow the event sourcing database pattern. All events (or commands) will be stored in a respective event series, and all database reads will be from views that are projections, reductions, aggregations of those event series.
Application/directory structure
- /internal
- /site: website
- /webhooks: webhooks for platform events
- /domains: packages for each domain
- /store_events: storing and events
- /platforms: ecommerce platform domains
- /tiktok: interface with tiktok
- ... etc
- ... etc
Website hierarchy
- /site
Architectural and Software Diagrams
Database schemas
Events
Event Sourcing Architecture
Event Structure
Store Event Database Tables
Platform: Etsy
Signing up
TODO: need an account page that can create accounts ahead of time - force users to create an account first!
TODO: create a page that will take billing information and include it in this process
Getting a new refresh token
TODO
Models
All Diagrams
All diagrams are stored in the diagrams directory