├── .npmrc ├── .prettierignore ├── static └── favicon.png ├── src ├── lib │ ├── index.ts │ ├── components │ │ └── ui │ │ │ ├── separator │ │ │ ├── index.ts │ │ │ └── separator.svelte │ │ │ ├── card │ │ │ ├── card-content.svelte │ │ │ ├── card-footer.svelte │ │ │ ├── card-header.svelte │ │ │ ├── card-description.svelte │ │ │ ├── card.svelte │ │ │ ├── card-title.svelte │ │ │ └── index.ts │ │ │ ├── alert │ │ │ ├── alert-description.svelte │ │ │ ├── alert.svelte │ │ │ ├── alert-title.svelte │ │ │ └── index.ts │ │ │ ├── drawer │ │ │ ├── drawer.svelte │ │ │ ├── drawer-footer.svelte │ │ │ ├── drawer-nested.svelte │ │ │ ├── drawer-overlay.svelte │ │ │ ├── drawer-description.svelte │ │ │ ├── drawer-header.svelte │ │ │ ├── drawer-title.svelte │ │ │ ├── drawer-content.svelte │ │ │ └── index.ts │ │ │ ├── button │ │ │ ├── button.svelte │ │ │ └── index.ts │ │ │ └── input │ │ │ ├── index.ts │ │ │ └── input.svelte │ └── utils.ts ├── routes │ ├── +layout.svelte │ ├── api │ │ └── alert │ │ │ └── +server.ts │ └── +page.svelte ├── app.d.ts ├── app.html └── app.css ├── postcss.config.js ├── .env.example ├── vite.config.ts ├── tailwind.config.ts ├── .gitignore ├── .prettierrc ├── components.json ├── tsconfig.json ├── svelte.config.js ├── eslint.config.js ├── package.json ├── tailwind.config.js ├── README.md └── LICENSE /.npmrc: -------------------------------------------------------------------------------- 1 | engine-strict=true 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # Package Managers 2 | package-lock.json 3 | pnpm-lock.yaml 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/face-hh/lawmaxxing/HEAD/static/favicon.png -------------------------------------------------------------------------------- /src/lib/index.ts: -------------------------------------------------------------------------------- 1 | // place files you want to import through the `$lib` alias in this folder. 2 | -------------------------------------------------------------------------------- /src/routes/+layout.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {} 5 | } 6 | }; 7 | -------------------------------------------------------------------------------- /src/lib/components/ui/separator/index.ts: -------------------------------------------------------------------------------- 1 | import Root from "./separator.svelte"; 2 | 3 | export { 4 | Root, 5 | // 6 | Root as Separator, 7 | }; 8 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | RECEIVER_PHONE_NUMBER=+1234567890 2 | 3 | TWILIO_PHONE_NUMBER=+1234567890 4 | TWILIO_ACCOUNT_SID=fkeagjhAOEghaoeghAIOHG 5 | TWILIO_AUTH_TOKEN=GoieAJGOAEJgoaejOGjAEOgj -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { sveltekit } from '@sveltejs/kit/vite'; 2 | import { defineConfig } from 'vite'; 3 | 4 | export default defineConfig({ 5 | plugins: [sveltekit()] 6 | }); 7 | -------------------------------------------------------------------------------- /tailwind.config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from 'tailwindcss'; 2 | 3 | export default { 4 | content: ['./src/**/*.{html,js,svelte,ts}'], 5 | 6 | theme: { 7 | extend: {} 8 | }, 9 | 10 | plugins: [] 11 | } as Config; 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | # Output 4 | .output 5 | .vercel 6 | /.svelte-kit 7 | /build 8 | 9 | # OS 10 | .DS_Store 11 | Thumbs.db 12 | 13 | # Env 14 | .env 15 | .env.* 16 | !.env.example 17 | !.env.test 18 | 19 | # Vite 20 | vite.config.js.timestamp-* 21 | vite.config.ts.timestamp-* 22 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "useTabs": true, 3 | "singleQuote": true, 4 | "trailingComma": "none", 5 | "printWidth": 100, 6 | "plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"], 7 | "overrides": [ 8 | { 9 | "files": "*.svelte", 10 | "options": { 11 | "parser": "svelte" 12 | } 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /src/app.d.ts: -------------------------------------------------------------------------------- 1 | // See https://kit.svelte.dev/docs/types#app 2 | // for information about these interfaces 3 | declare global { 4 | namespace App { 5 | // interface Error {} 6 | // interface Locals {} 7 | // interface PageData {} 8 | // interface PageState {} 9 | // interface Platform {} 10 | } 11 | } 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://shadcn-svelte.com/schema.json", 3 | "style": "default", 4 | "tailwind": { 5 | "config": "tailwind.config.js", 6 | "css": "src/app.css", 7 | "baseColor": "gray" 8 | }, 9 | "aliases": { 10 | "components": "$lib/components", 11 | "utils": "$lib/utils" 12 | }, 13 | "typescript": true 14 | } -------------------------------------------------------------------------------- /src/app.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %sveltekit.head% 8 | 9 | 10 |
%sveltekit.body%
11 | 12 | 13 | -------------------------------------------------------------------------------- /src/lib/components/ui/card/card-content.svelte: -------------------------------------------------------------------------------- 1 | 10 | 11 |
12 | 13 |
14 | -------------------------------------------------------------------------------- /src/lib/components/ui/card/card-footer.svelte: -------------------------------------------------------------------------------- 1 | 10 | 11 |
12 | 13 |
14 | -------------------------------------------------------------------------------- /src/lib/components/ui/card/card-header.svelte: -------------------------------------------------------------------------------- 1 | 10 | 11 |
12 | 13 |
14 | -------------------------------------------------------------------------------- /src/lib/components/ui/alert/alert-description.svelte: -------------------------------------------------------------------------------- 1 | 10 | 11 |
12 | 13 |
14 | -------------------------------------------------------------------------------- /src/lib/components/ui/card/card-description.svelte: -------------------------------------------------------------------------------- 1 | 10 | 11 |

