# milpagit/agenda-inteligente architecture

> Architecture diagram of the GitHub repository milpagit/agenda-inteligente, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/milpagit/agenda-inteligente
- Repository: https://github.com/milpagit/agenda-inteligente

## Overview

##### Project Type and Purpose
- This is a full-stack calendar application frontend built with React and Redux Toolkit.
- Its goal is to provide authenticated users with a rich calendar UI to create, view, update, and delete events, plus view others’ events.
- It integrates with:
- A separate Node.js/Express/MongoDB backend (hosted elsewhere) for core CRUD and auth APIs.
- Firebase Hosting for static asset delivery and Firebase Cloud Functions (Python) under the `functions/` folder for background tasks such as proactive alerts or imports.

##### File Structure Analysis
- Top-level:
- `public/` – Static HTML/CSS/manifest for the SPA entry point.
- `src/` – All application code.
- `functions/` – Firebase Cloud Functions in Python.
- Config files: `firebase.json`, `.firebaserc`, `babel.config.js`, `jest.config.js`.
- `src/` breakdown:
- `api/` – Axios wrappers for REST endpoints: `alertsApi.js`, `functionsApi.js`, `importApi.js`, `alertsApi.js`.
- `auth/` and `calendar/` – Feature modules with pages and components (e.g., Login, Onboarding, CalendarPage, CalendarModal).
- `hooks/` – Custom React hooks for state stores and form handling.
- `store/` – Redux slices organized by domain (auth, calendar, habits, notifications, recommendations, subjects, tasks, ui).
- `router/` – React Router setup (`AppRouter.jsx`).
- `firebase/config.js` – Firebase SDK initialization for hosting or messaging.
- `core/recommendationEngine.js` – Business logic for recommending events.
- `helpers/` – Utility functions such as date conversions, localizers, and message lookups.

##### Key Architecture Patterns
- Single-Page Application (SPA) with React and React Router.
- Global state management via Redux Toolkit slices and custom hooks.
- API abstraction layer using Axios.
- Modular “feature-folder” structure (auth, calendar, shared).
- Separation of concerns: UI components vs. business logic vs. data layer.
- Serverless functions (Firebase) alongside a traditional backend (Node/Express/MongoDB).

##### Main Components
a. Frontend SPA
- React Components (Auth pages, Calendar pages, Shared/Loading)
- Redux Store (slices for auth, calendar, etc.)
- Custom Hooks + Recommendation Engine + Helpers
b. API Layer
- Axios wrappers → HTTP calls to:
- Node.js/Express backend (`REACT_APP_API_URL`)
- Firebase Cloud Functions (hosted under your Firebase project)
c. Backend Services
- Node.js + Express REST API → MongoDB database
- Firebase Cloud Functions (Python) → external triggers or cron jobs
d. Hosting & Deployment
- Firebase Hosting serves `public/` and bundles from Webpack/Babel
- Cloud Functions deployed via `firebase.json`

