Layer Dependency Model
BookWish follows a strict 4-layer dependency model to ensure proper architectural separation and maintainable feature development.
Layer Dependencies & Build Order
Layer 4: Programs (Challenges, Book Clubs)
│ depends on ▼
Layer 3: Social (Profiles, Lines, Reviews, Feed)
│ depends on ▼
Layer 2: Store Operations (POS, Inventory, Websites)
│ depends on ▼
Layer 1: Core Loop (Users, Books, Wishlists, Stores, Orders)
Layer Descriptions
Layer 1: Core Loop
The foundation of the platform - the indie commerce loop.
Key Features:
- User authentication and profiles
- Book catalog and search
- Wishlist management
- Store profiles
- Orders and checkout
- Home store selection
Core Entities:
users- User accounts (guest and registered)books- Global book catalogwishlists- User wishlist collectionswishlist_items- Books on wishlistsstores- Independent bookstore profilesorders- Order recordsorder_items- Books in ordersaddresses- Shipping/billing addresses
Dependencies: None (this is the foundation layer)
Layer 2: Store Operations
Advanced store management and operations.
Key Features:
- Inventory management (native + Square sync)
- Point of Sale (POS)
- Trade credit system
- Trade-in processing with BooksRun integration
- Store websites (Next.js at bookwish.shop)
- Shipping integration (EasyPost)
Core Entities:
inventory- Store-specific book inventorytrade_credit_accounts- Customer credit balances per storetrade_credit_transactions- Credit/debit ledgertrade_ins- Trade-in sessionstrade_in_items- Books traded in
Dependencies: Layer 1 (requires users, books, stores, orders)
Layer 3: Social
Social networking and content sharing features.
Key Features:
- Lines (short posts about books)
- Reviews and ratings
- Private notes (Scribbles)
- Following system (users + stores)
- Social feed
- Likes and engagement
Core Entities:
lines- Short posts about booksreviews- Book reviews with ratingsnotes- Private book notesfollows- User following relationshipsstore_follows- Store followinglikes- Engagement on lines and reviews
Dependencies: Layer 1 (requires users, books, stores)
Layer 4: Programs
Community-building programs and activities.
Key Features:
- Book clubs with discussions
- Reading challenges
- Club and challenge participation tracking
- Program-specific social interactions
Core Entities:
clubs- Book club definitionsclub_books- Books selected for clubsclub_members- Club membershipchallenges- Reading challengeschallenge_books- Challenge book listschallenge_participants- Challenge participation
Dependencies: Layer 1 (users, books, stores) + Layer 3 (lines for discussions)
Implementation Phases
Following the layer dependency model, implementation proceeds in phases:
Phase 1: Foundation (Layer 1)
- Database schema + migrations
- Auth (signup, login, guest, migration)
- User profiles
- Book catalog + search (Google Books integration)
- Wishlists CRUD
- Stores (basic profile)
- Home store selection
- Orders (BookWish Direct only initially)
- Stripe integration
- Flutter app shell (tabs, navigation)
- Book Info Overlay
- Wish tab + wishlist UI
- Public wishlist sharing (Next.js)
Phase 2: Social (Layer 3)
- Lines CRUD
- Reviews CRUD
- Private Notes
- Follows (users + stores)
- Share tab + feed
- Profile Overlay
- Scribbles Overlay
- Notifications (basic)
Phase 3: Store Operations (Layer 2)
- Inventory management (native)
- Square integration
- Store orders (pickup/ship)
- POS flow
- Trade credit system
- Trade-ins + BooksRun
- Store websites (Next.js)
- Shipping (EasyPost)
Phase 4: Programs (Layer 4)
- Clubs CRUD + membership
- Club discussion (Lines)
- Challenges CRUD + participation
- Challenge discussion
- Read tab UI
Phase 5: Polish
- Push notifications
- Stock alerts
- Edelweiss import
- Advanced search/filtering
- Premium tier features
- Analytics
Why This Order?
The implementation phases intentionally implement Layer 3 (Social) before completing Layer 2 (Store Operations) because:
- User Value First: Social features provide immediate value to all users, not just store owners
- Network Effects: Building the community early creates engagement and retention
- Validation: Social features validate the platform concept before heavy store investment
- Dependency Logic: Layer 3 (Social) only depends on Layer 1 (Core), so it can be built before Layer 2
- Parallel Development: Layer 2 advanced features (POS, store websites) can be developed after Layer 3 is live
The key insight is that Layer 2 and Layer 3 both depend on Layer 1, but are independent of each other. Layer 4 depends on both Layer 1 and Layer 3 (for discussions), so it comes last.
Cross-Layer Interactions
While layers should respect dependencies, some entities reference multiple layers:
Lines (Layer 3) can have optional context from:
store_id- Posted by a storeclub_id- Posted in a club (Layer 4)challenge_id- Posted in a challenge (Layer 4)
Reviews (Layer 3) can have optional context from:
club_id- Written for a club (Layer 4)challenge_id- Written for a challenge (Layer 4)
These cross-layer references are acceptable because they're optional and the higher layer (Layer 4) depends on the lower layer (Layer 3).
Summary
The 4-layer model provides:
- Clear dependencies: Each layer knows what it can use
- Predictable build order: Features are implemented in a logical sequence
- Maintainability: Changes to lower layers don't break higher layers
- Scalability: New features fit naturally into the existing structure