# adityaaryansahu/lost_and_found_system architecture

> Architecture diagram of the GitHub repository adityaaryansahu/lost_and_found_system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adityaaryansahu/lost_and_found_system
- Repository: https://github.com/adityaaryansahu/lost_and_found_system

## Overview

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: [`frontend/src/api/apiClient.js`](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/api/apiClient.js) (API client), [`app/services`](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/services) (Services), [`app/api/endpoints`](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/api/endpoints) (HTTP endpoints), [`app/core`](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/core) (Core infra)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["App shell<br/>React entry<br/>[App.jsx]"]
  node_frontend_auth(("Auth state<br/>context<br/>[AuthContext.jsx]"))
  node_frontend_api["API client<br/>http client<br/>[apiClient.js]"]
  node_frontend_auth_page["Auth page<br/>[Auth.jsx]"]
  node_frontend_listings["Listings<br/>page<br/>[ItemListing.jsx]"]
  node_frontend_item_detail["Item detail<br/>page<br/>[ItemDetail.jsx]"]
  node_frontend_upload["Upload item<br/>page<br/>[ItemUpload.jsx]"]
  node_frontend_claims["My claims<br/>page<br/>[MyClaimsPage.jsx]"]
  node_frontend_matches["Matches<br/>page<br/>[MatchPage.jsx]"]
  node_frontend_messages["Messaging<br/>page<br/>[MessagingPage.jsx]"]
  node_frontend_profile["Profile<br/>page<br/>[Profile.jsx]"]
  node_frontend_settings["Settings<br/>page<br/>[Settings.jsx]"]
  node_frontend_shared_ui["Shared UI<br/>components"]
end

subgraph group_backend["Backend"]
  node_backend_router["API router<br/>[router.py]"]
  node_backend_endpoints["HTTP endpoints<br/>route layer"]
  node_backend_services["Services<br/>business logic"]
  node_backend_repos["Repositories<br/>data access"]
  node_backend_models["Models"]
  node_backend_schemas["Schemas<br/>validation"]
  node_backend_core["Core infra<br/>infrastructure"]
end

subgraph group_infra["Infrastructure"]
  node_db_mongo[("MongoDB<br/>database")]
  node_storage_r2[("R2 storage<br/>object storage<br/>[s3_storage.py]")]
  node_service_resend(("Resend<br/>email service<br/>[noti_service.py]"))
end

node_frontend_app -->|"uses"| node_frontend_auth
node_frontend_app -->|"composes"| node_frontend_shared_ui
node_frontend_auth_page -->|"calls"| node_frontend_api
node_frontend_listings -->|"calls"| node_frontend_api
node_frontend_item_detail -->|"calls"| node_frontend_api
node_frontend_upload -->|"calls"| node_frontend_api
node_frontend_claims -->|"calls"| node_frontend_api
node_frontend_matches -->|"calls"| node_frontend_api
node_frontend_messages -->|"calls"| node_frontend_api
node_frontend_profile -->|"calls"| node_frontend_api
node_frontend_settings -->|"calls"| node_frontend_api
node_backend_router -->|"mounts"| node_backend_endpoints
node_backend_endpoints -->|"delegates"| node_backend_services
node_backend_services -->|"reads/writes"| node_backend_repos
node_backend_services -->|"uses"| node_backend_models
node_backend_endpoints -->|"validates"| node_backend_schemas
node_backend_repos -->|"stores"| node_db_mongo
node_backend_core -->|"connects"| node_db_mongo
node_backend_services -->|"uploads"| node_storage_r2
node_backend_services -->|"notifies"| node_service_resend
node_backend_core -->|"abstracts"| node_storage_r2
node_frontend_api -->|"requests"| node_backend_endpoints
node_backend_services -->|"depends on"| node_backend_core

