How amilcar1129/agrosmart2.0-frontend works
Purpose and Runtime
Agrosmart20Frontend is an Angular 20 single-page application for managing agricultural/community surveys, their geographic data, and operational views such as dashboards, reports, maps, and users. It runs in the browser, is built with Angular CLI, and starts from src/main.ts into the root application at src/app/app.ts.
Application Composition and Routing
The root shell configures application-wide providers and route navigation through src/app/app.config.ts and src/app/app.routes.ts. src/app/app.html hosts routed content. Routes separate public authentication from protected operational features, including dashboard, surveys, survey detail/list, map, reports, and users.
Authentication and Authorization Boundary
Authentication is centralized in src/app/services/auth.ts. Route-level access control is enforced by src/app/guards/auth.guard.ts and role-specific control by src/app/guards/role.guard.ts. Outbound HTTP requests cross the authentication boundary through src/app/interceptors/auth-interceptor.ts, which likely applies credentials/tokens consistently. Role-aware UI visibility is supported by src/app/shared/directives/has-role.ts.
Authenticated Application Shell
Protected pages are organized under the main layout, which provides persistent navigation and content framing: src/app/layout/main-layout/main-layout.ts and src/app/layout/sidebar/sidebar.ts. The login flow is isolated in src/app/pages/login/login/login.ts, allowing unauthenticated users to enter before accessing the main shell.
Survey Capture Workflow
Survey entry is a multi-step wizard rooted at src/app/pages/survey/survey-wizard/survey-wizard.ts. Domain sections are divided into independently rendered stages, including family data at src/app/pages/survey/steps/family-step/family-step.ts, socioeconomic data at src/app/pages/survey/steps/socioeconomic-step/socioeconomic-step.ts, and agricultural/livestock data at src/app/pages/survey/steps/agro-step/agro-step.ts and src/app/pages/survey/steps/livestock-step/livestock-step.ts. src/app/services/survey.ts is the service boundary for survey persistence and retrieval.
Operational Data Views
Survey records are consumed by a list and detail flow in src/app/pages/encuestas-list/encuestas-list/encuestas-list.ts and src/app/pages/encuesta-detail/encuesta-detail/encuesta-detail.ts. Higher-level monitoring and administration are represented by src/app/pages/dashboard/dashboard/dashboard.ts, src/app/pages/reports/reports/reports.ts, and src/app/pages/users/users/users.ts. Community-specific data access is separated into src/app/services/community.ts.
Geospatial and Media Capabilities
Mapping is available both as a reusable map component and a dedicated map view: src/app/shared/components/map/map/map.ts and src/app/pages/map-view/map-view/map-view.ts. Polygon capture is encapsulated in src/app/shared/components/polygon-drawer/polygon-drawer.ts; Leaflet assets reside in src/assets/leaflet. Survey/media acquisition is handled by src/app/shared/components/photo-capture/photo-capture/photo-capture.ts, creating a browser device/media boundary.
Cross-Cutting UX and Environment Boundaries
Global loading and user feedback are provided by src/app/services/loading.ts, src/app/services/notification.ts, and src/app/shared/components/spinner/spinner/spinner.ts. Deployment-specific service endpoints or settings belong in src/environments/environment.ts and src/environments/environment.prod.ts. Global visual styling enters through src/styles.scss, with app-level styling in src/app/app.scss.
Components 21
Bootstrap
- Browser entry
src/main.ts - Root application
src/app/app.ts - App providers
src/app/app.config.ts - Route definitions · Separates public login from protected operational routes.
src/app/app.routes.ts - Loading & notifications
src/app/services/loading.ts - Environment settings
src/environments/environment.ts
Access boundary
- Authentication
src/app/services/auth.ts - Route access control · Authentication and role guards protect routes.
src/app/guards/auth.guard.ts - Authenticated HTTP
src/app/interceptors/auth-interceptor.ts - Login
src/app/pages/login/login/login.ts - Main layout
src/app/layout/main-layout/main-layout.ts - Sidebar navigation
src/app/layout/sidebar/sidebar.ts
Survey workflow
- Survey wizard
src/app/pages/survey/survey-wizard/survey-wizard.ts - Survey domain steps · Family, socioeconomic, agricultural, and livestock stages.
src/app/pages/survey/steps/family-step/family-step.ts - Survey data · Persists and retrieves surveys.
src/app/services/survey.ts - Photo capture
src/app/shared/components/photo-capture/photo-capture/photo-capture.ts
Operations & geospatial
- Survey list & detail
src/app/pages/encuestas-list/encuestas-list/encuestas-list.ts - Dashboard, reports & users
src/app/pages/dashboard/dashboard/dashboard.ts - Community data
src/app/services/community.ts - Map view
src/app/pages/map-view/map-view/map-view.ts - Map & polygon capture · Renders maps and captures geographic polygons.
src/app/shared/components/map/map/map.ts
Connections 27
- Browser entry → Root application: bootstraps
- Root application → App providers: uses
- Root application → Route definitions: hosts navigation
- Route definitions → Login: public route
- Route definitions → Route access control: protects routes
- Route access control → Authentication: checks session and roles
- Route definitions → Main layout: protected routes
- Main layout → Sidebar navigation: contains
- Login → Authentication: signs in
- App providers → Authenticated HTTP: registers
- Authenticated HTTP → Authentication: gets credentials
- Main layout → Survey wizard: routes to
- Survey wizard → Survey domain steps: renders stages
- Survey wizard → Survey data: saves survey
- Survey wizard → Photo capture: acquires media
- Main layout → Survey list & detail: routes to
- Survey list & detail → Survey data: loads records
- Main layout → Dashboard, reports & users: routes to
- Dashboard, reports & users → Survey data: uses survey data
- Dashboard, reports & users → Community data: uses community data
- Main layout → Map view: routes to
- Map view → Map & polygon capture: renders
- Map & polygon capture → Survey data: uses survey geography
- Survey data → Authenticated HTTP: HTTP requests
- Community data → Authenticated HTTP: HTTP requests
- Survey data → Environment settings: reads endpoint settings
- Survey wizard → Loading & notifications: shows progress and feedback