# aliwoto/examsphere architecture

> Architecture diagram of the GitHub repository aliwoto/examsphere, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aliwoto/examsphere
- Repository: https://github.com/aliwoto/examsphere

## Overview

##### Main Components Identification
The system appears to be structured as a backend-heavy application with the following major components:

a. API Layer
- Handlers by domain (user, course, exam, topic, captcha)
- Swagger documentation integration
- Authentication/authorization flow

b. Core Services
- Application configuration management
- Value management
- Utility services (email, hashing, logging)

c. Database Layer
- SQL database with migrations
- Separate data models for users, courses, exams, and topics

d. UI Component
- Though currently minimal (empty .gitkeep), show as a planned frontend interface

**[Client Layer]**

- ▼
**[API Gateway/Router]**

- ┬─────────────────┬────────────────┐
- ▼                     ▼                 ▼                ▼
**[Auth Services]    [Exam Services]    [Course Services]  [Topic Services]**

- ┬─────────┴─────────┬───────┴────────┬──────┘

- ▼                    ▼                ▼
- [Core Services]      [Utility Services]  [Database Layer]

##### Component Details

For each major section, include:

a. API Layer (src/apiHandlers/*)
- Separate modules for different domains
- Swagger integration
- Authentication flow
- CAPTCHA integration

b. Core Services (src/core/*)
- Configuration management
- Application values
- Auto-completion utilities
- Email service with templates
- Hashing utilities
- Logging system

c. Database Layer (src/database/*)
- Migration system
- Separate models for different entities
- CRUD operations
- Relationship between entities

##### Interactions and Data Flow

Show:
- RESTful API communications
- Database transactions
- Email notifications
- Authentication flow
- Error logging paths

##### Technical Stack Indicators

Highlight:
- Go backend
- SQL database
- Email service integration
- Swagger documentation
- Configuration management

##### Notes for Implementation Details

Annotations for:
- Configuration requirements (config.sample.ini)
- Logging paths (logs/errors, logs/panics)
- Database migration scripts
- API documentation endpoints

Remember to include version control and CI/CD elements visible in the .github/workflows directory, showing the deployment pipeline from development to production.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        UI[UI Layer]:::frontend
    end

    subgraph API
        API[API Gateway/Router]:::api
        
        subgraph Handlers
            UH[User Handlers]:::api
            CH[Course Handlers]:::api
            EH[Exam Handlers]:::api
            TH[Topic Handlers]:::api
            CAP[CAPTCHA Handlers]:::api
            SW[Swagger Handlers]:::api
        end
    end

    subgraph Core
        subgraph ConfigServices
            CONF[Configuration Management]:::core
            VAL[Application Values]:::core
        end

        subgraph UtilityServices
            EM[Email Service]:::util
            HASH[Hashing Service]:::util
            LOG[Logging Service]:::util
            AUTO[Auto-completion Utils]:::util
        end
    end

    subgraph Database
        DB[(SQL Database)]:::db
        MIG[Migrations]:::db
        subgraph Models
            UM[User Models]:::db
            CM[Course Models]:::db
            EM_M[Exam Models]:::db
            TM[Topic Models]:::db
        end
    end

    subgraph EmailTemplates
        CONF_EMAIL[Account Confirmation]:::util
        PASS_EMAIL[Password Change]:::util
    end

    subgraph Logging
        ERR[Error Logs]:::util
        PAN[Panic Logs]:::util
    end

    MS[Master Server]:::core

    UI --> API
    API --> Handlers
    Handlers --> Core
    Core --> Database
    EM --> EmailTemplates
    LOG --> Logging
    MS --> API

    %% Component Mappings
    click UI "https://github.com/ALiwoto/ExamSphere/tree/master/ui/"
    click API "https://github.com/ALiwoto/ExamSphere/tree/master/src/apiHandlers/"
    click UH "https://github.com/ALiwoto/ExamSphere/tree/master/src/apiHandlers/userHandlers/"
    click CH "https://github.com/ALiwoto/ExamSphere/tree/master/src/apiHandlers/courseHandlers/"
    click EH "https://github.com/ALiwoto/ExamSphere/tree/master/src/apiHandlers/examHandlers/"
    click TH "https://github.com/ALiwoto/ExamSphere/tree/master/src/apiHandlers/topicHandlers/"
    click CAP "https://github.com/ALiwoto/ExamSphere/tree/master/src/apiHandlers/captchaHandlers/"
    click SW "https://github.com/ALiwoto/ExamSphere/tree/master/src/apiHandlers/swaggerHandlers/"
    click CONF "https://github.com/ALiwoto/ExamSphere/tree/master/src/core/appConfig/"
    click VAL "https://github.com/ALiwoto/ExamSphere/tree/master/src/core/appValues/"
    click EM "https://github.com/ALiwoto/ExamSphere/tree/master/src/core/utils/emailUtils/"
    click HASH "https://github.com/ALiwoto/ExamSphere/tree/master/src/core/utils/hashing/"
    click LOG "https://github.com/ALiwoto/ExamSphere/tree/master/src/core/utils/logging/"
    click AUTO "https://github.com/ALiwoto/ExamSphere/tree/master/src/core/utils/autoCompletionUtils/"
    click MIG "https://github.com/ALiwoto/ExamSphere/tree/master/src/database/dbScripts/"
    click UM "https://github.com/ALiwoto/ExamSphere/blob/master/src/database/types_users.go"
    click CM "https://github.com/ALiwoto/ExamSphere/blob/master/src/database/types_courses.go"
    click EM_M "https://github.com/ALiwoto/ExamSphere/blob/master/src/database/types_exams.go"
    click TM "https://github.com/ALiwoto/ExamSphere/blob/master/src/database/types_topics.go"
    click CONF_EMAIL "https://github.com/ALiwoto/ExamSphere/blob/master/src/core/utils/emailUtils/templates/ConfirmAccount.en.html"
    click PASS_EMAIL "https://github.com/ALiwoto/ExamSphere/blob/master/src/core/utils/emailUtils/templates/PasswordChange.en.html"
    click ERR "https://github.com/ALiwoto/ExamSphere/tree/master/logs/errors/"
    click PAN "https://github.com/ALiwoto/ExamSphere/tree/master/logs/panics/"
    click MS "https://github.com/ALiwoto/ExamSphere/tree/master/src/masterServer/"

    classDef frontend fill:#E6E6FA,stroke:#333,stroke-width:2px
    classDef api fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef core fill:#98FB98,stroke:#333,stroke-width:2px
    classDef util fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef db fill:#FFA07A,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Frontend]:::frontend
        L2[API Layer]:::api
        L3[Core Services]:::core
        L4[Utility Services]:::util
        L5[Database Layer]:::db
    end
```
