|
| 1 | +# Aarini Architecture |
| 2 | + |
| 3 | +Aarini is a cross-platform mobile application built to provide health insights, cycle tracking, and ML-powered predictions. The system is split between a React Native (Expo) frontend and a Python-based backend handling the predictive logic, all bound together by Firebase for real-time data synchronization. |
| 4 | + |
| 5 | +## ?? High-Level Overview |
| 6 | + |
| 7 | +The architecture is divided into three primary tiers: |
| 8 | + |
| 9 | +1. **Client / Frontend (`frontend/`)**: An Expo React Native application providing the user interface, state management, and device integration. |
| 10 | +2. **Backend API (`backend/`)**: A Python-based service responsible for machine learning algorithms, cycle predictions, and data analysis. |
| 11 | +3. **Database & Auth (Firebase)**: Firestore provides real-time NoSQL data storage (governed by `firestore.rules`), while Firebase Authentication secures user sessions. |
| 12 | + |
| 13 | +### ?? System Architecture Diagram |
| 14 | + |
| 15 | +```mermaid |
| 16 | +graph TD |
| 17 | + User[End User (Mobile)] |
| 18 | + |
| 19 | + subgraph Frontend Application |
| 20 | + Expo[React Native / Expo App] |
| 21 | + Context[React Context / State] |
| 22 | + Screens[UI Screens & Components] |
| 23 | + Services[API Services / Hooks] |
| 24 | + end |
| 25 | + |
| 26 | + subgraph Backend Services |
| 27 | + Python[Python API] |
| 28 | + ML[Cycle Prediction Engine] |
| 29 | + end |
| 30 | + |
| 31 | + subgraph Firebase Infrastructure |
| 32 | + Auth[Firebase Authentication] |
| 33 | + Firestore[Cloud Firestore DB] |
| 34 | + end |
| 35 | + |
| 36 | + User -->|Interacts| Screens |
| 37 | + Screens -->|Dispatches| Context |
| 38 | + Context -->|Uses| Services |
| 39 | + |
| 40 | + Services -->|Authenticates| Auth |
| 41 | + Services -->|Reads/Writes| Firestore |
| 42 | + Services -->|Fetches Predictions| Python |
| 43 | + |
| 44 | + Python -->|Queries History| Firestore |
| 45 | + Python -->|Runs Models| ML |
| 46 | +``` |
| 47 | + |
| 48 | +## ?? Directory Structure |
| 49 | + |
| 50 | +### Frontend (`frontend/`) |
| 51 | +- **`assets/`**: Static images and fonts. |
| 52 | +- **`components/`**: Reusable UI components. |
| 53 | +- **`screens/`**: Full-page views for navigation. |
| 54 | +- **`context/`**: Global state management (Auth, Theme). |
| 55 | +- **`services/`**: API wrappers and Firebase interactions. |
| 56 | +- **`utils/`**: Helper functions and parsers. |
| 57 | +- **`navigation/`**: React Navigation configurations. |
| 58 | + |
| 59 | +### Backend (`backend/`) |
| 60 | +- **`app.py`**: Main application entry point for the REST API. |
| 61 | +- **`cycle_prediction.py`**: Core algorithm for predicting cycles. |
| 62 | +- **`tests/`**: Unit tests for backend logic. |
| 63 | + |
| 64 | +## ?? Data Flow |
| 65 | + |
| 66 | +1. **User Input**: A user logs a new symptom on the mobile app. |
| 67 | +2. **Frontend Service**: The `frontend/services` layer packages this data and sends it securely to Firebase Firestore. |
| 68 | +3. **Backend Trigger**: When the user requests a new prediction, the Python backend queries the recent data from Firestore. |
| 69 | +4. **Processing**: `cycle_prediction.py` processes the historical data. |
| 70 | +5. **Response**: The backend returns the predicted dates to the frontend, which updates the React Context and re-renders the UI. |
| 71 | + |
| 72 | +## ?? Deployment Strategy |
| 73 | + |
| 74 | +- **Frontend**: Distributed via Expo Application Services (EAS). |
| 75 | +- **Backend**: Containerized/Deployed via standard PaaS providers (e.g. Render, Vercel, Heroku) as defined by `render.yaml`. |
| 76 | +- **Database**: Serverless deployment on Google Cloud via Firebase. |
0 commit comments