# alegria825/forms_app architecture

> Architecture diagram of the GitHub repository alegria825/forms_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/alegria825/forms_app
- Repository: https://github.com/alegria825/forms_app

## Overview

1. This is a Flutter cross-platform client app. The same Dart codebase targets Android, iOS, web, Windows, macOS, and Linux, with platform-specific runner shells present under each folder.

2. The app entrypoint is `lib/main.dart`, which likely wires up the root widget, Firebase initialization, routing, and theming. The presence of `lib/firebase_options.dart` indicates Firebase was configured via FlutterFire.

3. The repository is organized in a layered style:
   - `domain` contains business abstractions and entities.
   - `infrastructure` contains concrete implementations and input validation models.
   - `presentation` contains UI screens, widgets, and BLoC/Cubit state management.
   - `Config` contains app-wide routing and theme setup.

4. The domain layer defines the core authentication contract. `lib/domain/datasources/auth_datasource.dart` and `lib/domain/repositories/auth_repository.dart` describe the interfaces, while `lib/domain/entities/user.dart` models the user concept used by the app.

5. The infrastructure layer provides the Firebase-backed implementation. `lib/infrastructure/datasources/firebase_auth_datasource.dart` is the main integration point with Firebase Auth, and `lib/infrastructure/repositories/auth_repository_impl.dart` adapts that datasource to the domain repository interface.

6. Input validation is separated into small value-object style classes under `lib/infrastructure/inputs/` such as `email.dart`, `password.dart`, `username.dart`, `lastname.dart`, and `enrollment.dart`. These are used to validate and normalize form fields before they reach the auth flow.

7. Presentation is driven by BLoC/Cubit state management. There are example counter flows (`counter_bloc`, `counter_cubit`) and a registration flow (`register_cubit`). This suggests the app uses reactive state boundaries between UI and business logic rather than directly calling infrastructure from widgets.

8. The main product screens appear to be authentication/registration and role-based home screens:
   - `student_register_screen.dart`
   - `teacher_register_screen.dart`
   - `home_student_screen.dart`
   - `home_teacher_screen.dart`
   - `classroom_teacher.dart`
   There is also a generic `home_screen.dart`, likely used as a landing or role selector page.

9. Shared UI building blocks live under `lib/presentation/widgets/`, including custom text fields and filled buttons. These are the form composition layer that sits above the input validators and register cubit.

10. Routing and visual styling are centralized:
   - `lib/Config/router/app_router.dart` defines navigation structure.
   - `lib/Config/theme/app_theme.dart` defines the app theme.
   These are the main app-wide composition points outside feature code.

11. The Android, iOS, macOS, Linux, Windows, and web folders are standard Flutter host projects. They mostly contain generated or platform bootstrap code, asset manifests, app icons, splash screens, and native launch configuration, not independent business logic.

12. There are no visible server components or custom backend services in this repository. The main external dependency affecting architecture is Firebase Auth, with the app acting as a client-side front end layered over that service.

13. From an architecture-diagram perspective, the core data flow is: UI screens and form widgets → Cubit/BLoC → domain repository interface → Firebase-backed datasource → Firebase Auth. The reverse flow carries user/auth state back up to update the presentation layer.

14. The presence of counter example modules alongside auth/register screens suggests this repo is partly a template/demo Flutter app and partly an app-specific authentication/role-management implementation.

