Link : https://astu-lost-and-found-system-for-render.onrender.com
A campus-ready web app for reporting, browsing, and matching lost/found items at Adama Science & Technology University (ASTU). Students submit posts, admins approve them, and both sides get notified when a match is approved.
- Remove paper logs and scattered chats; give students one place to report.
- Keep sensitive contact info hidden until an admin approves a match.
- Make admins faster: pending queues, filters, and one-click approvals.
- Report – Logged-in student opens
/report/new?type=lost|found, enters details, uploads up to 5 photos (found posts require at least one). Post is stored aspending. - Review – Admin dashboard lists pending posts. Approve ➜ post becomes public; Reject ➜ poster sees remark.
- Browse – Public
/reportshows only approved posts with filters (type, category, location, color, date). - Request – On an item page, a different user files a claim (or “found match” if the original post is lost). Multiple active claims per user/post are prevented.
- Decision – Admin approves a request ➜ item is marked
claimedand both parties receive notifications with each other’s contact info. Rejection sends the requester a remark. - Notify – Users see unread counts in the nav;
/notificationslets them read/mark all.
- Backend: Go 1.21+, Gin, GORM (PostgreSQL)
- Views: Server-rendered HTML templates (Tailwind via CDN with local CSS tweaks)
- Sessions & Auth: Gorilla sessions (cookie store), bcrypt password hashing
- Security middleware: CSRF tokens, role-based guards (student/admin)
- Passwords hashed with bcrypt.
- CSRF protection on all state-changing requests (including logout as POST).
- Session cookie: HttpOnly + SameSite=Lax,
SecurewhenCOOKIE_SECURE=true. - DSN masking in logs; production lowers GORM logging to WARN to avoid PII in SQL traces.
- Upload hardening: MIME sniffing (JPEG/PNG), 5 MB per file, max 5 images, orphan file cleanup on delete.
- Public listing shows only approved posts; contact/location on found items stay hidden until an approved match.
Create .env (or set env vars):
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=yourpass
DB_NAME=lostfound
DB_SSLMODE=disable
# or DATABASE_URL=postgres://user:pass@host:5432/dbname?sslmode=disable
SESSION_SECRET=change_me_32_chars
GO_ENV=development # set to production in prod
COOKIE_SECURE=false # true when behind HTTPS
go mod download
go run .
# server listens on :8080 by default (PORT env overrides)The app auto-migrates tables and, if no admin exists, seeds admin / admin123 (change immediately in prod).
- Register/Login:
/register,/login(login via student ID + password). - Report item:
/report/new?type=lostorfound(auth required). - Browse:
/reportwith filters; click a card to see details. - Request/claim: On an item page, submit the claim form (cannot claim your own post).
- Notifications:
/notificationsto read/mark all. - Admin:
/admin/dashboard,/admin/items,/admin/claims(admins only).
- User: name, student_id (unique, lowercased), phone, email, password hash, role.
- Item: type (lost/found), title, category, color, brand, location, date, description, images, approval_status, status.
- Claim: request_type (claim_request | found_match_request), status, admin_remarks.
- Notification: user_id, title, message, is_read.
main.go– bootstrap, routing, template wiring, auto-migrations, data normalization.internal/handler– HTTP handlers (auth, item, admin, rendering helper).internal/service– business logic, validation, notifications, upload handling.internal/repository– DB operations (items, users, claims, notifications).internal/middleware– auth/session, admin guard, CSRF.templates/– HTML pages/partials.static/– CSS, JS, uploads saved tostatic/uploads.pkg/database– DB connection + masked logging.pkg/utils– bcrypt helpers.
- Set
GO_ENV=productionandCOOKIE_SECURE=true(HTTPS). - Provide
SESSION_SECRET≥ 32 chars. - Point to your PostgreSQL via
DATABASE_URLor discrete DB_* vars. - Rotate the seeded admin password immediately or create admins manually.
- Serve
static/uploadswith appropriate size/virus scanning policies if needed.
- No styles? Ensure Tailwind CDN reachable; hard refresh. (Core layout still works with base CSS.)
- DB connect errors? Recheck env vars, network to Postgres, and that the DSN includes
sslmode. - Upload failures? Respect 5 MB/file and JPEG/PNG only; found posts require at least one photo.
- Branch off
main. - Keep server-rendered templates consistent; run
go test ./.... - Avoid committing
.envor real secrets; they’re intentionally gitignored.