How killercavin/brightside works
Project type and purpose
• BrightSide Stores is a full-stack e-commerce/storefront application.
• The frontend is a Next.js/React SPA with server-side rendering and theming.
• The backend is a Ktor (Kotlin) REST API exposing endpoints for products, categories, and cart.
• A relational database (e.g. PostgreSQL) stores domain data.
File structure
• Top-level directories:
– backend/: Ktor application with configs, controllers, services, models, routes, tests
– frontend/: Next.js app with pages, components, theming, public assets
• Backend patterns: layered architecture (Routing → Controllers → Services → Data/Models)
• Key config files: application.yaml, EnvConfig, DatabaseFactory, Serialization, Security
• Frontend patterns: app/layout + page.tsx, reusable components (Header, Footer, Hero), ThemeProvider
• Build tools: Gradle wrapper for backend, pnpm workspace for frontend
README for additional insights
• README simply names the project, but code and file names imply standard e-commerce operations:
– Product listing & management
– Category management
– Cart operations
Main components and interactions
a. Client & Browser
– Users interact via browser, triggering SSR or API calls
b. Frontend (Next.js)
– Pages (layout.tsx, page.tsx) render UI, import ThemeProvider, Header, Footer, Hero
– Fetches data from backend REST endpoints (/api/products, /api/categories, /api/cart)
c. Backend (Ktor REST API)
– Routing layer (CartRoutes, ProductRoutes, CategoryRoutes)
– Controllers (CartController, ProductController, CategoryController) handle HTTP requests
– Services encapsulate business logic (CartService, ProductService, CategoryService)
– Data layer: Exposed ORM tables (ProductTable, CategoryTable) + Models → Database
– Config modules: DatabaseFactory (connection pool), Serialization (JSON), Security (auth), EnvConfig
d. Database
– Relational store for products, categories, cart entries
e. External and support services
– Logging (logback)
– Environment variables (.env via EnvConfig)
– Static assets served by Next.js from public/assets
Architectural patterns & design principles
• Layered service architecture in backend (separate web, service, data layers)
• Modular routing grouping per resource (products, categories, cart)
• Next.js SSR/SSG for SEO + React component composition + theming
• Configuration by code (Kotlin config classes) and YAML for environment
• Dependency injection via constructor parameters in services/controllers
Essential elements
• Clear labels on all components (e.g., “ProductService”, “CategoryController”)