APP

Documentation

Developer Guide

Architecture Overview

AutoTechJobs follows a modern web application architecture built on Remix v2 and Cloudflare's edge platform. The architecture emphasizes performance, security, and developer experience.

Core Application Flow

  1. Entry Points:
    • entry.client.tsx: Handles client-side hydration using React 18's hydrateRoot
    • entry.server.tsx: Manages server-side rendering with streaming support
    • root.tsx: Defines the application shell with common layout elements
  2. Data Layer:
    • Repository Pattern: Each domain entity has a dedicated repository
    • Base Repository: Provides common CRUD operations
    • D1 Integration: Uses Cloudflare D1 for data persistence
  3. Service Layer:
    • Authentication: Handles user registration, login, and session management
    • Email Service: Manages email templates and delivery via Resend
    • Geocoding: Provides location-based services for job matching

Architectural Patterns

Repository Pattern

The application uses the repository pattern to abstract data access logic:

// Base repository with common CRUD operations
export class BaseRepository<T> {
  constructor(protected tableName: string, protected db: D1Database) {}
  
  async findById(id: string): Promise<T | null> {
    // Implementation
  }
  
  async create(data: Partial<T>): Promise<T> {
    // Implementation
  }
  
  // Other common methods
}

Service Layer

Services encapsulate business logic and orchestrate operations across repositories:

export class AuthService {
  constructor(
    private userRepository: UserRepository,
    private sessionStorage: SessionStorage
  ) {}
  
  async validateCredentials(email: string, password: string): Promise<User> {
    // Validation logic
  }
  
  async createSession(request: Request, user: User): Promise<Session> {
    // Session creation logic
  }
}

Remix v2 Data Flow

The application follows Remix v2 patterns for data loading and mutations:

import type { LoaderFunctionArgs } from '@remix-run/cloudflare';
import { json } from '@remix-run/cloudflare';
import { useLoaderData } from '@remix-run/react';

export const loader = async ({ request, context }: LoaderFunctionArgs) => {
  const { env } = context.cloudflare;
  // Data loading logic using repositories
  return json({ data });
};

export default function RouteComponent() {
  const { data } = useLoaderData<typeof loader>();
  // Component rendering
}

Infrastructure Architecture

Cloudflare Edge Platform

The application leverages Cloudflare's edge infrastructure:

Cloudflare Pages
  • Hosts the Remix application
  • Provides global CDN distribution
  • Automatic deployments from Git
Cloudflare D1
  • SQLite-compatible database
  • Distributed at the edge
  • Automatic replication
Cloudflare KV
  • Used for session storage
  • Caching frequently accessed data
  • Global key-value store
Cloudflare Workers
  • Background processing
  • Email delivery service
  • Scheduled tasks