How modamaan/hackathon works
1. Overall shape
- This is a Next.js App Router application written in TypeScript. The repo is organized as a single full-stack web app with UI, client-side interactive components, and server-side API routes in the same codebase.
2. Primary user-facing routes
- app/page.tsx is the landing page.
- app/diagnose/page.tsx is the main workflow page.
- app/history/page.tsx shows prior activity or past diagnoses.
- app/layout.tsx and app/globals.css define the shared shell, styling, and top-level composition for all pages.
3. Core workflow boundary
- The application center of gravity appears to be the diagnosis flow: users provide inputs, the app processes them through API endpoints, and results are displayed back in the client.
- The main client-side orchestration lives in components/diagnose-client.tsx, which likely coordinates input capture, submission, and rendering of results.
4. Input capture subsystem
- components/voice-recorder.tsx handles audio capture.
- components/leaf-uploader.tsx handles image/file input.
- components/location-picker.tsx handles location selection.
- Together these suggest the diagnosis request can combine voice, image, and location context before sending to the backend.
5. Server API layer
- app/api/transcribe/route.ts is the audio-processing entry point, likely converting recorded speech into text.
- app/api/analyze/route.ts is the main inference/analysis endpoint that consumes user-provided inputs and returns diagnosis output.
- app/api/history/route.ts exposes history data for the history page and probably for persistence/readback of previous sessions.
6. Data flow through the system
- The client gathers inputs through specialized components.
- Audio is sent to /api/transcribe for transcription.
- The resulting text, along with other inputs such as uploaded leaf data and location, is sent to /api/analyze.
- Results are rendered in components/results-panel.tsx.
- Historical records are retrieved through /api/history and shown in the history page.
7. State, auth, and backend boundary
- components/auth-provider.tsx indicates authentication state is managed on the client side and shared across the app.
- lib/firebase.ts and lib/firebase-admin.ts show a split between client Firebase usage and server-side admin access.
- This usually means authenticated client interactions are paired with privileged server operations for reading/writing protected data.
8. Likely persistence and external services
- The presence of Firebase client/admin libraries strongly suggests Firebase is the main external platform for authentication and/or data storage.
- The history endpoint and auth provider imply user-scoped records are persisted and later queried, with server-admin code handling trusted access.
9. Shared UI component layer
- components/ui/* contains reusable presentational primitives such as buttons, cards, tabs, badges, progress, skeletons, and sonner/toast UI.
- These are likely a design-system layer used across the landing, diagnosis, and history pages to keep styling consistent.
10. Page composition and navigation
- components/navbar.tsx provides cross-page navigation and likely user/session-aware controls.
- app/diagnose/page.tsx and app/history/page.tsx are thin page shells that assemble the reusable client components rather than containing most business logic themselves.
11. Shared utilities and types
- lib/types.ts defines domain shapes used across client and server boundaries.
- lib/utils.ts and lib/button-variants.ts support shared formatting, class handling, and component styling concerns.
- These files reduce duplication between route handlers and React components.
12. Implementation constraints that matter architecturally
- The repo is designed around the App Router split: server route handlers under app/api and client interactions under components.
- Because there are separate Firebase client/admin modules, the architecture likely enforces a trust boundary between browser code and privileged server code.
- Styling and UI are centralized, but the business flow is concentrated in the diagnosis pipeline and history retrieval.
Main entry points: diagnose-client.tsx Diagnose Client · layout.tsx App Shell · page.tsx History Page · route.ts Analyze API
Components 21
App Router
Pages and server API routes
- Landing · Entry page for the app
app/page.tsx - Diagnose Page · Main workflow page shell
app/diagnose/page.tsx - History Page · Past activity and diagnoses
app/history/page.tsx - App Shell · Shared top-level layout
app/layout.tsx - Global Styles · App-wide CSS
app/globals.css - Transcribe API · Speech-to-text entry point
app/api/transcribe/route.ts - Analyze API · Main diagnosis inference endpoint
app/api/analyze/route.ts - History API · Fetches stored diagnosis history
app/api/history/route.ts
Client Flow
Interactive diagnosis UI and page composition
- Navbar · Cross-page navigation and session-aware chrome
components/navbar.tsx - Auth Provider · Shared authentication state
components/auth-provider.tsx - Diagnose Client · Coordinates input capture and analysis flow
components/diagnose-client.tsx - Voice Recorder · Audio capture and recording
components/voice-recorder.tsx - Leaf Uploader · Image or file upload input
components/leaf-uploader.tsx - Location Picker · Location/context selection
components/location-picker.tsx - Results Panel · Renders analysis results
components/results-panel.tsx
UI Primitives
Reusable presentation components
- UI Primitives · Reusable component set
Shared Lib
Cross-cutting utilities and Firebase boundary
- Firebase Client · Browser-side Firebase access
lib/firebase.ts - Firebase Admin · Privileged server-side Firebase access
lib/firebase-admin.ts - Shared Types · Domain shapes used across client and server
lib/types.ts - Utils · Shared utility helpers
lib/utils.ts - Button Variants · Variant definitions for buttons
lib/button-variants.ts
Connections 28
- Landing → App Shell: wrapped by · Landing page uses shared shell
- Diagnose Page → App Shell: wrapped by · Diagnose page uses shared shell
- History Page → App Shell: wrapped by · History page uses shared shell
- App Shell → Navbar: includes · Global navigation chrome
- App Shell → Auth Provider: provides · Shares session state across pages
- App Shell → Global Styles: applies · Global styling foundation
- Navbar → UI Primitives: uses · Navigation built from shared primitives
- Diagnose Page → Diagnose Client: mounts · Page delegates workflow to client orchestrator
- History Page → History API: loads · History page fetches stored records
- Diagnose Client → Voice Recorder: captures · Collects audio input
- Diagnose Client → Leaf Uploader: captures · Collects image/file input
- Diagnose Client → Location Picker: captures · Collects location context
- Diagnose Client → Transcribe API: calls · Sends audio for transcription
- Diagnose Client → Analyze API: calls · Submits combined diagnosis inputs
- Diagnose Client → Results Panel: renders · Displays analysis output
- Transcribe API → Firebase Admin: may use · Trusted server-side access boundary
- Analyze API → Firebase Admin: may use · Trusted server-side access boundary
- History API → Firebase Admin: uses · Reads persisted history via admin access
- Auth Provider → Firebase Client: uses · Client authentication and app state
- History API → Shared Types: shares · Structured history records
- Analyze API → Shared Types: shares · Analysis request/response shapes
- Diagnose Client → Shared Types: uses · Client-side workflow data contracts
- UI Primitives → Utils: supported by · Shared helper utilities
- UI Primitives → Button Variants: uses · Variant styling source
- Results Panel → UI Primitives: uses · Built from reusable UI primitives
- Diagnose Client → UI Primitives: uses · Workflow UI composed from shared primitives
- Landing → UI Primitives: uses · Landing page uses shared primitives
- History Page → UI Primitives: uses · History page uses shared primitives