Main entry points: [`lib/main.dart`](https://github.com/alegria825/forms_app/blob/master/lib/main.dart) (Main), [`lib/presentation/screens/screens.dart`](https://github.com/alegria825/forms_app/blob/master/lib/presentation/screens/screens.dart) (Screens), [`lib/presentation/blocs/register_cubit/register_cubit.dart`](https://github.com/alegria825/forms_app/blob/master/lib/presentation/blocs/register_cubit/register_cubit.dart) (Register cubit), [`lib/domain/repositories/auth_repository.dart`](https://github.com/alegria825/forms_app/blob/master/lib/domain/repositories/auth_repository.dart) (Auth repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core app"]
  node_main["Main<br/>Flutter entrypoint<br/>[main.dart]"]
  node_firebase_options["Firebase opts<br/>FlutterFire config"]
  node_app_router["Router<br/>navigation config<br/>[app_router.dart]"]
  node_app_theme["Theme<br/>visual config<br/>[app_theme.dart]"]
end

subgraph group_domain["Domain"]
  node_auth_ds_iface["Auth datasource<br/>domain interface"]
  node_auth_repo_iface["Auth repository<br/>domain interface"]
  node_user_entity(("User<br/>domain entity<br/>[user.dart]"))
end

subgraph group_infra["Infrastructure"]
  node_firebase_auth_ds["Firebase auth<br/>datasource impl"]
  node_auth_repo_impl["Auth repo impl<br/>repository impl"]
  node_inputs["Inputs<br/>validation models<br/>[inputs.dart]"]
end

subgraph group_presentation["Presentation"]
  node_register_cubit["Register cubit<br/>state controller"]
  node_counter_bloc["Counter bloc<br/>demo state<br/>[counter_bloc.dart]"]
  node_counter_cubit["Counter cubit<br/>demo state<br/>[counter_cubit.dart]"]
  node_screens["Screens<br/>[screens.dart]"]
  node_widgets["Widgets<br/>ui components<br/>[widgets.dart]"]
end

subgraph group_platform["Platform shells"]
  node_android["Android<br/>platform shell"]
  node_ios["iOS<br/>platform shell"]
  node_web["Web<br/>platform shell"]
  node_windows["Windows<br/>platform shell"]
  node_macos["macOS<br/>platform shell"]
  node_linux["Linux<br/>platform shell"]
end

node_main -->|"configures"| node_firebase_options
node_main -->|"wires"| node_app_router
node_main -->|"applies"| node_app_theme
node_main -->|"hosts"| node_screens
node_auth_repo_iface -.->|"depends on"| node_auth_ds_iface
node_auth_repo_impl -->|"implements"| node_auth_repo_iface
node_auth_repo_impl -->|"wraps"| node_firebase_auth_ds
node_firebase_auth_ds -->|"uses"| node_firebase_options
node_register_cubit -->|"calls"| node_auth_repo_iface
node_register_cubit -->|"validates"| node_inputs
node_register_cubit -->|"emits"| node_user_entity
node_screens -->|"drives"| node_register_cubit
node_screens -.->|"shows"| node_counter_bloc
node_screens -.->|"shows"| node_counter_cubit
node_screens -->|"composes"| node_widgets
node_widgets -.->|"supports"| node_inputs
node_android -.->|"boots"| node_main
node_ios -.->|"boots"| node_main
node_web -.->|"boots"| node_main
node_windows -.->|"boots"| node_main
node_macos -.->|"boots"| node_main
node_linux -.->|"boots"| node_main

click node_main "https://github.com/alegria825/forms_app/blob/master/lib/main.dart"
click node_firebase_options "https://github.com/alegria825/forms_app/blob/master/lib/firebase_options.dart"
click node_app_router "https://github.com/alegria825/forms_app/blob/master/lib/Config/router/app_router.dart"
click node_app_theme "https://github.com/alegria825/forms_app/blob/master/lib/Config/theme/app_theme.dart"
click node_auth_ds_iface "https://github.com/alegria825/forms_app/blob/master/lib/domain/datasources/auth_datasource.dart"
click node_auth_repo_iface "https://github.com/alegria825/forms_app/blob/master/lib/domain/repositories/auth_repository.dart"
click node_user_entity "https://github.com/alegria825/forms_app/blob/master/lib/domain/entities/user.dart"
click node_firebase_auth_ds "https://github.com/alegria825/forms_app/blob/master/lib/infrastructure/datasources/firebase_auth_datasource.dart"
click node_auth_repo_impl "https://github.com/alegria825/forms_app/blob/master/lib/infrastructure/repositories/auth_repository_impl.dart"
click node_inputs "https://github.com/alegria825/forms_app/blob/master/lib/infrastructure/inputs/inputs.dart"
click node_register_cubit "https://github.com/alegria825/forms_app/blob/master/lib/presentation/blocs/register_cubit/register_cubit.dart"
click node_counter_bloc "https://github.com/alegria825/forms_app/blob/master/lib/presentation/blocs/counter_bloc/counter_bloc.dart"
click node_counter_cubit "https://github.com/alegria825/forms_app/blob/master/lib/presentation/blocs/counter_cubit/counter_cubit.dart"
click node_screens "https://github.com/alegria825/forms_app/blob/master/lib/presentation/screens/screens.dart"
click node_widgets "https://github.com/alegria825/forms_app/blob/master/lib/presentation/widgets/widgets.dart"
click node_android "https://github.com/alegria825/forms_app/tree/master/android"
click node_ios "https://github.com/alegria825/forms_app/tree/master/ios"
click node_web "https://github.com/alegria825/forms_app/tree/master/web"
click node_windows "https://github.com/alegria825/forms_app/tree/master/windows"
click node_macos "https://github.com/alegria825/forms_app/tree/master/macos"
click node_linux "https://github.com/alegria825/forms_app/tree/master/linux"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_firebase_options,node_app_router,node_app_theme toneBlue
class node_auth_ds_iface,node_auth_repo_iface,node_user_entity toneAmber
class node_firebase_auth_ds,node_auth_repo_impl,node_inputs toneMint
class node_register_cubit,node_counter_bloc,node_counter_cubit,node_screens,node_widgets toneRose
class node_android,node_ios,node_web,node_windows,node_macos,node_linux toneIndigo
```

## Components

### Core app

Shared Dart application code and composition points

- [Main](https://github.com/alegria825/forms_app/blob/master/lib/main.dart): Flutter entrypoint · Bootstraps the app, Firebase, routing, and theme · `lib/main.dart`
- [Firebase opts](https://github.com/alegria825/forms_app/blob/master/lib/firebase_options.dart): FlutterFire config · Generated Firebase configuration for the client app · `lib/firebase_options.dart`
- [Router](https://github.com/alegria825/forms_app/blob/master/lib/Config/router/app_router.dart): navigation config · Defines app routes and navigation structure · `lib/Config/router/app_router.dart`
- [Theme](https://github.com/alegria825/forms_app/blob/master/lib/Config/theme/app_theme.dart): visual config · Centralized app styling and theme setup · `lib/Config/theme/app_theme.dart`

### Domain

Business contracts and entities

- [Auth datasource](https://github.com/alegria825/forms_app/blob/master/lib/domain/datasources/auth_datasource.dart): domain interface · Abstract auth data source contract · `lib/domain/datasources/auth_datasource.dart`
- [Auth repository](https://github.com/alegria825/forms_app/blob/master/lib/domain/repositories/auth_repository.dart): domain interface · Repository contract used by the app for authentication flows · `lib/domain/repositories/auth_repository.dart`
- [User](https://github.com/alegria825/forms_app/blob/master/lib/domain/entities/user.dart): domain entity · Core user model shared across layers · `lib/domain/entities/user.dart`

### Infrastructure

Firebase integration and input validation

- [Firebase auth](https://github.com/alegria825/forms_app/blob/master/lib/infrastructure/datasources/firebase_auth_datasource.dart): datasource impl · Firebase Auth-backed datasource · `lib/infrastructure/datasources/firebase_auth_datasource.dart`
- [Auth repo impl](https://github.com/alegria825/forms_app/blob/master/lib/infrastructure/repositories/auth_repository_impl.dart): repository impl · Adapts Firebase datasource to the domain repository · `lib/infrastructure/repositories/auth_repository_impl.dart`
- [Inputs](https://github.com/alegria825/forms_app/blob/master/lib/infrastructure/inputs/inputs.dart): validation models · Value-object style field validation and normalization · `lib/infrastructure/inputs/inputs.dart`

### Presentation

State management, screens, and reusable UI

- [Register cubit](https://github.com/alegria825/forms_app/blob/master/lib/presentation/blocs/register_cubit/register_cubit.dart): state controller · Reactive controller for registration and auth form flow · `lib/presentation/blocs/register_cubit/register_cubit.dart`
- [Counter bloc](https://github.com/alegria825/forms_app/blob/master/lib/presentation/blocs/counter_bloc/counter_bloc.dart): demo state · Example BLoC counter flow · `lib/presentation/blocs/counter_bloc/counter_bloc.dart`
- [Counter cubit](https://github.com/alegria825/forms_app/blob/master/lib/presentation/blocs/counter_cubit/counter_cubit.dart): demo state · Example Cubit counter flow · `lib/presentation/blocs/counter_cubit/counter_cubit.dart`
- [Screens](https://github.com/alegria825/forms_app/blob/master/lib/presentation/screens/screens.dart): ui screens · Auth, home, role, and demo screens · `lib/presentation/screens/screens.dart`
- [Widgets](https://github.com/alegria825/forms_app/blob/master/lib/presentation/widgets/widgets.dart): ui components · Shared form fields and buttons · `lib/presentation/widgets/widgets.dart`

### Platform shells

Native runner projects for each target

- [Android](https://github.com/alegria825/forms_app/tree/master/android): platform shell · Android host project and launcher · `android`
- [iOS](https://github.com/alegria825/forms_app/tree/master/ios): platform shell · iOS host project and launcher · `ios`
- [Web](https://github.com/alegria825/forms_app/tree/master/web): platform shell · Web entry shell and manifest · `web`
- [Windows](https://github.com/alegria825/forms_app/tree/master/windows): platform shell · Windows host project and runner · `windows`
- [macOS](https://github.com/alegria825/forms_app/tree/master/macos): platform shell · macOS host project and runner · `macos`
- [Linux](https://github.com/alegria825/forms_app/tree/master/linux): platform shell · Linux host project and runner · `linux`

## Connections

- Main → Firebase opts: configures · Uses generated Firebase settings during startup
- Main → Router: wires · Installs routing into the root app
- Main → Theme: applies · Uses the centralized theme configuration
- Main → Screens: hosts · Launches the top-level UI flow
- Auth repository → Auth datasource: depends on · Repository contract is backed by datasource contract
- Auth repo impl → Auth repository: implements · Concrete repository follows the domain contract
- Auth repo impl → Firebase auth: wraps · Delegates auth operations to Firebase
- Firebase auth → Firebase opts: uses · Reads Firebase app configuration
- Register cubit → Auth repository: calls · Uses the domain repository to execute registration and auth actions
- Register cubit → Inputs: validates · Consumes input value objects for form validation
- Register cubit → User: emits · Transforms auth results into user state
- Screens → Register cubit: drives · Screens bind to cubit state and events
- Screens → Counter bloc: shows · Includes BLoC counter demo screen flow
- Screens → Counter cubit: shows · Includes Cubit counter demo screen flow
- Screens → Widgets: composes · Builds forms from shared UI controls
- Widgets → Inputs: supports · Text fields pair with validation models
- Android → Main: boots · Native launcher starts the Dart app
- iOS → Main: boots · Native launcher starts the Dart app
- Web → Main: boots · Browser shell loads the Dart app
- Windows → Main: boots · Desktop launcher starts the Dart app
- macOS → Main: boots · Desktop launcher starts the Dart app
- Linux → Main: boots · Desktop launcher starts the Dart app
