How sundas-razzaq/infracracknet works
Purpose and topology
InfraCrackNet is a full-stack infrastructure-inspection system for detecting cracks in buildings, roads, and bridges with AI-assisted analysis. It has a Vite/React single-page frontend and a Node.js backend. The user workflow spans projects, inspections, image uploads, AI analysis, human validation/annotation, reporting, and notifications.
Application entry points
Frontend bootstraps from Infra-frontend/src/main.jsx into Infra-frontend/src/App.jsx; dashboard navigation is concentrated in Infra-frontend/src/routes/DashboardRoutes.jsx. Backend deployment/runtime entry points are Infra-Backend/index.js, Infra-Backend/server.js, and Express app composition in Infra-Backend/src/app.js.
Client application and access boundary
The React client separates public/auth/dashboard layouts and uses route protection plus shared authentication state. Infra-frontend/src/components/ProtectedRoute.jsx, Infra-frontend/src/context/AuthContext.jsx, and Infra-frontend/src/layouts/DashboardLayout.jsx form the primary client-side access and shell boundary. Feature-specific API modules call the backend, e.g. Infra-frontend/src/api/analysisApi.js, Infra-frontend/src/api/inspectionApi.js, and Infra-frontend/src/api/reportApi.js.
Core inspection domain
Projects contain or organize inspections; inspections carry uploaded images and lifecycle/status data. Backend persistence models define these aggregates in Infra-Backend/src/models/project.js, Infra-Backend/src/models/inspection.js, and Infra-Backend/src/models/inspectionImage.js. Their HTTP interfaces are handled by paired routes/controllers such as Infra-Backend/src/routes/projectRoutes.js, Infra-Backend/src/controllers/inspectionControllers.js, and Infra-Backend/src/controllers/inspectionImageControllers.js. The frontend implements create/edit, inspection execution, and image-upload experiences under Infra-frontend/src/pages/dashboard/projects/ and Infra-frontend/src/pages/dashboard/inspection/.
Image ingestion and AI analysis pipeline
Inspection images pass through upload middleware and Cloudinary integration before analysis records/results are exposed. Key boundaries are Infra-Backend/src/middleware/uploadMiddleware.js, Infra-Backend/src/config/cloudinary.js, and Infra-Backend/src/services/cloudinaryService.js. Analysis orchestration is split between Infra-Backend/src/controllers/analysisController.js, Infra-Backend/src/services/analysisService.js, and persisted analysis/crack entities in Infra-Backend/src/models/AIAnalysis.js and Infra-Backend/src/models/crackDetection.js. The UI presents processing and result stages via Infra-frontend/src/pages/dashboard/analysis/AIProcessingPage.jsx and Infra-frontend/src/pages/dashboard/analysis/AIResultsPage.jsx.
Human review and validation
AI detections can be inspected, edited, rejected, or manually annotated before becoming trusted results. The backend annotation boundary is Infra-Backend/src/routes/annotationRoutes.js and Infra-Backend/src/controllers/annotationController.js; validation rules reside in Infra-Backend/src/validations/annotationValidators.js. The main review workspace is Infra-frontend/src/pages/dashboard/annotation/AnnotationWorkspacePage.jsx, supported by the interactive canvas and editing controls in Infra-frontend/src/components/annotation/AnnotationCanvas.jsx and Infra-frontend/src/components/annotation/CrackEditorModal.jsx.
Identity, roles, and notifications
Authentication, profile operations, and protected API authorization are implemented through Infra-Backend/src/controllers/authControllers.js, Infra-Backend/src/services/authService.js, Infra-Backend/src/middleware/authMiddleware.js, and Infra-Backend/src/models/user.js. Role-oriented dashboard views exist for inspectors and engineers at Infra-frontend/src/pages/dashboard/inspectorDashboard.jsx and Infra-frontend/src/pages/dashboard/engineerDashboard.jsx. Notifications are persisted and delivered through Infra-Backend/src/models/notification.js, Infra-Backend/src/services/notificationService.js, and likely email via Infra-Backend/src/services/emailService.js.
Reports and infrastructure
Validated inspection/analysis information feeds report records and PDF generation. Infra-Backend/src/controllers/reportControllers.js, Infra-Backend/src/models/report.js, and Infra-Backend/src/pdf/generateReport.js form that reporting path; frontend report browsing/export is under Infra-frontend/src/pages/dashboard/reports/. Material infrastructure includes database setup in Infra-Backend/src/config/db.js, Cloudinary for image storage, email delivery, and Vercel deployment descriptors at Infra-Backend/vercel.json and Infra-frontend/vercel.json.
Components 19
React client
- Client bootstrap
Infra-frontend/src/main.jsx - Dashboard routes · Public, auth, and dashboard navigation.
Infra-frontend/src/routes/DashboardRoutes.jsx - Auth and protected shell · Shared session state, route guard, and dashboard layout.
Infra-frontend/src/components/ProtectedRoute.jsx - Inspection workflows · Project editing, inspection execution, and image upload.
- Analysis results UI · Processing status and AI result presentation.
Infra-frontend/src/pages/dashboard/analysis/AIResultsPage.jsx - Annotation workspace · Interactive detection validation and editing.
Infra-frontend/src/pages/dashboard/annotation/AnnotationWorkspacePage.jsx - Report UI · Report browsing and export.
- Feature API clients · Analysis, inspection, and report HTTP calls.
Infra-frontend/src/api/analysisApi.js
Node/Express backend
- Express application · Composes backend middleware and routes.
Infra-Backend/src/app.js - Identity and authorization · Authentication, profiles, roles, and protected API access.
Infra-Backend/src/services/authService.js - Projects and inspections · Project, inspection, image, and lifecycle management.
Infra-Backend/src/controllers/inspectionControllers.js - Image ingestion · Upload middleware and Cloudinary asset handling.
Infra-Backend/src/middleware/uploadMiddleware.js - AI analysis orchestration · Creates analysis and crack-detection results.
Infra-Backend/src/services/analysisService.js - Human validation · Validates, edits, rejects, and annotates detections.
Infra-Backend/src/controllers/annotationController.js - Reports and PDF generation · Builds report records and PDFs from trusted findings.
Infra-Backend/src/pdf/generateReport.js - Notifications · Persists notifications and triggers email delivery.
Infra-Backend/src/services/notificationService.js
Infrastructure services
- Application database · Stores users, projects, inspections, analyses, findings, reports, and notifications.
Infra-Backend/src/config/db.js - Cloudinary · External inspection-image storage.
Infra-Backend/src/config/cloudinary.js - Email delivery · Outbound notification delivery.
Infra-Backend/src/services/emailService.js
Connections 29
- Client bootstrap → Dashboard routes: mounts
- Dashboard routes → Auth and protected shell: applies guard and shell
- Auth and protected shell → Inspection workflows: hosts
- Auth and protected shell → Analysis results UI: hosts
- Auth and protected shell → Annotation workspace: hosts
- Auth and protected shell → Report UI: hosts
- Inspection workflows → Feature API clients: uses
- Analysis results UI → Feature API clients: uses
- Annotation workspace → Feature API clients: uses
- Report UI → Feature API clients: uses
- Feature API clients → Express application: HTTP requests
- Express application → Identity and authorization: auth endpoints and middleware
- Express application → Projects and inspections: inspection routes
- Express application → AI analysis orchestration: analysis routes
- Express application → Human validation: annotation routes
- Express application → Reports and PDF generation: report routes
- Identity and authorization → Application database: users and roles
- Projects and inspections → Image ingestion: uploads inspection images
- Projects and inspections → Application database: projects, inspections, images
- Image ingestion → Cloudinary: stores assets
- Image ingestion → AI analysis orchestration: provides image assets
- AI analysis orchestration → Application database: analysis and crack records
- AI analysis orchestration → Human validation: submits detections for review
- Human validation → Application database: persists validated findings
- Human validation → Reports and PDF generation: trusted findings
- Reports and PDF generation → Application database: report records
- AI analysis orchestration → Notifications: analysis status
- Notifications → Application database: persists notifications
- Notifications → Email delivery: sends email