How sujal1123/civic-mangement works
Purpose and Topology
CivicSync is a mobile civic-reporting system: an Expo/React Native client submits, browses, edits, and tracks reports through a Node.js API. The repository has two deployable boundaries: mobile-app/ for Android/mobile UI and server/ for HTTP API, persistence, media storage, analytics, and notifications.
Mobile Entry and Navigation
Expo Router file-based routing is rooted at mobile-app/app/_layout.tsx; native Android boots the React Native host through mobile-app/android/app/src/main/java/com/anonymous/CivicSync/MainActivity.kt and MainApplication.kt. Route groups separate public onboarding, authentication, and authenticated tab navigation:
• mobile-app/app/(public)/index.tsx
• mobile-app/app/(auth)/login.tsx
• mobile-app/app/(tabs)/_layout.tsx
Individual report detail is parameterized by mobile-app/app/posts/[id].tsx.
Client State, Session, and Server Selection
Client-wide providers manage language, visual theme, and configurable API-server location, principally:
• mobile-app/context/ServerConfigContext.tsx
• mobile-app/context/ThemeContext.tsx
• mobile-app/context/LanguageContext.tsx
Authentication and local identity persistence are encapsulated in mobile-app/hooks/useAuth.tsx and mobile-app/lib/storage/userStorage.ts. Server address persistence in mobile-app/lib/storage/serverStorage.ts is an important environment boundary, allowing the app to target a selected backend rather than a compile-time endpoint.
Reporting Workflow
The main product flow is report creation and management: tab routes render report UI, form hooks manage input/submission, and media/location components collect report evidence and geography. Key stages are:
• Create report: mobile-app/app/(tabs)/create/index.tsx, mobile-app/hooks/useCreateReportForm.ts
• Browse/refresh reports: mobile-app/app/(tabs)/home/index.tsx, mobile-app/hooks/useReports.ts
• Render/edit/details: mobile-app/components/reports/ReportForm.tsx, mobile-app/components/reports/EditPostModal.tsx, mobile-app/components/reports/PostDetails.tsx
• Map/location selection: mobile-app/components/maps/MapView.tsx, mobile-app/components/common/LocationPicker.tsx
Client API Boundary
All mobile-to-server communication should pass through the API layer: mobile-app/lib/api/apiClient.ts, with domain services in mobile-app/lib/api/reportService.ts and userService.ts. This isolates route/auth/header/error behavior from screens and hooks. Report hooks and forms consume this boundary; they should not directly own transport or backend URL construction.
Server HTTP Pipeline
The backend starts from server/src/server.js, builds the Express application in server/src/app.js, and exposes separate authentication, report, and user route domains:
• server/src/routes/authRoutes.js
• server/src/routes/reportRoutes.js
• server/src/routes/userRoutes.js
Requests flow route → authorization/upload middleware → controller → model/services → standardized response/error handling. Core enforcement boundaries are server/src/middlewares/authMiddleware.js, roleMiddleware.js, uploadMiddleware.js, and errorHandler.js.
Domain, Persistence, and External Services
Mongoose-style domain models define users, departments, and civic reports in server/src/models/User.js, Report.js, and Department.js; database configuration is centralized in server/src/config/db.js. Report controllers coordinate API behavior in server/src/controllers/reportController.js. Media passes through upload middleware and storage abstractions (server/src/services/storageService.js, server/src/config/cloudStorage.js), separating cloud-provider handling from report logic. Notification and analytics side effects are isolated in server/src/services/notificationService.js and analyticsService.js.
Material Runtime and Infrastructure
The client is TypeScript React Native/Expo with Android Gradle packaging configured under mobile-app/android/ and Expo configuration at mobile-app/app.config.js. The API is Node.js/Express, configured from server/src/config/index.js and environment values in server/src/.env; it depends on a database plus cloud media storage, with notification and analytics integrations represented as service boundaries.
Main entry points: reportController.js Report controller · apiClient.ts API client · index.tsx Report screens · reportRoutes.js Route domains
Components 22
Mobile app
Expo/React Native client.
- Expo Router · File-based mobile route root.
mobile-app/app/_layout.tsx - Authenticated tabs · Primary signed-in navigation.
mobile-app/app/(tabs)/_layout.tsx - Login route
mobile-app/app/(auth)/login.tsx - Auth session · Manages authentication and local identity.
mobile-app/hooks/useAuth.tsx - App providers · Server selection, theme, and language state.
mobile-app/context/ServerConfigContext.tsx - Server preference · Persists the selected API server.
mobile-app/lib/storage/serverStorage.ts - Report screens · Create, browse, edit, and view reports.
mobile-app/app/(tabs)/create/index.tsx - Report form hook · Owns report input and submission state.
mobile-app/hooks/useCreateReportForm.ts - Location and map · Collects report geography.
mobile-app/components/maps/MapView.tsx - API client · Centralizes mobile HTTP behavior.
mobile-app/lib/api/apiClient.ts - Report service
mobile-app/lib/api/reportService.ts
API server
Node.js/Express backend.
- Server bootstrap
server/src/server.js - Express app
server/src/app.js - Route domains · Authentication, report, and user endpoints.
server/src/routes/reportRoutes.js - Auth, role, and upload middleware · Enforces access and handles uploaded media.
server/src/middlewares/authMiddleware.js - Report controller · Coordinates report API behavior.
server/src/controllers/reportController.js - Civic domain models · Users, departments, and reports.
server/src/models/Report.js - Error handler · Standardizes API failures.
server/src/middlewares/errorHandler.js - Media storage service · Abstracts cloud media operations.
server/src/services/storageService.js - Notifications and analytics · Report side-effect integrations.
server/src/services/notificationService.js
External infrastructure
- Database · Configured through the server database layer.
- Cloud media storage
Connections 22
- Expo Router → Login route: routes to
- Expo Router → Authenticated tabs: routes to
- Authenticated tabs → Report screens: renders
- Login route → Auth session: authenticates through
- App providers → Server preference: persists selection in
- Report screens → Report form hook: uses
- Report screens → Location and map: collects location with
- Report form hook → Report service: submits through
- Report service → API client: uses
- Auth session → API client: supplies session
- App providers → API client: supplies server address
- API client → Express app: HTTP requests
- Server bootstrap → Express app: starts
- Express app → Route domains: mounts
- Route domains → Auth, role, and upload middleware: applies
- Auth, role, and upload middleware → Report controller: authorizes and forwards
- Route domains → Error handler: errors handled by
- Report controller → Civic domain models: reads and writes
- Civic domain models → Database: persists to
- Report controller → Media storage service: stores media through
- Media storage service → Cloud media storage: uploads to
- Report controller → Notifications and analytics: emits events to