How sohelshekhin/thesoulspace-frontend works
Main Components
• Frontend Pages: The “app” directory holds all the page components for different sections such as:
• Homepage (app/page.tsx)
• Shop (app/shop and subfolders)
• Checkout (app/checkout and subdirectories like address, payment)
• User Account (app/account)
• Custom Design Orders (app/custom-design)
• Standard static pages (about, contact, more/ policies)
• Authentication pages (login, register)
• Error and not-found pages
• API Endpoints: Under “app/api”, you have endpoints for:
• Authentication (app/api/auth/[...nextauth])
• Health checks (app/api/health)
• Order processing (app/api/orders/neworder)
• React Components: The “components” directory breaks down common UI pieces into:
• Authentication forms (Login, Register, CheckoutAuthForm)
• Checkout components (steps, forms for shipping/contact and payment details)
• Navbar, Footer, and global UI components, ensuring style and usability consistency
• Shop-specific components (product items, cart summaries, offers, autocomplete)
• HomePage sections (Hero banner, Popular Categories, Testimonial, etc.)
• Context and Utilities: The “context” directory provides global state management (StateContext.tsx), while “utils” and “types” offer shared functions, cookies management, and type definitions to standardize interactions.
Relationships and Interactions
• The “app” directory defines the routing mechanism. Each route corresponds to a view or API endpoint. For example, the shop pages fetch data and interact with the API endpoints to handle orders.
• Components are used across pages to render shared UI elements (e.g., Navbar and Footer appear on multiple pages; forms are embedded in login and checkout).
• The API routes act as serverless functions that encapsulate business logic (authentication processes, health checks, new order creation) and are called by frontend pages or components.
• The Context provider (in components/Global/Provider.tsx) wraps parts of the application ensuring that state (like the cart or user authentication status) is maintained across pages.
Architectural Patterns and Design Principles
• File-based Routing: Next.js automatically maps files to routes which simplifies navigation.
• Component-Based UI: The project’s division into individual component folders (HomePage, Navbar, Shop, etc.) follows the principle of reusable UI components.
• Separation of Concerns: The clear division between pages, API endpoints, and components helps to maintain a modular architecture.
• Context and Utility Layers: Using a global state and utility functions/interfaces abstracts common logic away from individual components.
• Next.js Features: The project leverages Next.js capabilities such as server-side rendering, API Routes (for authentication and orders), and static file serving (in the “public” folder).
• The Routing layer (represented by the “app” directory) with different entry points (Home, Shop, Account, Checkout, etc.).
• The API layer (depicted also as routes beneath “app/api”) and note which URLs relate to authentication, health, and order management.
• Finally, include supportive artifacts like public assets and utilities (from “utils” and “types”) on the side, indicating that they provide essential, cross-cutting functionality.