Commit Graph

14 Commits

Author SHA1 Message Date
Dylan Knutson
8745583990 Add configuration and database setup
- Updated Cargo.toml with necessary dependencies
- Enhanced config.rs with database and application configuration
- Updated main.rs with improved bot initialization
- Added development database file
2025-08-28 01:28:31 +00:00
Dylan Knutson
af1f3271a3 chore: update rstest dependency from 0.21 to 0.26.1
- Update rstest version for better test parametrization support
- Update corresponding Cargo.lock
2025-08-28 01:19:41 +00:00
Dylan Knutson
5212175df5 refactor: organize type definitions into dedicated db/types/ directory
- Move type files to src/db/types/: currency_type, listing_id, user_id, money_amount, telegram_user_id
- Create types/mod.rs with proper re-exports for all type modules
- Update db/mod.rs to import from new types module instead of individual files
- All tests pass - no functionality changes
- Improves code organization by clearly separating types, DAOs, and models
2025-08-28 01:17:45 +00:00
Dylan Knutson
3a7d0a6905 refactor: organize DAOs into dedicated db/dao/ directory
- Move listing_dao.rs and user_dao.rs to src/db/dao/
- Create dao/mod.rs with proper re-exports for ListingDAO and UserDAO
- Update import paths in DAO files to work from new location
- Update db/mod.rs to import from new dao module
- All tests still pass - no functionality changes
2025-08-28 01:15:40 +00:00
Dylan Knutson
7a16c5859b feat: add epsilon-based timestamp comparison macros for tests 2025-08-28 01:05:16 +00:00
Dylan Knutson
fc1a61ff32 feat: implement type-safe ID system and enum-based listing architecture
- Add UserId and ListingId newtype wrappers with SQLx integration
  - Prevents mixing up different ID types at compile time
  - Custom Encode/Decode traits for seamless database operations
  - Zero-cost abstractions with full type safety

- Refactor Listing to enum-based architecture
  - BasicAuction: Traditional time-based auction with bidding
  - MultiSlotAuction: Auction with multiple winners/slots
  - FixedPriceListing: Fixed price sale with no bidding
  - BlindAuction: Blind auction where seller chooses winner
  - ListingBase: Common fields shared by all listing types
  - ListingRow: Flat database row structure for SQLx compatibility

- Update ListingType enum variants
  - Standard -> BasicAuction
  - MultiSlot -> MultiSlotAuction
  - FixedPrice -> FixedPriceListing
  - Blind -> BlindAuction

- Add comprehensive conversion traits and helper methods
- Maintain full database compatibility with existing schema
- Remove unused helper methods and make base() private for cleaner API
2025-08-27 23:38:10 +00:00
Dylan Knutson
eca570c887 chore: Remove dead code - delete obsolete money.rs file
- Remove src/db/money.rs which contained the old Decimal-based MoneyAmount implementation
- This file was leftover from the INTEGER cents refactoring and was not referenced in mod.rs
- Only money_amount.rs with INTEGER storage is now active
- Compilation confirmed successful after removal
2025-08-27 23:24:44 +00:00
Dylan Knutson
0eaab7c743 refactor: Modularize database models into separate files
- Break down monolithic src/db/models.rs into focused model files
- Create src/db/models/ directory with individual files:
  - listing_type.rs - ListingType enum and variants
  - user.rs - User struct and NewUser helper
  - listing.rs - Listing struct and NewListing helper
  - bid.rs - Bid struct and NewBid helper
  - proxy_bid.rs - ProxyBid struct and NewProxyBid helper
  - listing_media.rs - ListingMedia for file attachments
  - user_settings.rs - UserSettings for user preferences
  - mod.rs - Re-exports all models for seamless access
- Remove old monolithic models.rs file
- Maintain backward compatibility through re-exports

Benefits:
- Improved code organization and maintainability
- Better separation of concerns for each model
- Easier navigation and IDE support
- Reduced merge conflicts in team development
- Scalable foundation for adding new models
2025-08-27 23:23:16 +00:00
Dylan Knutson
32dca5f4de refactor: Convert MoneyAmount to INTEGER cents storage and modularize currency types
- Refactor MoneyAmount to store as INTEGER cents instead of TEXT decimals
- Move CurrencyType to separate currency_type.rs module
- Rename money.rs to money_amount.rs for clarity
- Update database schema to use INTEGER for all monetary columns
- Remove complex CAST AS REAL workarounds from database queries
- Add comprehensive test coverage for cent-based arithmetic and storage
- Enable STRICT mode and foreign key constraints in SQLite
- Add rstest dependency for parameterized testing

Benefits:
- Faster INTEGER-based comparisons vs TEXT casting
- Exact financial precision without floating-point errors
- Simpler, cleaner SQL queries
- Better performance for auction bid operations
2025-08-27 23:19:13 +00:00
Dylan Knutson
348fa416e8 feat: implement database layer and rename auction -> listing
Major Changes:
- Set up SQLx database connection and migration system
- Create complete initial database schema with all tables
- Rename 'auction' to 'listing' throughout codebase for better terminology
- Update bot commands: /newauction -> /newlisting, /myauctions -> /mylistings
- Update all database tables: auctions -> listings, auction_medias -> listing_medias
- Update foreign key relationships and indexes
- Add automatic database migration on startup
- Update documentation and README
- Complete backlog tasks: task-001, task-002, task-010

The bot now has a solid database foundation ready for implementing core business logic.
All tests pass and code compiles successfully.
2025-08-27 19:24:15 +00:00
Dylan Knutson
30751181e4 add .env.example, user-stories.md 2025-08-27 19:12:40 +00:00
Dylan Knutson
947092ce54 add README.md 2025-08-27 02:57:14 +00:00
Dylan Knutson
b5f15f9d3e add .cursorrules with backlog.md description 2025-08-27 02:42:23 +00:00
Dylan Knutson
caebe567df initial commit 2025-08-26 22:39:40 -04:00