# surajpatel24-r/transfer_certificate_generator architecture

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

- Interactive diagram: https://gitdiagram.com/surajpatel24-r/transfer_certificate_generator
- Repository: https://github.com/surajpatel24-r/transfer_certificate_generator

## Overview

##### Project Type and Purpose
- This is a cross-platform Flutter mobile/desktop/web application whose sole purpose is to allow college staff to enter student data, persist or sync it (via Google Sheets), then generate and export a PDF transfer certificate and an Excel summary.

##### Main Architectural Layers & Components
a. Presentation Layer (Flutter UI)
– lib/screens: individual screens (Home, Forms, About, Faculty-specific screens)
– lib/main.dart: entry point and MaterialApp/router setup
b. Domain/Logic Layer
– lib/service/data_controller.dart: orchestrates data operations (CRUD, generate exports)
– lib/models: domain entities (Student, User)
c. Data Layer
– lib/service/data_store.dart: local in-memory or on-device caching logic
– lib/api/sheets/tc_sheets_api.dart: integration with Google Sheets REST API (read/write)
d. Template/Export Layer
– lib/templates/template_*.dart: PDF certificate templates, layout logic
– (You likely use packages such as `pdf` or `excel`)
e. Platform Embedder & Runtime
– android/, ios/, linux/, macos/, windows/, web/: Flutter engine integration & native launchers
– Pubspec.yaml / build scripts: dependency and build configuration

##### External Services & Outputs
- Local File System:
– PDF certificate files (.pdf)
– Excel workbook (.xlsx)

##### Data Flow & Component Interactions
1. User taps “New Certificate” in Flutter UI
2. UI invokes DataController.createCertificate(studentData)
3. DataController:
- Validates and updates Student model
- Calls DataStore.saveLocal(...) to cache data (optional)
- Calls SheetsAPI.upsertRecord(...) to sync with Google Sheets
4. Upon success, DataController invokes TemplateEngine.generatePDF(...)
5. PDF file written to Local File System
6. DataController invokes TemplateEngine.generateExcelReport(allRecords)
7. Excel file written to Local File System
8. UI displays share/preview options

##### Architectural Patterns & Principles
- Layered (Clean) Architecture: clear separation between UI, business logic, data, and external integrations
- Dependency Flow: UI depends on Controller → Controller depends on Data & Template modules → Data modules depend on external service interfaces
- Single Responsibility: each folder (api, service, templates, models) contains cohesive code
- Cross-platform Embedding: native host layers (Android/iOS/etc.) only handle app initialization

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Screens["Screens (lib/screens)"]:::ui
        Main["Main (lib/main.dart)"]:::ui
    end

    %% Domain/Logic Layer
    subgraph "Domain/Logic Layer"
        direction TB
        DataController["DataController (lib/service/data_controller.dart)"]:::logic
        StudentModel["Student Model (lib/models/student.dart)"]:::logic
        UserModel["User Model (lib/models/user.dart)"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        DataStore["DataStore (lib/service/data_store.dart)"]:::data
        SheetsAPI["Sheets API Client (lib/api/sheets/tc_sheets_api.dart)"]:::data
    end

    %% Template/Export Layer
    subgraph "Template/Export Layer"
        direction TB
        Template1["Template 1 (lib/templates/template_1.dart)"]:::templ
        Template2["Template 2 (lib/templates/template_2.dart)"]:::templ
        Template3["Template 3 (lib/templates/template_3.dart)"]:::templ
    end

    %% External Services & Outputs
    subgraph "External Services & Outputs"
        direction TB
        GoogleSheets["Google Sheets API"]:::external
        PDFFile["PDF File (.pdf)"]:::external
        ExcelFile["Excel File (.xlsx)"]:::external
    end

    %% Platform Embedders
    subgraph "Platform Embedders & Runtimes"
        direction TB
        Android["android/"]:::platform
        iOS["ios/"]:::platform
        Linux["linux/"]:::platform
        macOS["macos/"]:::platform
        Windows["windows/"]:::platform
        Web["web/"]:::platform
    end

    %% Connections
    Main -->|"navigates to"| Screens
    Screens -->|"createCertificate()"| DataController
    DataController -->|"validates & updates"| StudentModel
    DataController -->|"validates & updates"| UserModel
    DataController -->|"saveLocal()"| DataStore
    DataController -->|"upsertRecord()"| SheetsAPI
    SheetsAPI -->|"HTTP"| GoogleSheets
    DataController -->|"generatePDF()"| Template1
    Template1 -->|"writes to"| PDFFile
    DataController -->|"generateExcelReport()"| Template2
    Template2 -->|"writes to"| ExcelFile
    PDFFile -->|"preview/share"| Screens

    %% Click Events
    click Screens "https://github.com/surajpatel24-r/transfer_certificate_generator/tree/master/lib/screens/"
    click Main "https://github.com/surajpatel24-r/transfer_certificate_generator/blob/master/lib/main.dart"
    click DataController "https://github.com/surajpatel24-r/transfer_certificate_generator/blob/master/lib/service/data_controller.dart"
    click StudentModel "https://github.com/surajpatel24-r/transfer_certificate_generator/blob/master/lib/models/student.dart"
    click UserModel "https://github.com/surajpatel24-r/transfer_certificate_generator/blob/master/lib/models/user.dart"
    click DataStore "https://github.com/surajpatel24-r/transfer_certificate_generator/blob/master/lib/service/data_store.dart"
    click SheetsAPI "https://github.com/surajpatel24-r/transfer_certificate_generator/blob/master/lib/api/sheets/tc_sheets_api.dart"
    click Template1 "https://github.com/surajpatel24-r/transfer_certificate_generator/blob/master/lib/templates/template_1.dart"
    click Template2 "https://github.com/surajpatel24-r/transfer_certificate_generator/blob/master/lib/templates/template_2.dart"
    click Template3 "https://github.com/surajpatel24-r/transfer_certificate_generator/blob/master/lib/templates/template_3.dart"
    click Android "https://github.com/surajpatel24-r/transfer_certificate_generator/tree/master/android/"
    click iOS "https://github.com/surajpatel24-r/transfer_certificate_generator/tree/master/ios/"
    click Linux "https://github.com/surajpatel24-r/transfer_certificate_generator/tree/master/linux/"
    click macOS "https://github.com/surajpatel24-r/transfer_certificate_generator/tree/master/macos/"
    click Windows "https://github.com/surajpatel24-r/transfer_certificate_generator/tree/master/windows/"
    click Web "https://github.com/surajpatel24-r/transfer_certificate_generator/tree/master/web/"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef logic fill:#90EE90,stroke:#000,stroke-width:1px
    classDef data fill:#FFFFE0,stroke:#000,stroke-width:1px
    classDef templ fill:#DDA0DD,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
    classDef platform fill:#D3D3D3,stroke:#000,stroke-width:1px
```
