# avaibhav54/examportalspringboot architecture

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

- Interactive diagram: https://gitdiagram.com/avaibhav54/examportalspringboot
- Repository: https://github.com/avaibhav54/examportalspringboot

## Overview

##### Project type and purpose
- From the README and file tree, this is a full-stack Exam Portal application. It uses:
- Angular for the frontend UI (mentioned in README, not in Java code tree)
- Spring Boot for the backend REST API (src/main/java/com/exam/…)
- MySQL for persistence (entities and Spring Data JPA repositories)
- JWT for authentication/authorization

##### File structure
- Top-level:
- .mvn, mvnw, pom.xml → Maven wrapper and build config
- src/main/java/com/exam/... → backend code by package:
– config (JWT filter, entry point, security config, utilities)
– controller (REST endpoints by resource: Authenticate, Category, Quiz, Question, Result, User)
– model (domain objects: User/Role/Authority, DTOs for JWT, exam entities under model/exams, userRole)
– repo (Spring Data JPA interfaces for persistence)
– services & services/implement (service interfaces and their @Service implementations)
- src/main/resources/application.properties → Spring Boot config (DB URL, JWT secrets, etc.)
- src/test/java/... → unit/integration tests
- The “bin” directory duplicates the Maven project—this can be ignored or treated as sample/demo.

##### Key architectural patterns & design principles
- Layered (Controller → Service → Repository → Database)
- MVC-style separation for HTTP handling and business logic
- JWT-based stateless authentication filter inserted in the security filter chain
- Use of Spring Data JPA for ORM, reducing boilerplate DAOs

##### Main components and relationships
a. Components to include:
1) Angular Frontend (Browser SPA)
- UI modules: Admin portal, Student portal
- HTTP client for calling REST endpoints
2) Spring Boot Backend
- Controllers (REST API layer)
- Security Layer (JWTAuthenticationFilter, JWTAuthenticationEntryPoint, mySecurityConfig)
- Service Layer (CategoryService, QuizService, QuestionService, ResultService, UserService, UserDetailsService)
- Repository Layer (CategoryRepository, QuizRepository, QuestionRepository, ResultRepository, RoleRepository, UserRepository)
3) MySQL Database
4) External components (optional):
- Token Store (in-memory or DB for revoked tokens)
- CDN or File Storage (for any media attachments in questions)
b. Interactions and data flows:
- User interacts with Angular UI → Angular issues HTTP requests (with JWT in header) →
- Spring Security filter chain intercepts → JWTAuthenticationFilter validates token →
- Controller receives authenticated request → delegates to Service → Service calls Repository →
- Repository queries/upserts MySQL → Service returns domain to Controller →
- Controller serializes JSON back to Angular → Angular updates the UI
c. Architectural patterns:
- Layered design (API, business logic, persistence)
- Stateless authentication with JWT (no session)
- Use of DTOs (JWTRequest, JWTResponse) for decoupling domain entities from REST payloads
d. Technologies/Frameworks:
- Angular (TypeScript, RxJS, Angular Router)
- Spring Boot (Spring MVC, Spring Security, Spring Data JPA, Jackson)
- MySQL (InnoDB)
- Maven (build), JWT (jjwt or spring-security-oauth)

