How adityaaryansahu/lost_and_found_system works
1. System shape
- This is a two-tier full-stack app: a React frontend in frontend/ and a FastAPI backend in app/.
- The backend is organized in classic layers: API routes → services → repositories → MongoDB, with shared infrastructure in core/.
2. Frontend boundary
- The React app is route-driven, with pages for auth, listings, item detail/upload, claims, matches, messaging, profile, settings, and personal dashboards.
- Shared UI components and CSS provide the reusable shell for chat, claim forms, filters, conversation lists, and user menus.
3. Frontend data flow
- All server communication is centralized through frontend/src/api/* service wrappers and apiClient.js.
- AuthContext holds user/session state and likely gates access to protected pages; route pages call the API wrappers rather than talking to backend endpoints directly.
4. Backend API boundary
- app/api/endpoints/ exposes the HTTP contract by domain: auth, users, items, claims, matches, messages, and search.
- app/api/router.py is the composition point that mounts these route groups into the FastAPI app.
5. Application/service layer
- app/services/ contains the business workflows: authentication, item management, claims review, matching, messaging, image handling, search, notifications, and user operations.
- This is where the app’s core rules live: claim approval, match scoring, PIN verification, and notification triggering.
6. Persistence layer
- app/repositories/ encapsulates database access for each domain object, keeping MongoDB-specific operations out of the API and service layers.
- The dump/Lost_and_Found/ folder shows the main persisted collections: users, sessions, items, images, messages, and conversations.
7. Domain model and validation
- app/models/ and app/schemas/ define the backend’s data contracts and validation shapes.
- Models cover auth, users, items, claims, images, matches, messages, and search, while schemas define the request/response payloads exposed to the frontend.
8. Core infrastructure
- app/core/ holds cross-cutting concerns: configuration, database setup, caching, security, exception types, and storage abstractions.
- This is the boundary for secrets/config loading, Mongo connection management, auth/token logic, and file storage integration.
9. External services and integrations
- The app integrates with MongoDB for persistent data, Resend for email notifications, and Cloudflare R2 for image storage.
- app/core/s3_storage.py and app/core/storage.py indicate a storage abstraction, which keeps image upload logic separate from item/claim flows.
10. Key business flows
- Item creation starts in the frontend upload/listing pages, goes through the items API, is stored in MongoDB, and may trigger image storage in R2.
- Matching and claims form the main operational loop: items are matched, users submit claims, finders review claims, and approval can lead to PIN-based handoff verification.
- Messaging is a separate coordination channel between users and is exposed through its own API and frontend chat views.
11. Search and discovery
- Search is treated as its own backend capability rather than a UI-only filter, suggesting backend filtering across item metadata and status.
- The frontend’s listing and filter components likely call the search API for server-side discovery of items.
12. Deployment and packaging
- The repo is containerized with a docker/Dockerfile, docker-compose.yml, and render.yaml, so it is meant to run as a deployed service rather than a local-only app.
- The presence of both backend and frontend build/runtime files suggests separate deployable artifacts that communicate over HTTP.
Main entry points: apiClient.js API client · services Services · endpoints HTTP endpoints · core Core infra
Components 23
Frontend
React UI and client-side state
- App shell · Bootstraps the frontend and routes into the page layer.
frontend/src/App.jsx - Auth state · Holds session and access state for the UI.
frontend/src/contexts/AuthContext.jsx - API client · Central wrapper used by frontend features to talk to the backend.
frontend/src/api/apiClient.js - Auth page · Login and sign-up flows.
frontend/src/pages/Auth.jsx - Listings · Browse and filter items.
frontend/src/pages/ItemListing.jsx - Item detail · View item details and related actions.
frontend/src/pages/ItemDetail.jsx - Upload item · Create new item reports and upload images.
frontend/src/pages/ItemUpload.jsx - My claims · Track submitted claims and their status.
frontend/src/pages/MyClaimsPage.jsx - Matches · Show candidate item/user matches.
frontend/src/pages/MatchPage.jsx - Messaging · Conversation and chat views.
frontend/src/pages/MessagingPage.jsx - Profile · User profile and account details.
frontend/src/pages/Profile.jsx - Settings · User preferences and account settings.
frontend/src/pages/Settings.jsx - Shared UI · Reusable chat, claim form, filters, conversation list, and menu widgets.
frontend/src/components
Backend
FastAPI application layers
- API router · Composes the domain route groups into the application.
app/api/router.py - HTTP endpoints · Domain route handlers for auth, users, items, claims, matches, messages, and search.
app/api/endpoints - Services · Core workflows for auth, items, claims, matching, messaging, images, search, notifications, and users.
app/services - Repositories · MongoDB-oriented persistence for domain entities.
app/repositories - Models · Backend entity definitions for auth, users, items, claims, images, matches, messages, and search.
app/models - Schemas · Request and response shapes exposed through the API.
app/schemas - Core infra · Config, database, cache, security, storage, and shared exceptions.
app/core
Infrastructure
Persistence and external integrations
- MongoDB · Primary persistent store for users, sessions, items, images, messages, and conversations.
dump/Lost_and_Found - R2 storage · Stores uploaded item images through the storage abstraction.
app/core/s3_storage.py - Resend · Sends notifications and email messages from the backend.
app/services/noti_service.py
Connections 23
- App shell → Auth state: uses · App-wide session state gates protected routes.
- App shell → Shared UI: composes · Routes and screens assemble reusable UI widgets.
- Auth page → API client: calls · Auth flows use centralized API wrappers.
- Listings → API client: calls · Listing and filtering data is fetched through the API client.
- Item detail → API client: calls · Item detail actions read and update backend state.
- Upload item → API client: calls · Upload flow submits item and image data.
- My claims → API client: calls · Claim pages interact with claim endpoints.
- Matches → API client: calls · Match views fetch scored matches.
- Messaging → API client: calls · Chat screens load and send messages.
- Profile → API client: calls · Profile data is fetched and updated through APIs.
- Settings → API client: calls · Settings changes go through the API layer.
- API router → HTTP endpoints: mounts · Router aggregates the domain endpoint modules.
- HTTP endpoints → Services: delegates · HTTP handlers forward business work to services.
- Services → Repositories: reads/writes · Services persist and fetch domain data via repositories.
- Services → Models: uses · Business logic manipulates domain entities.
- HTTP endpoints → Schemas: validates · API contract is shaped by request/response schemas.
- Repositories → MongoDB: stores · Repositories operate over MongoDB collections.
- Core infra → MongoDB: connects · Database configuration and connection management live here.
- Services → R2 storage: uploads · Image workflows store files through the storage abstraction.
- Services → Resend: notifies · Notification service triggers email delivery.
- Core infra → R2 storage: abstracts · Core storage boundary hides the concrete image backend.
- API client → HTTP endpoints: requests · Frontend clients call the backend HTTP contract.
- Services → Core infra: depends on · Services rely on config, security, cache, and shared infra.