# alexcl0320/gestion_documental architecture

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

- Interactive diagram: https://gitdiagram.com/alexcl0320/gestion_documental
- Repository: https://github.com/alexcl0320/gestion_documental

## Overview

##### Project type and purpose
- The “src/app” directory contains React/Next.js pages and layouts, indicating an SSR/CSR frontend.
- The “src/backend” folder holds AI-related TypeScript functions (e.g., flows, generation scripts) and a database migration, implying serverless or function-based backend APIs plus a relational database.

##### File structure
- Top-level directories:
- src/app – Next.js 13+ app directory with page.tsx routes
- src/components – UI components (compliance charts, tables, forms, layout, generic UI library)
- src/context, src/hooks – React context and custom hooks for auth, compliance data, toasts
- src/backend – AI micro-services (flows, dev harness) and database migrations
- src/lib – shared utilities and placeholder data
- Config files:
- next.config.* – Next.js configuration
- tailwind.config.ts, postcss.config.mjs – styling setup with Tailwind CSS
- apphosting.yaml – Firebase hosting/deployment descriptor
- package.json, tsconfig.json – dependencies and TypeScript setup

##### Key insights from README
- It’s a Next.js starter project integrated with Firebase, designed to demonstrate hosting and basic features (“take a look at src/app/page.tsx”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend" 
        direction TB
        AppRouter["Next.js App Router (SSR/CSR Frontend)"]:::frontend
        Layout["Main Layout"]:::frontend
        Globals["Global Stylesheet"]:::frontend
        subgraph "Pages"
            direction TB
            Home["Home Page"]:::frontend
            CompliancePage["Compliance Page"]:::frontend
            DocumentsPage["Documents Page"]:::frontend
            TeachersPage["Teachers Page"]:::frontend
            ProfilePage["Profile Page"]:::frontend
            SettingsPage["Settings Page"]:::frontend
            LoginPage["Login Page"]:::frontend
            ForgotPasswordPage["Forgot Password Page"]:::frontend
        end
        subgraph "UI Components"
            direction TB
            UILib["UI Component Library"]:::frontend
            ComplianceUI["Compliance Charts"]:::frontend
            DashboardUI["Dashboard Widgets"]:::frontend
            DocumentsUI["Documents Uploader & List"]:::frontend
            TeachersUI["Teachers Forms & Table"]:::frontend
            LayoutComps["Layout Components"]:::frontend
            Icons["Shared Icons"]:::frontend
        end
        subgraph "State & Data"
            direction TB
            AuthContext["Auth Context"]:::frontend
            HooksAuth["use-auth Hook"]:::frontend
            HooksCompliance["use-compliance-report Hook"]:::frontend
            HooksMobile["use-mobile Hook"]:::frontend
            HooksToast["use-toast Hook"]:::frontend
            Utils["Utility Functions"]:::frontend
            PlaceholderData["Placeholder Images & Data"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB
        subgraph "AI Micro-services"
            direction TB
            DevHarness["Dev Harness Entry"]:::backend
            GenCompliance["Generate Compliance Report"]:::backend
            GenKit["GenKit Integration"]:::backend
        end
        subgraph "Database Layer"
            direction TB
            Migrations["SQL Migrations"]:::backend
            Database["SQL Database"]:::db
        end
    end

    %% Config & Deployment
    subgraph "Configuration & Deployment"
        direction TB
        FirebaseHosting["Firebase Hosting / CDN"]:::compute
        NextConfig1["next.config.mjs"]:::config
        NextConfig2["next.config.ts"]:::config
        TailwindConfig["Tailwind CSS Config"]:::config
        PostCSSConfig["PostCSS Config"]:::config
        PackageJSON["package.json"]:::config
        TSConfig["tsconfig.json"]:::config
        HostingDesc["apphosting.yaml"]:::config
    end

    %% External Service
    ExternalAI["OpenAI GenKit Service"]:::external

    %% Connections
    Browser["Browser / Mobile Client"]:::external
    Browser -->|"HTTP Request"| FirebaseHosting
    FirebaseHosting -->|"Serves Static & Proxies"| AppRouter
    AppRouter -->|"Renders Layout"| Layout
    AppRouter -->|"Applies Styles"| Globals
    AppRouter -->|"Renders Pages"| Pages
    Home -->|"uses"| UILib
    CompliancePage -->|"uses"| HooksCompliance
    DocumentsPage -->|"uses"| DocumentsUI
    TeachersPage -->|"uses"| TeachersUI
    ProfilePage -->|"uses"| AuthContext
    SettingsPage -->|"uses"| HooksAuth
    LoginPage -->|"uses"| HooksAuth
    ForgotPasswordPage -->|"uses"| HooksAuth
    Layout -->|"uses"| LayoutComps
    Layout -->|"uses"| Icons
    UILib -->|"imports"| Utils
    UILib -->|"imports"| PlaceholderData
    AppRouter -->|"API Call"| GenCompliance
    AppRouter -->|"API Call"| DevHarness
    GenCompliance -->|"calls"| GenKit
    GenKit -->|"calls External API"| ExternalAI
    GenCompliance -->|"reads/writes"| Database
    DevHarness -->|"reads/writes"| Database
    Migrations -->|"define schema"| Database
    AppRouter -->|"queries"| Database
    FirebaseHosting -->|"deploys configs"| NextConfig1
    FirebaseHosting -->|"deploys configs"| NextConfig2
    FirebaseHosting -->|"deploys configs"| TailwindConfig
    FirebaseHosting -->|"deploys configs"| PostCSSConfig
    FirebaseHosting -->|"deploys configs"| PackageJSON
    FirebaseHosting -->|"deploys configs"| TSConfig
    FirebaseHosting -->|"deploys configs"| HostingDesc

    %% Click Events
    click AppRouter "https://github.com/alexcl0320/gestion_documental/tree/main/src/app/"
    click Layout "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/layout.tsx"
    click Globals "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/globals.css"
    click Home "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/page.tsx"
    click CompliancePage "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/compliance/page.tsx"
    click DocumentsPage "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/documents/page.tsx"
    click TeachersPage "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/teachers/page.tsx"
    click ProfilePage "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/profile/page.tsx"
    click SettingsPage "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/settings/page.tsx"
    click LoginPage "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/login/page.tsx"
    click ForgotPasswordPage "https://github.com/alexcl0320/gestion_documental/blob/main/src/app/forgot-password/page.tsx"
    click UILib "https://github.com/alexcl0320/gestion_documental/tree/main/src/components/ui/"
    click ComplianceUI "https://github.com/alexcl0320/gestion_documental/tree/main/src/components/compliance/"
    click DashboardUI "https://github.com/alexcl0320/gestion_documental/tree/main/src/components/dashboard/"
    click DocumentsUI "https://github.com/alexcl0320/gestion_documental/tree/main/src/components/documents/"
    click TeachersUI "https://github.com/alexcl0320/gestion_documental/tree/main/src/components/teachers/"
    click LayoutComps "https://github.com/alexcl0320/gestion_documental/tree/main/src/components/layout/"
    click Icons "https://github.com/alexcl0320/gestion_documental/blob/main/src/components/icons.tsx"
    click AuthContext "https://github.com/alexcl0320/gestion_documental/blob/main/src/context/auth-context.tsx"
    click HooksAuth "https://github.com/alexcl0320/gestion_documental/blob/main/src/hooks/use-auth.ts"
    click HooksCompliance "https://github.com/alexcl0320/gestion_documental/blob/main/src/hooks/use-compliance-report.ts"
    click HooksMobile "https://github.com/alexcl0320/gestion_documental/blob/main/src/hooks/use-mobile.ts"
    click HooksToast "https://github.com/alexcl0320/gestion_documental/blob/main/src/hooks/use-toast.ts"
    click Utils "https://github.com/alexcl0320/gestion_documental/blob/main/src/lib/utils.ts"
    click PlaceholderData "https://github.com/alexcl0320/gestion_documental/blob/main/src/lib/placeholder-images.ts"
    click DevHarness "https://github.com/alexcl0320/gestion_documental/blob/main/src/backend/ai/dev.ts"
    click GenCompliance "https://github.com/alexcl0320/gestion_documental/blob/main/src/backend/ai/flows/generate-compliance-report.ts"
    click GenKit "https://github.com/alexcl0320/gestion_documental/blob/main/src/backend/ai/genkit.ts"
    click Migrations "https://github.com/alexcl0320/gestion_documental/blob/main/src/backend/database/migrations/0001_initial_schema.sql"
    click HostingDesc "https://github.com/alexcl0320/gestion_documental/blob/main/apphosting.yaml"
    click NextConfig1 "https://github.com/alexcl0320/gestion_documental/blob/main/next.config.mjs"
    click NextConfig2 "https://github.com/alexcl0320/gestion_documental/blob/main/next.config.ts"
    click TailwindConfig "https://github.com/alexcl0320/gestion_documental/blob/main/tailwind.config.ts"
    click PostCSSConfig "https://github.com/alexcl0320/gestion_documental/blob/main/postcss.config.mjs"
    click PackageJSON "https://github.com/alexcl0320/gestion_documental/blob/main/package.json"
    click TSConfig "https://github.com/alexcl0320/gestion_documental/blob/main/tsconfig.json"

    %% Styles
    classDef frontend fill:#E8EAF6,stroke:#3949AB,color:#1A237E
    classDef backend fill:#F3E5F5,stroke:#8E24AA,color:#4A148C
    classDef compute fill:#E0F7FA,stroke:#006064,color:#004D40
    classDef db fill:#FFE0B2,stroke:#FB8C00,color:#E65100
    classDef external fill:#DCEDC8,stroke:#2E7D32,color:#1B5E20
    classDef config fill:#FFF3E0,stroke:#E65100,color:#BF360C
```
