A modern web application for booking services built with Astro, React, and MongoDB.
- Language: TypeScript
- Package Manager: pnpm
- Framework: Astro with React integration
- Database: MongoDB
- Authentication: Better Auth
- Styling: Tailwind CSS v4
- UI Components: HeroUI
- Code Quality: Biome
- State Management: Nanostores
- Forms: React Hook Form
- Deployment: Netlify
Before you begin, ensure you have the following installed on your machine:
- Node.js (version 18 or higher)
- pnpm (latest version)
- MongoDB database access (local or cloud)
You have several options for MongoDB:
- MongoDB Compass (Recommended for beginners): Download MongoDB Compass for a user-friendly GUI
- MongoDB Shell: Download MongoDB Shell for command-line interaction
- Atlas CLI: Download Atlas CLI for cloud database management
git clone <repository-url>
cd lf-v2
pnpm installCreate a .env file in the root directory. Use the following template based on the sample file:
# Application Configuration
APP_ENV="local"
PUBLIC_APP_URL="http://127.0.0.1:4321"
# Database Configuration
DATABASE_NAME="flamboyants"
DATABASE_HOST="your/database/url"
DATABASE_USERNAME="your_database_username"
DATABASE_PASSWORD="your_database_password"
# Authentication
BETTER_AUTH_SECRET="your_auth_secret"
BETTER_AUTH_URL="http://127.0.0.1:4321"
# Email Configuration (for password reset)
MAILER_API_KEY="your_mailer_api_key"
MAILER_FORGOT_PASSWORD_URL="your_mailer_service_url"Important Environment Variables:
DATABASE_NAME: Name of your MongoDB databaseBETTER_AUTH_SECRET: A secure random string for authenticationBETTER_AUTH_URL: Base URL for auth callbacks (should match your app URL)
pnpm devThe application will be available at http://localhost:4321
lf-v2/
βββ src/
β βββ actions/ # Server actions
β βββ assets/ # Static assets (images, icons)
β βββ components/ # React components
β β βββ auth/ # Authentication components
β β βββ booking/ # Booking-related components
β β βββ contact/ # Contact form components
β β βββ index/ # Homepage components
β β βββ product/ # Product components
β β βββ shared/ # Reusable components
β β βββ user-profil/ # User profile components
β βββ data/ # Static data and constants
β βββ db/ # Database utilities and repository
β βββ layouts/ # Astro layout components
β βββ lib/ # Authentication configuration
β βββ pages/ # Astro pages (routes)
β β βββ api/ # API endpoints
β βββ sdk/ # SDK utilities
β βββ services/ # Business logic services
β βββ store/ # State management
β βββ styles/ # Global styles
β βββ types/ # TypeScript type definitions
β βββ utils/ # Utility functions
β βββ content.config.ts # Content collections configuration
β βββ env.d.ts # Environment type definitions
β βββ middleware.ts # Astro middleware
βββ public/ # Public static files
βββ astro.config.mjs # Astro configuration
βββ biome.jsonc # Biome configuration
βββ package.json # Project dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ tailwind.config.js # Tailwind CSS configuration
# Development
pnpm dev # Start development server
# Building
pnpm build # Build for production
pnpm preview # Preview production build locally
# Code Quality
pnpm check # Check code with Biome (lint + format)
pnpm format # Format code with Biome
# Utility
pnpm astro # Run Astro CLI commands- User registration and login
- Password reset functionality
- Session management with Better Auth
- Protected routes middleware
- MongoDB with custom repository pattern
- Type-safe database operations
- Connection handling for development and production
- RESTful API endpoints under
/api/ - Authentication endpoints
- Product and booking management
- Contact form handling
- Modular React components
- Shared components for reusability
- Feature-specific component organization
The project uses TypeScript path mapping for cleaner imports:
@components/* β src/components/*
@assets/* β src/assets/*
@layouts/* β src/layouts/*
@data/* β src/data/*
@utils β src/utils/mod.ts
@sdk β src/sdk/fetcher.ts
@db β src/db/mod.ts
@better-auth β src/lib/mod.ts
@store β src/store/mod.ts
@services β src/services/mod.ts
@types β src/types/mod.tsThe project uses Biome for code formatting and linting. Run checks before committing:
pnpm check # Check for issues
pnpm format # Auto-fix formatting issuesHusky is configured to run code quality checks before commits.
Use the Mongo class from @db for all database operations:
import { Mongo } from "@db";
// Get documents
const users = await Mongo.getDocumentsFrom({
db: "flamboyants",
collection: "users"
});
// Insert document
await Mongo.postDocumentTo({
db: "flamboyants",
collection: "users",
data: userData
});Authentication is handled through Better Auth:
import { auth } from "@better-auth-server";
// In API routes
const session = await auth.api.getSession({
headers: request.headers
});The application is configured for deployment on Netlify:
- Build the project:
pnpm build - The build output will be in the
dist/directory - Netlify configuration is in
netlify.toml
Ensure all environment variables are properly set in your deployment environment, particularly:
- Database credentials
- Authentication secrets
- Email service configuration
- Follow the established code style (enforced by Biome)
- Use conventional commit messages
- Test your changes thoroughly
- Update documentation when adding new features
- Astro Documentation
- Better Auth Documentation
- MongoDB Node.js Driver
- HeroUI Components
- Tailwind CSS v4
-
Database Connection Failed
- Check your MongoDB connection string
- Ensure MongoDB service is running
- Verify network access for cloud databases
-
Authentication Not Working
- Verify
BETTER_AUTH_SECRETis set - Check
BETTER_AUTH_URLmatches your app URL - Ensure session cookies are properly configured
- Verify
-
Build Errors
- Run
pnpm checkto identify code issues - Ensure all environment variables are set
- Clear node_modules and reinstall if necessary
- Run
For additional help, check the error logs and ensure all dependencies are properly installed.