# santosh4568/online-fir-system architecture

> Architecture diagram of the GitHub repository santosh4568/online-fir-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/santosh4568/online-fir-system
- Repository: https://github.com/santosh4568/online-fir-system

## Overview

##### Project type and purpose
- This is a full-stack web application called **JusticeNet – Online FIR System**.
- The **frontend** folder contains a React/Vite Single-Page Application for user interactions (registration, login, filing & tracking FIRs).
- The **backend** is a Spring Boot MVC application (with Thymeleaf templates and REST controllers) that handles business logic, security, and data persistence.

##### File structure
- Top-level:
- Dockerfile – containerization
- pom.xml / .mvn – Maven build for the backend
- frontend/ – React SPA code (package.json, Vite config, src/components, src/pages)
- Backend (src/main/java/com/example/Online_FIR_System):
- Controller – Spring MVC controllers (UserController, error handlers)
- Model – JPA entities (User, FIR, ComplaintStatus, Role)
- Repository – Spring Data JPA interfaces for CRUD
- Services – business logic wrapping repositories
- config – WebConfig (CORS, view resolvers, static mapping)
- src/main/resources:
- application.properties – DB connection, JPA settings
- static/css & js – served assets
- templates – Thymeleaf views (login.html, home.html, officerHome.html, reports, etc.)
- Tests under src/test to verify application context and endpoints.

##### Key insights from README
- Core features for Users and Officers, with separate registration flows
- Spring Security + BCrypt for authentication/authorization
- MySQL as the persistent store
- MVC layering: Controllers → Services → Repositories → Database

##### Details
- **User vs. Officer flows** if space allows, showing role-based decisions in Spring Security.
- **ComplaintStatus** flow: filing → status update → tracking.
- Call out the **WebConfig** as enabling CORS if the React app is hosted separately.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser (User/Officer)"]:::external
    Browser -->|"loads SPA"| ReactSPA["React Frontend (SPA)"]:::frontend
    click ReactSPA "https://github.com/santosh4568/online-fir-system/tree/main/frontend/"
    ReactSPA -->|"HTTP/HTTPS"| Security

    subgraph "Docker Container"
        Application["OnlineFirSystemApplication"]:::backend
        click Application "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/OnlineFirSystemApplication.java"
        Security["Spring Security"]:::presentation
        WebConfig["WebConfig"]:::presentation
        click WebConfig "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/config/WebConfig.java"

        subgraph "Presentation Layer"
            UserController["UserController"] 
            click UserController "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Controller/UserController.java"
            ErrorController["Error"] 
            click ErrorController "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Controller/Error.java"
            Templates["Thymeleaf Templates"] 
            click Templates "https://github.com/santosh4568/online-fir-system/tree/main/src/main/resources/templates/"
            StaticAssets["Static Assets"] 
            click StaticAssets "https://github.com/santosh4568/online-fir-system/tree/main/src/main/resources/static/"
        end

        subgraph "Service Layer"
            UserService["UserService"]
            click UserService "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Services/UserService.java"
            FirService["FirService"]
            click FirService "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Services/FirService.java"
            ComplaintStatusService["ComplaintStatusService"]
            click ComplaintStatusService "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Services/ComplaintStatusService.java"
        end

        subgraph "Repository Layer"
            UserRepo["UserRepository"]
            click UserRepo "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Repository/UserRepository.java"
            FirRepo["FirRepository"]
            click FirRepo "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Repository/FirRepository.java"
            ComplaintStatusRepo["ComplaintStatusRepository"]
            click ComplaintStatusRepo "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Repository/ComplaintStatusRepository.java"
        end

        subgraph "Domain Models"
            UserModel["User"]
            click UserModel "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Model/User.java"
            FIRModel["FIR"]
            click FIRModel "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Model/FIR.java"
            ComplaintStatusModel["ComplaintStatus"]
            click ComplaintStatusModel "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Model/ComplaintStatus.java"
            RoleModel["Role"]
            click RoleModel "https://github.com/santosh4568/online-fir-system/blob/main/src/main/java/com/example/Online_FIR_System/Model/Role.java"
        end

        Application --> Security
        Application --> WebConfig
        Application --> UserController
        Application --> Templates
        Application --> StaticAssets

        Security -->|"auth filter"| UserController
        UserController -->|"calls"| UserService
        UserController -->|"calls"| FirService
        UserController -->|"calls"| ComplaintStatusService

        UserService -->|"uses"| UserRepo
        FirService -->|"uses"| FirRepo
        ComplaintStatusService -->|"uses"| ComplaintStatusRepo

        UserRepo -->|"JPA/Hibernate"| UserModel
        FirRepo -->|"JPA/Hibernate"| FIRModel
        ComplaintStatusRepo -->|"JPA/Hibernate"| ComplaintStatusModel

        UserRepo -->|"SQL"| Database["MySQL Database"]:::database
        FirRepo -->|"SQL"| Database
        ComplaintStatusRepo -->|"SQL"| Database

        Config["application.properties"]:::presentation
        click Config "https://github.com/santosh4568/online-fir-system/blob/main/src/main/resources/application.properties"
        Pom["pom.xml"]:::infra
        click Pom "https://github.com/santosh4568/online-fir-system/blob/main/pom.xml"
        Dockerfile["Dockerfile"]:::infra
        click Dockerfile "https://github.com/santosh4568/online-fir-system/tree/main/Dockerfile"
        MVN[".mvn"]:::infra
        click MVN "https://github.com/santosh4568/online-fir-system/tree/main/.mvn/"

        Config -.-> Database
        Pom -.-> Application
        MVN -.-> Application
        Dockerfile -.-> Application
    end

    classDef frontend fill:#D0E8FF,stroke:#003366,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#000000,stroke-width:1px
    classDef backend fill:#E8F8D0,stroke:#336600,stroke-width:1px
    classDef presentation fill:#D5F5E3,stroke:#229954,stroke-width:1px
    classDef business fill:#FCF3CF,stroke:#B7950B,stroke-width:1px
    classDef data fill:#FADBD8,stroke:#C0392B,stroke-width:1px
    classDef database fill:#F2F3F4,stroke:#7B7D7D,stroke-width:1px,stroke-dasharray:5 5
    classDef infra fill:#FDF2E9,stroke:#BA4A00,stroke-width:1px
```
