How arjunhg/anonymous-guard works
Project type and purpose
• This is a full-stack web application built with Next.js 14 (App Router) and TypeScript.
• Purpose: AnonGuard is an anonymous crime reporting platform with AI-powered image/incident analysis, a user-facing reporting UI, and an admin dashboard for authorities.
File structure
• Top-level “app” directory holds both UI pages and backend API routes under app/api.
• UI routes: page.tsx in app/, app/auth, app/submit-report, app/track-report, app/dashboard.
• API routes: app/api/analyze-image, app/api/reports, app/api/auth, etc.
• “components” holds reusable React components (Navbar, ReportForm, ReportWizard, ReportTracker).
• “lib” contains shared utilities: auth wrappers, Prisma client, helper functions.
• Prisma folder holds database schema and migration files.
• Config files: next.config.mjs, tsconfig.json, tailwind.config.ts, postcss.config.mjs.
• Middleware.ts applies global logic (e.g., auth, redirect).
README for additional insights
• Tech stack: Next.js, TypeScript, Prisma ORM, PostgreSQL (Neon), Google Gemini API, NextAuth.js, Framer Motion, Tailwind CSS, Vercel for hosting.
• Features: anonymous reporting, AI analysis, geolocation, emergency categories, admin dashboard, report tracking.
Main components & interactions
a. Components
• Client Browser (React UI via Next.js pages/components)
• Next.js Server (SSR/SSG, App Router handling UI requests)
• API Layer (Next.js serverless functions under app/api)
– Auth service (NextAuth.js)
– Report service (CRUD for reports via Prisma)
– Image analysis service (calls Google Gemini API)
• Database (PostgreSQL via Prisma ORM)
• External AI API (Google Gemini)
• Deployment Platform (Vercel)
b. Relationships and data flow
• Browser ⇄ Next.js Server: page requests, SSR/SSG, client-side navigation
• Browser → API Layer: POST/GET for report submission, tracking, auth
• API Layer → Database: Prisma client queries for storing/fetching reports, users
• API Layer → Google Gemini: image/incident analysis calls
• NextAuth (under API Layer) → Database: user/session storage
c. Architectural patterns & design principles
• Separation of concerns: UI components vs. API routes
• Serverless microservices style (each route directory is a discrete function)
• ORM abstraction (Prisma) for database operations
• Environment-driven configuration for secrets and URLs
d. Key technologies
• Next.js App Router + Server Components
• React + TypeScript + Tailwind CSS + Framer Motion for UI
• NextAuth.js for authentication
• Prisma + PostgreSQL for persistence
• Google Gemini API for AI analysis
• Vercel as host and function runner
Detailed capture of essential elements
• Don’t just group “Backend” – break out auth, reports, analysis.
• Explicitly call out Prisma as the ORM layer between API and DB.
• Environment variables for secrets and URLs (e.g., NEXTAUTH_URL, GEMINI_API_KEY).
• If desired, annotate deployment boundaries: “Serverless on Vercel” vs. “Client in Browser”.