How bazieebenezer/anam-app works
Project type and purpose
• ANAM is a full-stack, multi-channel information platform built with a single Ionic/Angular codebase for Web, iOS and Android.
• It delivers weather bulletins and event notifications to general users and institution-level users, with role-based access and PDF export.
• The backend is serverless (Firebase) plus a small Node.js micro-service for push notifications, and an email-server for outbound email.
File-structure overview and architectural clues
• Top level
• capacitor.config.ts, firebase.json, ionic.config.json → configuration for Capacitor and Firebase hosting/integration
• android/ and ios/ → native project wrappers generated by Capacitor
• anam-server/ → Node.js micro-service that listens to Firestore and triggers FCM pushes
• email-server/ → standalone service for sending emails (package.json present)
• src/ → Ionic/Angular application code (components, pages, services, guards, model)
• docs/ → feature and architecture documentation
• Key patterns
• src/app/services → thin Angular services interacting with Firebase SDK and Capacitor plugins
• src/environments → environment-specific Firebase config
• angular.json, tsconfig.json → standard Angular workspace
Main system components
A. Client layer (Ionic/Angular)
• Shared codebase: src/app/components, pages, services, guards
• PDF generation service (html2canvas → jsPDF → @capacitor/filesystem → file-opener)
• Authentication flow: AuthService, onboarding, role guards
• Push subscription: FcmService with Capacitor Push and Community FCM plugin
B. Capacitor bridge
• Provides access to native APIs (camera, filesystem, preferences, social-login, push notifications)
• Generates Android (android/) and iOS (ios/) projects
C. Firebase (managed cloud services)
• Authentication (Firebase Auth)
• Firestore (NoSQL real-time DB) for users, bulletins, events
• Cloud Storage (object store for images after refactor)
• Cloud Messaging (FCM)
• (Optionally Cloud Functions for secure role elevation and image processing)
D. Node.js micro-service (anam-server)
• Listens to Firestore onSnapshot events
• Builds FCM topics and sends push notifications via Firebase Admin SDK
E. Email-server
• Sends email notifications or reports (could be triggered by Cloud Functions or by Node micro-service)
Relationships and data flows
• The Ionic app communicates directly with Firebase services via SDK over HTTPS / WebSockets:
• AuthService ↔ Firebase Auth
• EventService/PublicationService ↔ Firestore reads/writes
• ImageUploadService ↔ Cloud Storage (upload) → returns URL → stored in Firestore
• FcmService ↔ FCM (subscribe/unsubscribe to topics)
• The Node micro-service uses Firebase Admin SDK:
• Connects to Firestore → listens for new bulletins/events
• Constructs FCM topic names (newPosts, institution_{id}) → sends push notifications
• PDF export: Angular app renders invisible DOM → html2canvas captures → jsPDF outputs → file handled by Capacitor
• Email-server: invoked either by HTTP request or Cloud Function trigger to send email via SMTP/API
Architectural patterns and principles
• Separation of concerns: UI (components/pages), business logic (services), persistence (Firebase)
• Event-driven micro-service for notifications (decoupled push logic)
• Pub/Sub with FCM topics for broad vs. targeted notifications
• Feature modules (auth, onboarding, publications, PDF, theme) in Angular
• Role-based access control using guards and Custom Claims (recommended)
• Single codebase supporting multi-platform via Capacitor