# binary-ho/imhere-server architecture

> Architecture diagram of the GitHub repository binary-ho/imhere-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/binary-ho/imhere-server
- Repository: https://github.com/binary-ho/imhere-server

## Overview

##### Main Components

a. Client Layer:
- React Frontend Application (hosted on CloudFront/S3)
- Separation between development and production environments

b. API Gateway/Load Balancer:
- Nginx reverse proxy handling HTTPS
- SSL termination point

c. Application Servers:
- Spring Boot Application (show both dev and prod instances)
- Core Modules:
- Authentication/Security Module
- Attendance Management
- Lecture Management
- Enrollment Management
- Member Management

d. Data Stores:
- PostgreSQL RDS (primary database)
- Redis Cache (for attendance and lecture data)

e. External Services:
- Email Service (JavaMailSender)
- Discord (for monitoring alerts)

##### Key Relationships to Highlight

a. Data Flow Patterns:
- Client → Nginx → Application Server
- Authentication flow with JWT tokens
- Cache access patterns for attendance
- Email verification flow
- Real-time attendance tracking flow

b. Caching Strategy:
- Redis caching layer for:
- Attendance history
- Open lecture information
- Verification codes
- Attendee information

##### Specific Implementation Details

a. Security Layer:
- JWT Authentication/Authorization filters
- CORS configuration
- Role-based access control (Student/Lecturer)

b. Performance Optimizations:
- Redis caching for high-traffic attendance operations
- Database indexing for enrollment queries
- Asynchronous operations for email sending

##### Infrastructure Components

a. AWS Services:
- EC2 instances for application servers
- RDS for PostgreSQL
- CloudFront for frontend delivery
- S3 for static assets
- IAM for access management

##### Monitoring and Logging
- Log4j2 configuration
- Discord integration for alerts
- Performance monitoring points

##### Persistence Layer (Bottom)

Use these visual elements:

- Different types of connections
- Component types
- Environment separation (dev/prod)

##### The scalability aspects of the system

This will provide a clear visualization of how the system handles its core functionality of attendance management while maintaining security, performance, and scalability.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef aws fill:#2196F3,stroke:#1565C0,color:white
    classDef app fill:#4CAF50,stroke:#388E3C,color:white
    classDef cache fill:#FFC107,stroke:#FFA000,color:black
    classDef security fill:#F44336,stroke:#D32F2F,color:white
    classDef database fill:#795548,stroke:#5D4037,color:white
    classDef external fill:#9C27B0,stroke:#7B1FA2,color:white

    %% Client Layer
    subgraph ClientLayer
        CF["CloudFront/S3"]:::aws
        React["React Frontend"]:::app
    end

    %% Network Layer
    NGINX["NGINX Reverse Proxy"]:::security

    %% Application Layer
    subgraph AppLayer
        SpringBoot["Spring Boot Application"]:::app
        
        subgraph CoreModules
            Auth["Authentication Module"]:::security
            Attendance["Attendance Management"]:::app
            Lecture["Lecture Management"]:::app
            Enrollment["Enrollment Management"]:::app
            Member["Member Management"]:::app
        end

        subgraph SecurityComponents
            JWT["JWT Security"]:::security
            CORS["CORS Config"]:::security
            Filters["Security Filters"]:::security
        end
    end

    %% Cache Layer
    subgraph CacheLayer
        Redis["Redis Cache"]:::cache
        AttendanceCache["Attendance Cache"]:::cache
        LectureCache["Lecture Cache"]:::cache
        VerificationCache["Verification Cache"]:::cache
    end

    %% Data Layer
    RDS[(PostgreSQL RDS)]:::database

    %% External Services
    subgraph ExternalServices
        Email["Email Service"]:::external
        Discord["Discord Alerts"]:::external
    end

    %% Relationships
    CF --> React
    React --> NGINX
    NGINX --> SpringBoot
    SpringBoot --> Auth
    Auth --> JWT
    Auth --> CORS
    Auth --> Filters
    SpringBoot --> Attendance
    SpringBoot --> Lecture
    SpringBoot --> Enrollment
    SpringBoot --> Member
    
    Attendance --> Redis
    Lecture --> Redis
    Redis --> AttendanceCache
    Redis --> LectureCache
    Redis --> VerificationCache
    
    SpringBoot --> RDS
    SpringBoot --> Email
    SpringBoot --> Discord

    %% Click Events
    click Auth "https://github.com/binary-ho/imhere-server/tree/develop/src/main/java/gdsc/binaryho/imhere/security"
    click Attendance "https://github.com/binary-ho/imhere-server/tree/develop/src/main/java/gdsc/binaryho/imhere/core/attendance"
    click Lecture "https://github.com/binary-ho/imhere-server/tree/develop/src/main/java/gdsc/binaryho/imhere/core/lecture"
    click Enrollment "https://github.com/binary-ho/imhere-server/tree/develop/src/main/java/gdsc/binaryho/imhere/core/enrollment"
    click Member "https://github.com/binary-ho/imhere-server/tree/develop/src/main/java/gdsc/binaryho/imhere/core/member"
    click Redis "https://github.com/binary-ho/imhere-server/tree/develop/src/main/java/gdsc/binaryho/imhere/config/redis"
    click Email "https://github.com/binary-ho/imhere-server/blob/develop/src/main/java/gdsc/binaryho/imhere/config/JavaMailSenderConfig.java"
    click JWT "https://github.com/binary-ho/imhere-server/tree/develop/src/main/java/gdsc/binaryho/imhere/security/jwt"
    click CORS "https://github.com/binary-ho/imhere-server/blob/develop/src/main/java/gdsc/binaryho/imhere/security/config/CorsConfig.java"
    click Filters "https://github.com/binary-ho/imhere-server/blob/develop/src/main/java/gdsc/binaryho/imhere/security/filter/JwtAuthenticationFilter.java"
```