12 | 13 |

14 | -------------------------------------------------------------------------------- /src/lib/components/ui/card/card.svelte: -------------------------------------------------------------------------------- 1 | 10 | 11 |
15 | 16 |
17 | -------------------------------------------------------------------------------- /src/lib/components/ui/drawer/drawer.svelte: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/lib/components/ui/drawer/drawer-footer.svelte: -------------------------------------------------------------------------------- 1 | 13 | 14 |
15 | 16 |
17 | -------------------------------------------------------------------------------- /src/lib/components/ui/drawer/drawer-nested.svelte: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/lib/components/ui/drawer/drawer-overlay.svelte: -------------------------------------------------------------------------------- 1 | 11 | 12 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/lib/components/ui/drawer/drawer-description.svelte: -------------------------------------------------------------------------------- 1 | 11 | 12 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/lib/components/ui/drawer/drawer-header.svelte: -------------------------------------------------------------------------------- 1 | 12 | 13 |
18 | 19 |
20 | -------------------------------------------------------------------------------- /src/lib/components/ui/drawer/drawer-title.svelte: -------------------------------------------------------------------------------- 1 | 11 | 12 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/lib/components/ui/alert/alert.svelte: -------------------------------------------------------------------------------- 1 | 14 | 15 | 18 | -------------------------------------------------------------------------------- /src/lib/components/ui/card/card-title.svelte: -------------------------------------------------------------------------------- 1 | 14 | 15 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/lib/components/ui/alert/alert-title.svelte: -------------------------------------------------------------------------------- 1 | 14 | 15 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/lib/components/ui/card/index.ts: -------------------------------------------------------------------------------- 1 | import Root from "./card.svelte"; 2 | import Content from "./card-content.svelte"; 3 | import Description from "./card-description.svelte"; 4 | import Footer from "./card-footer.svelte"; 5 | import Header from "./card-header.svelte"; 6 | import Title from "./card-title.svelte"; 7 | 8 | export { 9 | Root, 10 | Content, 11 | Description, 12 | Footer, 13 | Header, 14 | Title, 15 | // 16 | Root as Card, 17 | Content as CardContent, 18 | Description as CardDescription, 19 | Footer as CardFooter, 20 | Header as CardHeader, 21 | Title as CardTitle, 22 | }; 23 | 24 | export type HeadingLevel = "h1" | "h2" | "h3" | "h4" | "h5" | "h6"; 25 | -------------------------------------------------------------------------------- /src/lib/components/ui/separator/separator.svelte: -------------------------------------------------------------------------------- 1 | 12 | 13 | 23 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json", 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "checkJs": true, 6 | "esModuleInterop": true, 7 | "forceConsistentCasingInFileNames": true, 8 | "resolveJsonModule": true, 9 | "skipLibCheck": true, 10 | "sourceMap": true, 11 | "strict": true, 12 | "moduleResolution": "bundler" 13 | } 14 | // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias 15 | // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files 16 | // 17 | // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes 18 | // from the referenced tsconfig.json - TypeScript does not merge them in 19 | } 20 | -------------------------------------------------------------------------------- /svelte.config.js: -------------------------------------------------------------------------------- 1 | import adapter from '@sveltejs/adapter-auto'; 2 | import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | // Consult https://kit.svelte.dev/docs/integrations#preprocessors 7 | // for more information about preprocessors 8 | preprocess: vitePreprocess(), 9 | 10 | kit: { 11 | // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. 12 | // If your environment is not supported, or you settled on a specific environment, switch out the adapter. 13 | // See https://kit.svelte.dev/docs/adapters for more information about adapters. 14 | adapter: adapter() 15 | } 16 | }; 17 | 18 | export default config; 19 | -------------------------------------------------------------------------------- /eslint.config.js: -------------------------------------------------------------------------------- 1 | import eslint from '@eslint/js'; 2 | import prettier from 'eslint-config-prettier'; 3 | import svelte from 'eslint-plugin-svelte'; 4 | import globals from 'globals'; 5 | import tseslint from 'typescript-eslint'; 6 | 7 | export default tseslint.config( 8 | eslint.configs.recommended, 9 | ...tseslint.configs.recommended, 10 | ...svelte.configs['flat/recommended'], 11 | prettier, 12 | ...svelte.configs['flat/prettier'], 13 | { 14 | languageOptions: { 15 | globals: { 16 | ...globals.browser, 17 | ...globals.node 18 | } 19 | } 20 | }, 21 | { 22 | files: ['**/*.svelte'], 23 | languageOptions: { 24 | parserOptions: { 25 | parser: tseslint.parser 26 | } 27 | } 28 | }, 29 | { 30 | ignores: ['build/', '.svelte-kit/', 'dist/'] 31 | } 32 | ); 33 | -------------------------------------------------------------------------------- /src/lib/components/ui/button/button.svelte: -------------------------------------------------------------------------------- 1 | 15 | 16 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/lib/components/ui/drawer/drawer-content.svelte: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 | 14 | 21 |
22 | 23 |
24 |
25 | -------------------------------------------------------------------------------- /src/lib/components/ui/input/index.ts: -------------------------------------------------------------------------------- 1 | import Root from "./input.svelte"; 2 | 3 | export type FormInputEvent = T & { 4 | currentTarget: EventTarget & HTMLInputElement; 5 | }; 6 | export type InputEvents = { 7 | blur: FormInputEvent; 8 | change: FormInputEvent; 9 | click: FormInputEvent; 10 | focus: FormInputEvent; 11 | focusin: FormInputEvent; 12 | focusout: FormInputEvent; 13 | keydown: FormInputEvent; 14 | keypress: FormInputEvent; 15 | keyup: FormInputEvent; 16 | mouseover: FormInputEvent; 17 | mouseenter: FormInputEvent; 18 | mouseleave: FormInputEvent; 19 | mousemove: FormInputEvent; 20 | paste: FormInputEvent; 21 | input: FormInputEvent; 22 | wheel: FormInputEvent; 23 | }; 24 | 25 | export { 26 | Root, 27 | // 28 | Root as Input, 29 | }; 30 | -------------------------------------------------------------------------------- /src/lib/components/ui/alert/index.ts: -------------------------------------------------------------------------------- 1 | import { type VariantProps, tv } from "tailwind-variants"; 2 | 3 | import Root from "./alert.svelte"; 4 | import Description from "./alert-description.svelte"; 5 | import Title from "./alert-title.svelte"; 6 | 7 | export const alertVariants = tv({ 8 | base: "[&>svg]:text-foreground relative w-full rounded-lg border p-4 [&:has(svg)]:pl-11 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4", 9 | 10 | variants: { 11 | variant: { 12 | default: "bg-background text-foreground", 13 | destructive: 14 | "border-destructive/50 text-destructive text-destructive dark:border-destructive [&>svg]:text-destructive", 15 | }, 16 | }, 17 | defaultVariants: { 18 | variant: "default", 19 | }, 20 | }); 21 | 22 | export type Variant = VariantProps["variant"]; 23 | export type HeadingLevel = "h1" | "h2" | "h3" | "h4" | "h5" | "h6"; 24 | 25 | export { 26 | Root, 27 | Description, 28 | Title, 29 | // 30 | Root as Alert, 31 | Description as AlertDescription, 32 | Title as AlertTitle, 33 | }; 34 | -------------------------------------------------------------------------------- /src/lib/components/ui/drawer/index.ts: -------------------------------------------------------------------------------- 1 | import { Drawer as DrawerPrimitive } from "vaul-svelte"; 2 | 3 | import Root from "./drawer.svelte"; 4 | import Content from "./drawer-content.svelte"; 5 | import Description from "./drawer-description.svelte"; 6 | import Overlay from "./drawer-overlay.svelte"; 7 | import Footer from "./drawer-footer.svelte"; 8 | import Header from "./drawer-header.svelte"; 9 | import Title from "./drawer-title.svelte"; 10 | import NestedRoot from "./drawer-nested.svelte"; 11 | 12 | const Trigger = DrawerPrimitive.Trigger; 13 | const Portal = DrawerPrimitive.Portal; 14 | const Close = DrawerPrimitive.Close; 15 | 16 | export { 17 | Root, 18 | NestedRoot, 19 | Content, 20 | Description, 21 | Overlay, 22 | Footer, 23 | Header, 24 | Title, 25 | Trigger, 26 | Portal, 27 | Close, 28 | 29 | // 30 | Root as Drawer, 31 | NestedRoot as DrawerNestedRoot, 32 | Content as DrawerContent, 33 | Description as DrawerDescription, 34 | Overlay as DrawerOverlay, 35 | Footer as DrawerFooter, 36 | Header as DrawerHeader, 37 | Title as DrawerTitle, 38 | Trigger as DrawerTrigger, 39 | Portal as DrawerPortal, 40 | Close as DrawerClose, 41 | }; 42 | -------------------------------------------------------------------------------- /src/lib/components/ui/input/input.svelte: -------------------------------------------------------------------------------- 1 | 17 | 18 | 43 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "lawmaxxing", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "dev": "vite dev", 7 | "build": "vite build", 8 | "preview": "vite preview", 9 | "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json", 10 | "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch", 11 | "lint": "prettier --check . && eslint .", 12 | "format": "prettier --write ." 13 | }, 14 | "devDependencies": { 15 | "@sveltejs/adapter-auto": "^3.2.5", 16 | "@sveltejs/kit": "^2.0.0", 17 | "@sveltejs/vite-plugin-svelte": "^3.0.0", 18 | "@types/eslint": "^9.6.0", 19 | "autoprefixer": "^10.4.20", 20 | "bits-ui": "^0.21.16", 21 | "eslint": "^9.0.0", 22 | "eslint-config-prettier": "^9.1.0", 23 | "eslint-plugin-svelte": "^2.36.0", 24 | "globals": "^15.0.0", 25 | "prettier": "^3.1.1", 26 | "prettier-plugin-svelte": "^3.1.2", 27 | "prettier-plugin-tailwindcss": "^0.6.5", 28 | "shadcn-svelte": "^0.13.0", 29 | "svelte": "^4.2.7", 30 | "svelte-check": "^4.0.0", 31 | "tailwindcss": "^3.4.9", 32 | "typescript": "^5.0.0", 33 | "typescript-eslint": "^8.0.0", 34 | "vite": "^5.0.3" 35 | }, 36 | "type": "module", 37 | "dependencies": { 38 | "@mapbox/mapbox-gl-directions": "^4.3.1", 39 | "clsx": "^2.1.1", 40 | "dotenv": "^16.4.5", 41 | "lucide-svelte": "^0.452.0", 42 | "mapbox-gl": "^3.7.0", 43 | "tailwind-merge": "^2.5.3", 44 | "tailwind-variants": "^0.2.1", 45 | "twilio": "^5.3.4", 46 | "vaul-svelte": "^0.3.2" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/routes/api/alert/+server.ts: -------------------------------------------------------------------------------- 1 | import { json } from '@sveltejs/kit'; 2 | import twilio from 'twilio'; 3 | import dotenv from 'dotenv'; 4 | 5 | dotenv.config(); 6 | 7 | // Initialize Twilio client 8 | const accountSid = process.env.TWILIO_ACCOUNT_SID!; 9 | const authToken = process.env.TWILIO_AUTH_TOKEN!; 10 | const client = twilio(accountSid, authToken); 11 | 12 | // In-memory storage for the last sent message timestamp 13 | let lastMessageTimestamp: number | null = null; 14 | const ONE_MINUTE = 10 * 1000; // 10 sec in milliseconds 15 | 16 | export async function POST({ request }) { 17 | const { street, coordinates, speed } = await request.json(); 18 | 19 | const currentTime = Date.now(); 20 | 21 | // Check if 1 minute has passed since the last message 22 | if (lastMessageTimestamp && currentTime - lastMessageTimestamp < ONE_MINUTE) { 23 | return json({ error: 'You must wait 1 minute between SMS messages' }, { status: 429 }); 24 | } 25 | 26 | try { 27 | const message = await client.messages.create({ 28 | body: `An individual is currently speeding on street "${street}", coordinates: ${coordinates} at ${speed}km/h.`, 29 | from: process.env.TWILIO_PHONE_NUMBER!, 30 | to: process.env.RECEIVER_PHONE_NUMBER!, 31 | }); 32 | 33 | // Update the last message timestamp 34 | lastMessageTimestamp = currentTime; 35 | 36 | return json({ message: 'SMS sent successfully', response: message }); 37 | } catch (error) { 38 | console.error('Error sending SMS:', error); 39 | return json({ error: 'Failed to send SMS' }, { status: 500 }); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/lib/components/ui/button/index.ts: -------------------------------------------------------------------------------- 1 | import { type VariantProps, tv } from "tailwind-variants"; 2 | import type { Button as ButtonPrimitive } from "bits-ui"; 3 | import Root from "./button.svelte"; 4 | 5 | const buttonVariants = tv({ 6 | base: "ring-offset-background focus-visible:ring-ring inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", 7 | variants: { 8 | variant: { 9 | default: "bg-primary text-primary-foreground hover:bg-primary/90", 10 | destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90", 11 | outline: 12 | "border-input bg-background hover:bg-accent hover:text-accent-foreground border", 13 | secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80", 14 | ghost: "hover:bg-accent hover:text-accent-foreground", 15 | link: "text-primary underline-offset-4 hover:underline", 16 | }, 17 | size: { 18 | default: "h-10 px-4 py-2", 19 | sm: "h-9 rounded-md px-3", 20 | lg: "h-11 rounded-md px-8", 21 | icon: "h-10 w-10", 22 | }, 23 | }, 24 | defaultVariants: { 25 | variant: "default", 26 | size: "default", 27 | }, 28 | }); 29 | 30 | type Variant = VariantProps["variant"]; 31 | type Size = VariantProps["size"]; 32 | 33 | type Props = ButtonPrimitive.Props & { 34 | variant?: Variant; 35 | size?: Size; 36 | }; 37 | 38 | type Events = ButtonPrimitive.Events; 39 | 40 | export { 41 | Root, 42 | type Props, 43 | type Events, 44 | // 45 | Root as Button, 46 | type Props as ButtonProps, 47 | type Events as ButtonEvents, 48 | buttonVariants, 49 | }; 50 | -------------------------------------------------------------------------------- /src/lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { type ClassValue, clsx } from "clsx"; 2 | import { twMerge } from "tailwind-merge"; 3 | import { cubicOut } from "svelte/easing"; 4 | import type { TransitionConfig } from "svelte/transition"; 5 | 6 | export function cn(...inputs: ClassValue[]) { 7 | return twMerge(clsx(inputs)); 8 | } 9 | 10 | type FlyAndScaleParams = { 11 | y?: number; 12 | x?: number; 13 | start?: number; 14 | duration?: number; 15 | }; 16 | 17 | export const flyAndScale = ( 18 | node: Element, 19 | params: FlyAndScaleParams = { y: -8, x: 0, start: 0.95, duration: 150 } 20 | ): TransitionConfig => { 21 | const style = getComputedStyle(node); 22 | const transform = style.transform === "none" ? "" : style.transform; 23 | 24 | const scaleConversion = ( 25 | valueA: number, 26 | scaleA: [number, number], 27 | scaleB: [number, number] 28 | ) => { 29 | const [minA, maxA] = scaleA; 30 | const [minB, maxB] = scaleB; 31 | 32 | const percentage = (valueA - minA) / (maxA - minA); 33 | const valueB = percentage * (maxB - minB) + minB; 34 | 35 | return valueB; 36 | }; 37 | 38 | const styleToString = ( 39 | style: Record 40 | ): string => { 41 | return Object.keys(style).reduce((str, key) => { 42 | if (style[key] === undefined) return str; 43 | return str + `${key}:${style[key]};`; 44 | }, ""); 45 | }; 46 | 47 | return { 48 | duration: params.duration ?? 200, 49 | delay: 0, 50 | css: (t) => { 51 | const y = scaleConversion(t, [0, 1], [params.y ?? 5, 0]); 52 | const x = scaleConversion(t, [0, 1], [params.x ?? 0, 0]); 53 | const scale = scaleConversion(t, [0, 1], [params.start ?? 0.95, 1]); 54 | 55 | return styleToString({ 56 | transform: `${transform} translate3d(${x}px, ${y}px, 0) scale(${scale})`, 57 | opacity: t 58 | }); 59 | }, 60 | easing: cubicOut 61 | }; 62 | }; -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | import { fontFamily } from "tailwindcss/defaultTheme"; 2 | 3 | /** @type {import('tailwindcss').Config} */ 4 | const config = { 5 | darkMode: ["class"], 6 | content: ["./src/**/*.{html,js,svelte,ts}"], 7 | safelist: ["dark"], 8 | theme: { 9 | container: { 10 | center: true, 11 | padding: "2rem", 12 | screens: { 13 | "2xl": "1400px" 14 | } 15 | }, 16 | extend: { 17 | colors: { 18 | border: "hsl(var(--border) / )", 19 | input: "hsl(var(--input) / )", 20 | ring: "hsl(var(--ring) / )", 21 | background: "hsl(var(--background) / )", 22 | foreground: "hsl(var(--foreground) / )", 23 | primary: { 24 | DEFAULT: "hsl(var(--primary) / )", 25 | foreground: "hsl(var(--primary-foreground) / )" 26 | }, 27 | secondary: { 28 | DEFAULT: "hsl(var(--secondary) / )", 29 | foreground: "hsl(var(--secondary-foreground) / )" 30 | }, 31 | destructive: { 32 | DEFAULT: "hsl(var(--destructive) / )", 33 | foreground: "hsl(var(--destructive-foreground) / )" 34 | }, 35 | muted: { 36 | DEFAULT: "hsl(var(--muted) / )", 37 | foreground: "hsl(var(--muted-foreground) / )" 38 | }, 39 | accent: { 40 | DEFAULT: "hsl(var(--accent) / )", 41 | foreground: "hsl(var(--accent-foreground) / )" 42 | }, 43 | popover: { 44 | DEFAULT: "hsl(var(--popover) / )", 45 | foreground: "hsl(var(--popover-foreground) / )" 46 | }, 47 | card: { 48 | DEFAULT: "hsl(var(--card) / )", 49 | foreground: "hsl(var(--card-foreground) / )" 50 | } 51 | }, 52 | borderRadius: { 53 | lg: "var(--radius)", 54 | md: "calc(var(--radius) - 2px)", 55 | sm: "calc(var(--radius) - 4px)" 56 | }, 57 | fontFamily: { 58 | sans: [...fontFamily.sans] 59 | } 60 | } 61 | }, 62 | }; 63 | 64 | export default config; 65 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Lawmaxxing 2 | 3 | A self-hosted web application that demonstrates speed monitoring capabilities using maps. This is a proof-of-concept project meant for **educational purposes only**. 4 | 5 | 6 | 7 | ## Legal Disclaimer 8 | 9 | THIS SOFTWARE IS PROVIDED FOR EDUCATIONAL AND ENTERTAINMENT PURPOSES ONLY. 10 | 11 | - This application is not intended to be used as a law enforcement tool or legitimate speed monitoring system 12 | - Any SMS messages sent by this application are purely demonstrative 13 | - The creators and contributors assume no liability for any misuse of this software 14 | - This is not a substitute for actual law enforcement or emergency services 15 | - If you witness actual traffic violations or emergencies, contact your local authorities through appropriate channels 16 | 17 | ## Setup 18 | 19 | 1. Prerequisites: 20 | - [Node.js](https://nodejs.org/en) 21 | - A [Mapbox](https://www.mapbox.com/) account for map functionality 22 | - A [Twilio](https://www.twilio.com/en-us) account for SMS capabilities 23 | 24 | 2. Environment Variables: 25 | Create a `.env` file in the root directory with the following: 26 | ```python 27 | RECEIVER_PHONE_NUMBER=your_phone_number 28 | TWILIO_PHONE_NUMBER=your_twilio_number 29 | TWILIO_ACCOUNT_SID=your_twilio_sid 30 | TWILIO_AUTH_TOKEN=your_twilio_token 31 | ``` 32 | 33 | 3. Mapbox Configuration: 34 | - Obtain a Mapbox access token from [Mapbox](https://www.mapbox.com/) 35 | - Replace `REPLACE_ME__BUDDY` in `src/routes/+page.svelte` with your Mapbox token 36 | 37 | 4. And we're almost done! 38 | ```bash 39 | npm install 40 | npm run dev 41 | ``` 42 | 5. If you want to use it on your 📱 phone: 43 | - Easiest way would be to host it on [Vercel](https://vercel.com) (**NOT AFFILIATED**). 44 | - then open the site on your phone (i.e. `https://gpeaoihganebo.vercel.app`). 45 | 46 | ## Configuration details 47 | - `RECEIVER_PHONE_NUMBER`: The phone number that will receive SMS notifications. Make sure it starts with the receiver's country code, i.e. `+1xxxxx` for the US. 48 | - `TWILIO_PHONE_NUMBER`: Your Twilio-provided phone number for sending SMS. 49 | - `TWILIO_ACCOUNT_SID`: Your Twilio account SID. 50 | - `TWILIO_AUTH_TOKEN`: Your Twilio authentication token. 51 | 52 | ## Contributing 53 | This is an educational project that has reached a stable state. While you're welcome to fork and modify the codebase for your own learning purposes, please note that this repository is in maintenance mode. New feature requests or pull requests are unlikely to be reviewed or merged, as the project is intended to remain in its current form. 54 | 55 | ## License 56 | Apache 2.0 57 | 58 | --- 59 | Remember: This is a demonstration project. Always follow local laws and regulations regarding traffic monitoring and reporting. 60 | 61 | Developed by [FaceDev](https://youtube.com/c/FaceDevStuff). 62 | -------------------------------------------------------------------------------- /src/app.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss/base'; 2 | @import 'tailwindcss/components'; 3 | @import 'tailwindcss/utilities'; 4 | @tailwind base; 5 | @tailwind components; 6 | @tailwind utilities; 7 | 8 | @layer base { 9 | :root { 10 | --background: 0 0% 100%; 11 | --foreground: 224 71.4% 4.1%; 12 | 13 | --muted: 220 14.3% 95.9%; 14 | --muted-foreground: 220 8.9% 46.1%; 15 | 16 | --popover: 0 0% 100%; 17 | --popover-foreground: 224 71.4% 4.1%; 18 | 19 | --card: 0 0% 100%; 20 | --card-foreground: 224 71.4% 4.1%; 21 | 22 | --border: 220 13% 91%; 23 | --input: 220 13% 91%; 24 | 25 | --primary: 220.9 39.3% 11%; 26 | --primary-foreground: 210 20% 98%; 27 | 28 | --secondary: 220 14.3% 95.9%; 29 | --secondary-foreground: 220.9 39.3% 11%; 30 | 31 | --accent: 220 14.3% 95.9%; 32 | --accent-foreground: 220.9 39.3% 11%; 33 | 34 | --destructive: 0 72.2% 50.6%; 35 | --destructive-foreground: 210 20% 98%; 36 | 37 | --ring: 224 71.4% 4.1%; 38 | 39 | --radius: 0.5rem; 40 | } 41 | 42 | .dark { 43 | --background: 224 71.4% 4.1%; 44 | --foreground: 210 20% 98%; 45 | 46 | --muted: 215 27.9% 16.9%; 47 | --muted-foreground: 217.9 10.6% 64.9%; 48 | 49 | --popover: 224 71.4% 4.1%; 50 | --popover-foreground: 210 20% 98%; 51 | 52 | --card: 224 71.4% 4.1%; 53 | --card-foreground: 210 20% 98%; 54 | 55 | --border: 215 27.9% 16.9%; 56 | --input: 215 27.9% 16.9%; 57 | 58 | --primary: 210 20% 98%; 59 | --primary-foreground: 220.9 39.3% 11%; 60 | 61 | --secondary: 215 27.9% 16.9%; 62 | --secondary-foreground: 210 20% 98%; 63 | 64 | --accent: 215 27.9% 16.9%; 65 | --accent-foreground: 210 20% 98%; 66 | 67 | --destructive: 0 62.8% 30.6%; 68 | --destructive-foreground: 210 20% 98%; 69 | 70 | --ring: 216 12.2% 83.9%; 71 | } 72 | } 73 | 74 | @layer base { 75 | * { 76 | @apply border-border; 77 | } 78 | body { 79 | @apply bg-background text-foreground; 80 | } 81 | } 82 | 83 | .mapbox-directions-origin label { 84 | background-color: hsl(var(--primary)) !important; 85 | border-top-left-radius: 12px !important; 86 | } 87 | 88 | .mapbox-directions-destination label { 89 | background-color: hsl(var(--primary)) !important; 90 | border-bottom-left-radius: 12px !important; 91 | } 92 | 93 | .mapboxgl-ctrl-top-left > div > div > div > div:first-child { 94 | border-radius: 12px !important; 95 | } 96 | 97 | #mapbox-directions-origin-input > div { 98 | border-top-right-radius: 12px; 99 | } 100 | 101 | #mapbox-directions-destination-input > div { 102 | border-bottom-right-radius: 12px; 103 | } 104 | 105 | .mapbox-directions-profile input[type=radio]:checked + label:hover, .mapbox-directions-profile input[type=radio]:checked + label { 106 | background: hsl(var(--primary)) !important; 107 | color: hsl(var(--primary-foreground)) !important; 108 | } 109 | 110 | .mapboxgl-ctrl-geocoder ul > li.active > a, .mapboxgl-ctrl-geocoder ul > li > a:hover { 111 | background: hsl(var(--primary)) !important; 112 | color: hsl(var(--primary-foreground)) !important; 113 | } 114 | 115 | .suggestions { 116 | border-radius: 12px !important; 117 | box-shadow: 0 0 0 2px rgba(0,0,0,0.1) !important; 118 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2024 FaceDev 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /src/routes/+page.svelte: -------------------------------------------------------------------------------- 1 | 321 | 322 | 323 | Mapbox iOS-style Navigation 324 | 325 | 326 |
327 |
328 | 329 |
330 | 331 | 332 | 333 |
334 | 335 | 336 | 337 |

{locationStatus}

338 |
339 |
340 | 341 | 342 | Speed Alert 343 | 344 | {#if showSpeedWarning} 345 | Highest recorded speed: 346 | {formatSpeed(averageSpeed)} 347 | 348 | Police has been NOTIFIED. 349 | {:else} 350 | You're moving at a safe speed. Keep it up! 351 | {/if} 352 | 353 | 354 | 355 | 362 | 363 | 364 | 365 |
366 | 367 |

368 | Current: {formatSpeed(currentSpeed)} | Avg: {formatSpeed(averageSpeed)} 369 |

370 |
371 |
372 | 373 | 374 | Navigation Steps 375 | 376 |
377 | {#if routeAdditionalData.distance !== null && routeAdditionalData.duration !== null} 378 |

379 | Total: {routeAdditionalData.distance} km | {routeAdditionalData.duration} min 380 |

381 | {/if} 382 |
383 | {#each routeSteps as step} 384 |
385 |
386 |

{step.label}

387 |

388 | {step.distance} km | {step.duration} min 389 |

390 |
391 |
392 | {/each} 393 |
394 |
395 |
396 |
397 |
398 | 399 | 464 | --------------------------------------------------------------------------------