click node_frontend_app "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/App.jsx"
click node_frontend_auth "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/contexts/AuthContext.jsx"
click node_frontend_api "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/api/apiClient.js"
click node_frontend_auth_page "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/Auth.jsx"
click node_frontend_listings "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/ItemListing.jsx"
click node_frontend_item_detail "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/ItemDetail.jsx"
click node_frontend_upload "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/ItemUpload.jsx"
click node_frontend_claims "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/MyClaimsPage.jsx"
click node_frontend_matches "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/MatchPage.jsx"
click node_frontend_messages "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/MessagingPage.jsx"
click node_frontend_profile "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/Profile.jsx"
click node_frontend_settings "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/Settings.jsx"
click node_frontend_shared_ui "https://github.com/adityaaryansahu/lost_and_found_system/tree/master/frontend/src/components"
click node_backend_router "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/app/api/router.py"
click node_backend_endpoints "https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/api/endpoints"
click node_backend_services "https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/services"
click node_backend_repos "https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/repositories"
click node_backend_models "https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/models"
click node_backend_schemas "https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/schemas"
click node_backend_core "https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/core"
click node_db_mongo "https://github.com/adityaaryansahu/lost_and_found_system/tree/master/dump/Lost_and_Found"
click node_storage_r2 "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/app/core/s3_storage.py"
click node_service_resend "https://github.com/adityaaryansahu/lost_and_found_system/blob/master/app/services/noti_service.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_app,node_frontend_auth,node_frontend_api,node_frontend_auth_page,node_frontend_listings,node_frontend_item_detail,node_frontend_upload,node_frontend_claims,node_frontend_matches,node_frontend_messages,node_frontend_profile,node_frontend_settings,node_frontend_shared_ui toneBlue
class node_backend_router,node_backend_endpoints,node_backend_services,node_backend_repos,node_backend_models,node_backend_schemas,node_backend_core toneAmber
class node_db_mongo,node_storage_r2,node_service_resend toneMint
```

## Components

### Frontend

React UI and client-side state

- [App shell](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/App.jsx): React entry · Bootstraps the frontend and routes into the page layer. · `frontend/src/App.jsx`
- [Auth state](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/contexts/AuthContext.jsx): context · Holds session and access state for the UI. · `frontend/src/contexts/AuthContext.jsx`
- [API client](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/api/apiClient.js): http client · Central wrapper used by frontend features to talk to the backend. · `frontend/src/api/apiClient.js`
- [Auth page](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/Auth.jsx): page · Login and sign-up flows. · `frontend/src/pages/Auth.jsx`
- [Listings](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/ItemListing.jsx): page · Browse and filter items. · `frontend/src/pages/ItemListing.jsx`
- [Item detail](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/ItemDetail.jsx): page · View item details and related actions. · `frontend/src/pages/ItemDetail.jsx`
- [Upload item](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/ItemUpload.jsx): page · Create new item reports and upload images. · `frontend/src/pages/ItemUpload.jsx`
- [My claims](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/MyClaimsPage.jsx): page · Track submitted claims and their status. · `frontend/src/pages/MyClaimsPage.jsx`
- [Matches](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/MatchPage.jsx): page · Show candidate item/user matches. · `frontend/src/pages/MatchPage.jsx`
- [Messaging](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/MessagingPage.jsx): page · Conversation and chat views. · `frontend/src/pages/MessagingPage.jsx`
- [Profile](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/Profile.jsx): page · User profile and account details. · `frontend/src/pages/Profile.jsx`
- [Settings](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/frontend/src/pages/Settings.jsx): page · User preferences and account settings. · `frontend/src/pages/Settings.jsx`
- [Shared UI](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/frontend/src/components): components · Reusable chat, claim form, filters, conversation list, and menu widgets. · `frontend/src/components`

### Backend

FastAPI application layers

- [API router](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/app/api/router.py): FastAPI router · Composes the domain route groups into the application. · `app/api/router.py`
- [HTTP endpoints](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/api/endpoints): route layer · Domain route handlers for auth, users, items, claims, matches, messages, and search. · `app/api/endpoints`
- [Services](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/services): business logic · Core workflows for auth, items, claims, matching, messaging, images, search, notifications, and users. · `app/services`
- [Repositories](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/repositories): data access · MongoDB-oriented persistence for domain entities. · `app/repositories`
- [Models](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/models): domain models · Backend entity definitions for auth, users, items, claims, images, matches, messages, and search. · `app/models`
- [Schemas](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/schemas): validation · Request and response shapes exposed through the API. · `app/schemas`
- [Core infra](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/app/core): infrastructure · Config, database, cache, security, storage, and shared exceptions. · `app/core`

### Infrastructure

Persistence and external integrations

- [MongoDB](https://github.com/adityaaryansahu/lost_and_found_system/tree/master/dump/Lost_and_Found): database · Primary persistent store for users, sessions, items, images, messages, and conversations. · `dump/Lost_and_Found`
- [R2 storage](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/app/core/s3_storage.py): object storage · Stores uploaded item images through the storage abstraction. · `app/core/s3_storage.py`
- [Resend](https://github.com/adityaaryansahu/lost_and_found_system/blob/master/app/services/noti_service.py): email service · Sends notifications and email messages from the backend. · `app/services/noti_service.py`

## Connections

- 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.
