How billyledev/astro-hapijs-starter works
Main Components
• Frontend: Represented by the "packages/front" directory, this component uses Astro for static page generation, Vue for interactive components, and Tailwind CSS for theming. It manages user interfaces like sign-in, sign-up, landing pages, contact forms, and more.
• Backend API: Represented by the "packages/api" directory, the API is built on HapiJS. Key files include the server entry point (src/server.ts), plugins (e.g., betterAuthPlugin, captchaPlugin, contactPlugin, mailerPlugin), and utility functions for tasks like mailing.
• Authentication & Security: Highlight the usage of BetterAuth for managing authentication and Altcha for captcha integration. These are integrated into the backend via dedicated plugins.
• Email Service: The API has an "emails" folder containing HTML/text templates for contact and welcome emails, along with mailer utilities. External SMTP (e.g., MailHog for testing) is used to deliver emails.
Component Interactions
• External Services: Include the SMTP server (like MailHog) as an external service interacting with the backend’s mailer utility.
Architectural Patterns and Design Principles
• Modular Architecture: The separation of the project into two main packages ("api" and "front") indicates a modular design, fostering separation of concerns.
• Plugin-based Extensions: The backend uses plugins to add functionality (better authentication, captcha, email), showcasing an extensible system design.
• TypeScript: Both components use TypeScript, ensuring consistency and type safety across the codebase.
• API-First Design: The clear division suggests an API-first approach where the frontend interacts with the backend solely via defined endpoints.