##### Detail without overcomplicating
- Tier (UI, API, BL, persistence) distinctly
- JWT flow in the security layer
- Avoid drawing every single method; group by package/layer

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend
    Angular["Angular SPA\n(Admin Portal, Student Portal, Auth Module)"]:::frontend

    %% Backend Application Entry
    ExamApp["ExamPortalApplication"]:::backend
    click ExamApp "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/ExamPortalApplication.java"

    %% Security Layer
    subgraph "Security Layer"
        JWTFilter["JWTAuthenticationFilter"]:::security
        click JWTFilter "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/config/JWTAuthenticationFilter.java"
        JWTEntry["JWTAuthenticationEntryPoint"]:::security
        click JWTEntry "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/config/JWTAuthenticationEntryPoint.java"
        SecConfig["mySecurityConfig"]:::security
        click SecConfig "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/config/mySecurityConfig.java"
        Utils["javaUtils"]:::security
        click Utils "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/config/javaUtils.java"
    end

    %% Controller Layer
    subgraph "Controller Layer"
        AuthCtrl["AuthenticateController"]:::controller
        click AuthCtrl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/controller/AuthenticateController.java"
        CatCtrl["CategoryController"]:::controller
        click CatCtrl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/controller/CategoryController.java"
        QuizCtrl["QuizController"]:::controller
        click QuizCtrl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/controller/QuizController.java"
        QuesCtrl["QuestionController"]:::controller
        click QuesCtrl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/controller/QuestionController.java"
        ResCtrl["ResultController"]:::controller
        click ResCtrl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/controller/ResultController.java"
        UserCtrl["userController"]:::controller
        click UserCtrl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/controller/userController.java"
    end

    %% Service Layer
    subgraph "Service Layer"
        subgraph "Interfaces"
            CatSvc["CategoryService"]:::service
            click CatSvc "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/CategoryService.java"
            QuizSvc["QuizService"]:::service
            click QuizSvc "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/QuizService.java"
            QuesSvc["QuestionService"]:::service
            click QuesSvc "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/QuestionService.java"
            ResSvc["ResultService"]:::service
            click ResSvc "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/ResultService.java"
            UserSvc["UserService"]:::service
            click UserSvc "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/UserService.java"
        end
        subgraph "Implementations"
            CatSvcImpl["CategoryServiceImpl"]:::service
            click CatSvcImpl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/implement/CategoryServiceImpl.java"
            QuizSvcImpl["QuizServiceImpl"]:::service
            click QuizSvcImpl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/implement/QuizServiceImpl.java"
            QuesSvcImpl["QuestionServiceImpl"]:::service
            click QuesSvcImpl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/implement/QuestionServiceImpl.java"
            ResSvcImpl["ResultServiceImpl"]:::service
            click ResSvcImpl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/implement/ResultServiceImpl.java"
            UserDetailsImpl["userDetailServiceImpl"]:::service
            click UserDetailsImpl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/implement/userDetailServiceImpl.java"
            UserSvcImpl["userServiceImpl"]:::service
            click UserSvcImpl "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/services/implement/userServiceImpl.java"
        end
    end

    %% Repository Layer
    subgraph "Repository Layer"
        CatRepo["CategoryRepository"]:::repository
        click CatRepo "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/repo/CategoryRepository.java"
        QuizRepo["QuizRepository"]:::repository
        click QuizRepo "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/repo/QuizRepository.java"
        QuesRepo["QuestionRepository"]:::repository
        click QuesRepo "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/repo/QuestionRepository.java"
        ResRepo["ResultRepository"]:::repository
        click ResRepo "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/repo/ResultRepository.java"
        RoleRepo["roleRepository"]:::repository
        click RoleRepo "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/repo/roleRepository.java"
        UserRepo["userRepository"]:::repository
        click UserRepo "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/java/com/exam/repo/userRepository.java"
    end

    %% Database
    MySQL["MySQL Database\n(Entities: User, Role, Authority, Category, Quiz, Question, Result)"]:::database
    click MySQL "https://github.com/avaibhav54/examportalspringboot/blob/master/src/main/resources/application.properties"

    %% Flows
    Angular -->|1: Login/Requests with JWT| JWTFilter
    JWTFilter -->|Validate Token| JWTEntry
    JWTFilter --> ExamApp
    ExamApp --> AuthCtrl
    ExamApp --> CatCtrl
    ExamApp --> QuizCtrl
    ExamApp --> QuesCtrl
    ExamApp --> ResCtrl
    ExamApp --> UserCtrl

    AuthCtrl -->|"calls"| CatSvc
    AuthCtrl -->|"calls"| UserSvc

    CatCtrl -->|"calls"| CatSvc
    QuizCtrl -->|"calls"| QuizSvc
    QuesCtrl -->|"calls"| QuesSvc
    ResCtrl -->|"calls"| ResSvc
    UserCtrl -->|"calls"| UserSvc

    CatSvc --> CatSvcImpl
    QuizSvc --> QuizSvcImpl
    QuesSvc --> QuesSvcImpl
    ResSvc --> ResSvcImpl
    UserSvc --> UserSvcImpl
    UserSvc --> UserDetailsImpl

    CatSvcImpl --> CatRepo
    QuizSvcImpl --> QuizRepo
    QuesSvcImpl --> QuesRepo
    ResSvcImpl --> ResRepo
    UserSvcImpl --> UserRepo

    CatRepo --> MySQL
    QuizRepo --> MySQL
    QuesRepo --> MySQL
    ResRepo --> MySQL
    RoleRepo --> MySQL
    UserRepo --> MySQL

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#000,stroke-width:1px
    classDef security fill:#FFC0CB,stroke:#f00,stroke-width:2px
    classDef controller fill:#98FB98,stroke:#000,stroke-width:1px
    classDef service fill:#E0FFE0,stroke:#000,stroke-width:1px
    classDef repository fill:#E0FFE0,stroke:#000,stroke-width:1px
    classDef database fill:#FFA500,stroke:#000,stroke-width:1px
```