##### Interactions & Data Flow
- User (Browser) → React SPA (hosted on Firebase Hosting)
- SPA dispatches Redux actions → Custom Hooks → Axios APIs
- Axios →
- Express API endpoints → CRUD on MongoDB
- Firebase Function endpoints → background tasks (e.g., proactive alerts, imports)
- Responses cycle back through Redux store → UI updates

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client (Browser)" 
        direction TB
        Entry["Entry Point\nsrc/index.js\nsrc/CalendarApp.jsx"]:::frontend
        Router["React Router\nAppRouter.jsx\nindex.js"]:::frontend
        subgraph "UI Components" 
            direction TB
            AuthModule["Auth Module"]:::frontend
            CalendarModule["Calendar Module"]:::frontend
            SharedModule["Shared Components"]:::frontend
        end
        subgraph "State & Logic"
            direction TB
            Store["Redux Store"]:::state
            Hooks["Custom Hooks\n(src/hooks/)"]:::state
            RecEngine["Recommendation Engine\ncore/recommendationEngine.js"]:::state
            Helpers["Utility Helpers\n(src/helpers/)"]:::state
            FirebaseConfig["Firebase SDK Init\nsrc/firebase/config.js"]:::state
        end
        subgraph "API Layer"
            direction TB
            AlertsApi["alertsApi.js"]:::api
            FunctionsApi["functionsApi.js"]:::api
            ImportApi["importApi.js"]:::api
            ApiIndex["api/index.js"]:::api
        end
    end

    %% Auth Module Details
    subgraph "Auth Module Details"
        direction TB
        LoginPage["LoginPage.jsx"]:::frontend
        OnboardingPage["OnboardingPage.jsx"]:::frontend
        AuthIndex["src/auth/index.js"]:::frontend
    end

    %% Calendar Module Details
    subgraph "Calendar Module Details"
        direction TB
        CalendarPage["CalendarPage.jsx"]:::frontend
        CalendarComponents["src/calendar/components/"]:::frontend
        CalendarIndex["src/calendar/index.js"]:::frontend
    end

    %% Shared Module Details
    subgraph "Shared Module Details"
        direction TB
        LoadingPage["LoadingPage.jsx"]:::frontend
        SharedIndex["src/shared/index.js"]:::frontend
    end

    %% Serverless Layer
    subgraph "Serverless (Firebase)" 
        direction TB
        Hosting["Firebase Hosting\n(public/)"]:::cloud
        Functions["Cloud Functions\nfunctions/main.py"]:::cloud
    end

    %% Server Layer
    subgraph "Server (Backend)"
        direction TB
        ExpressAPI["Express API Server"]:::backend
        MongoDB["MongoDB"]:::db
    end

    %% Static Assets
    StaticAssets["public/index.html\nmanifest.json\nrobots.txt"]:::frontend

    %% Flows
    Entry -->|renders| Router
    Router -->|routes to| AuthModule
    Router -->|routes to| CalendarModule
    Router -->|routes to| SharedModule
    AuthModule -->|renders pages| LoginPage
    AuthModule -->|renders pages| OnboardingPage
    CalendarModule -->|renders page| CalendarPage
    CalendarModule -->|uses components| CalendarComponents
    SharedModule -->|renders| LoadingPage

    Entry -->|provides| FirebaseConfig
    Entry -->|uses| Store
    Entry -->|uses| Hooks
    Entry -->|uses| RecEngine
    Entry -->|uses| Helpers

    Store -->|dispatch actions| AlertsApi
    Store -->|dispatch actions| FunctionsApi
    Store -->|dispatch actions| ImportApi

    AlertsApi -->|HTTP| ExpressAPI
    ImportApi -->|HTTP| Functions
    FunctionsApi -->|HTTP| Functions

    ExpressAPI -->|CRUD| MongoDB
    Functions -->|background tasks| MongoDB

    Hosting -->|serves| StaticAssets
    Hosting -->|serves| Entry

    %% Click Events
    click Entry "https://github.com/milpagit/agenda-inteligente/blob/main/src/index.js"
    click Entry "https://github.com/milpagit/agenda-inteligente/blob/main/src/CalendarApp.jsx"
    click Router "https://github.com/milpagit/agenda-inteligente/blob/main/src/router/AppRouter.jsx"
    click Router "https://github.com/milpagit/agenda-inteligente/blob/main/src/router/index.js"
    click LoginPage "https://github.com/milpagit/agenda-inteligente/blob/main/src/auth/pages/LoginPage.jsx"
    click OnboardingPage "https://github.com/milpagit/agenda-inteligente/blob/main/src/auth/pages/OnboardingPage.jsx"
    click AuthIndex "https://github.com/milpagit/agenda-inteligente/blob/main/src/auth/index.js"
    click CalendarPage "https://github.com/milpagit/agenda-inteligente/blob/main/src/calendar/pages/CalendarPage.jsx"
    click CalendarComponents "https://github.com/milpagit/agenda-inteligente/tree/main/src/calendar/components/"
    click CalendarIndex "https://github.com/milpagit/agenda-inteligente/blob/main/src/calendar/index.js"
    click LoadingPage "https://github.com/milpagit/agenda-inteligente/blob/main/src/shared/pages/LoadingPage.jsx"
    click SharedIndex "https://github.com/milpagit/agenda-inteligente/blob/main/src/shared/index.js"
    click Store "https://github.com/milpagit/agenda-inteligente/blob/main/src/store/store.js"
    click Store "https://github.com/milpagit/agenda-inteligente/blob/main/src/store/index.js"
    click AlertsApi "https://github.com/milpagit/agenda-inteligente/blob/main/src/api/alertsApi.js"
    click FunctionsApi "https://github.com/milpagit/agenda-inteligente/blob/main/src/api/functionsApi.js"
    click ImportApi "https://github.com/milpagit/agenda-inteligente/blob/main/src/api/importApi.js"
    click ApiIndex "https://github.com/milpagit/agenda-inteligente/blob/main/src/api/index.js"
    click RecEngine "https://github.com/milpagit/agenda-inteligente/blob/main/src/core/recommendationEngine.js"
    click Helpers "https://github.com/milpagit/agenda-inteligente/tree/main/src/helpers/"
    click FirebaseConfig "https://github.com/milpagit/agenda-inteligente/blob/main/src/firebase/config.js"
    click StaticAssets "https://github.com/milpagit/agenda-inteligente/blob/main/public/index.html"
    click StaticAssets "https://github.com/milpagit/agenda-inteligente/blob/main/public/manifest.json"
    click StaticAssets "https://github.com/milpagit/agenda-inteligente/blob/main/public/robots.txt"
    click Functions "https://github.com/milpagit/agenda-inteligente/blob/main/functions/main.py"
    click Functions "https://github.com/milpagit/agenda-inteligente/blob/main/functions/requirements.txt"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#1976D2,color:#0D47A1
    classDef state fill:#E8F5E9,stroke:#388E3C,color:#1B5E20
    classDef api fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef backend fill:#FFEBEE,stroke:#E53935,color:#B71C1C
    classDef db fill:#ECEFF1,stroke:#607D8B,color:#263238
    classDef cloud fill:#F3E5F5,stroke:#8E24AA,color:#4A148C
```
