# rparit-stacks/formfree architecture

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

- Interactive diagram: https://gitdiagram.com/rparit-stacks/formfree
- Repository: https://github.com/rparit-stacks/formfree

## Overview

##### Project Type and Purpose
- This is a Spring Boot–based REST API (“FormFree”) for dynamic form creation and submission.
- Key capabilities: project creation (with API key), form submission, submission retrieval, and health checking.

##### Main Architectural Layers (Left to Right)
- FormController
– POST /api/create-project
– POST /api/form/submit/{apiKey}
– GET /api/form/result/{projectId}
- Health
– GET /api/health
- FormService
– Handles business logic for creating projects, validating API keys, processing submissions, retrieving results.
- ProjectRepository (CRUD on Project entities)
- SubmissionsRepository (CRUD on FromSubmission entities)
- Underlying relational database (e.g., H2, MySQL, PostgreSQL) used by Spring Data JPA

##### Optional/Supporting Components
– Projects.java
– FromSubmission.java
- DTOs (Data Transfer Objects)
– e.g., ProjectCreationRequest, FormSubmissionRequest, ProjectResponse
– @ControllerAdvice class to catch validation errors, invalid API key, not found errors

1. Client → Controller: HTTP request
2. Controller → Service: call business method
3. Service → Repository: save or fetch data
4. Repository → Database: SQL operations
5. Database → Repository → Service → Controller → Client: response path
6. On errors: Service throws exception → Exception Handler intercepts → Controller returns error response

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Controllers Layer
    subgraph "Controllers" 
        direction TB
        FController["FormController\nPOST /api/create-project\nPOST /api/form/submit/{apiKey}\nGET /api/form/result/{projectId}"]:::controller
        Health["HealthController\nGET /api/health"]:::controller
    end

    %% DTOs & Models Layer
    subgraph "DTOs & Models"
        direction TB
        DTOs["DTOs\n(ProjectCreationRequest,\nFormSubmissionRequest,\nProjectResponse)"]:::dto
        Projects["Projects"]:::model
        FromSubmission["FromSubmission"]:::model
    end

    %% Services Layer
    subgraph "Services"
        direction TB
        FormService["FormService"]:::service
    end

    %% Repositories Layer
    subgraph "Repositories"
        direction TB
        ProjectRepo["ProjectRepository\nimplements JpaRepository"]:::repo
        SubsRepo["SubmissionsRepository\nimplements JpaRepository"]:::repo
    end

    %% Database Layer
    DB[(Relational Database)]:::database

    %% Exception Handling
    ExceptionHandler["ExceptionHandler"]:::error

    %% Other Components
    subgraph "Other"
        direction TB
        App["FormFreeApplication"]:::app
        Config["application.properties"]:::config
        Tests["FormFreeApplicationTests"]:::test
    end

    %% Connections
    FController -->|uses DTOs| DTOs
    DTOs -->|to Service| FormService
    FController -->|calls service| FormService
    Health -->|returns status| Health
    FormService -->|"save/find"| ProjectRepo
    FormService -->|"save/find"| SubsRepo
    ProjectRepo -->|"CRUD operations"| DB
    SubsRepo -->|"CRUD operations"| DB
    FormService -->|manages entities| Projects
    FormService -->|manages entities| FromSubmission
    ExceptionHandler -.->|handles errors| FController

    %% Click Events
    click FController "https://github.com/rparit-stacks/formfree/blob/main/src/main/java/com/form/free/formfree/controller/FormController.java"
    click Health "https://github.com/rparit-stacks/formfree/blob/main/src/main/java/com/form/free/formfree/controller/Health.java"
    click FormService "https://github.com/rparit-stacks/formfree/blob/main/src/main/java/com/form/free/formfree/service/FormService.java"
    click ProjectRepo "https://github.com/rparit-stacks/formfree/blob/main/src/main/java/com/form/free/formfree/repository/ProjectRepository.java"
    click SubsRepo "https://github.com/rparit-stacks/formfree/blob/main/src/main/java/com/form/free/formfree/repository/SubmissionsRepository.java"
    click Projects "https://github.com/rparit-stacks/formfree/blob/main/src/main/java/com/form/free/formfree/model/Projects.java"
    click FromSubmission "https://github.com/rparit-stacks/formfree/blob/main/src/main/java/com/form/free/formfree/model/FromSubmission.java"
    click App "https://github.com/rparit-stacks/formfree/blob/main/src/main/java/com/form/free/formfree/FormFreeApplication.java"
    click Config "https://github.com/rparit-stacks/formfree/blob/main/src/main/resources/application.properties"
    click Tests "https://github.com/rparit-stacks/formfree/blob/main/src/test/java/com/form/free/formfree/FormFreeApplicationTests.java"

    %% Styles
    classDef controller fill:#D6E9FF,stroke:#0000FF,color:#000
    classDef service fill:#D5F5E3,stroke:#27AE60,color:#000
    classDef repo fill:#FDEBD0,stroke:#E67E22,color:#000
    classDef database fill:#E5E7E9,stroke:#95A5A6,stroke-width:2px,color:#000
    classDef dto fill:#E8F8F5,stroke:#1ABC9C,color:#000
    classDef model fill:#D6EAF8,stroke:#3498DB,color:#000
    classDef error fill:#FADBD8,stroke:#E74C3C,stroke-width:2px,color:#000
    classDef app fill:#F9E79F,stroke:#F1C40F,color:#000
    classDef config fill:#F5EEF8,stroke:#8E44AD,color:#000
    classDef test fill:#FCF3CF,stroke:#B7950B,color:#000
```
