# oyenet1/course_allocation architecture

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

- Interactive diagram: https://gitdiagram.com/oyenet1/course_allocation
- Repository: https://github.com/oyenet1/course_allocation

## Overview

##### Project Type and Purpose
- Project Type: A full-stack web application built with Laravel.
- Purpose: Manage course allocation by allowing administrators to add lecturers, courses, and levels; allocate courses; and prevent duplicate assignments.

##### File Structure
- Core Laravel Structure: The file tree shows typical Laravel directories (app, bootstrap, config, database, public, resources, routes, storage, tests).
- Backend Components:
- "app/Http/Controllers" holds the standard HTTP controllers.
- "app/Actions/Fortify" shows handling for Fortify-related actions (user authentication functions).
- "app/Http/Livewire" and corresponding Blade views in "resources/views/livewire" indicate the use of Laravel Livewire for interactive frontend components.
- "app/Models" contains the Eloquent models for Course, Department, Lecturer/User, etc.
- Frontend Components:
- "resources/views" and "public" hold Blade layouts and assets like CSS, JS, and images.
- "resources/scss" and "resources/js" contain the styling and scripting, with Tailwind and possibly Bootstrap configurations.
- Database Layer:
- "database/migrations" defines the schema for tables such as users, profiles, courses, departments, semesters, course allocations, etc.
- "database/seeders" provides dummy data, supporting rapid prototyping.
- Other Key Directories:
- "config" holds configuration files (including fortify, laratrust), which affect authentication and authorization.
- "storage" shows local file storage for images (e.g., profile pictures and course-related documents).

##### Incorporate README Insights
- The README provides three architectural views (use case, data flow, ERD) that should be referenced.
- It explains the system requirements and installation instructions, emphasizing that the application runs on PHP, MySQL, and uses Composer.

a. Main Components:
- Client/Presentation Layer:
- Browser/User Interface interacting with Blade templates and Livewire components (e.g., admin dashboard, forms for adding lecturers, courses, and allocations).
- Static assets (CSS, JS, images) under the public directory.
- Application/Business Logic Layer:
- Laravel Controllers and Livewire components which handle requests and update views.
- Middleware for authentication, session management, and request validation.
- Actions (in app/Actions/Fortify) handling user management.
- Services like Mail, Notifications, and Events for sending alerts (e.g., checkout reminders, contact responses).
- Data Access Layer:
- Eloquent Models (e.g., Course, Department, Level, User) representing the database entities.
- Database: MySQL as configured in the .env file, with migrations and seeders establishing schema and test data.
- Infrastructure:
- External dependencies like Composer packages.
- File storage system managed under storage (for images and temporary files).
- CLI and Artisan commands for operations.

b. Relationships and Interactions:
- The client sends HTTP requests (forms, AJAX calls via Livewire).
- Routes (defined in routes/web.php and routes/api.php) dispatch these requests to Controllers.
- Controllers interact with Livewire components (or return Blade views) and communicate with the business service layer.
- The Eloquent models interface with the MySQL database using migrations and seeders for data initialization.
- Middleware (authentication, CSRF, etc.) secures and validates incoming requests.
- Mail and Notification systems are used to communicate with users (e.g., contact form responses).

c. Architectural Patterns and Design Principles:
- MVC (Model-View-Controller): Clear separation between presentation (views), business logic (controllers and Livewire components), and data (models).
- Use of Laravel-specific layers such as Fortify (for authentication) and Laratrust (for permission management).
- Event-driven architecture: Mail, Notifications, and scheduled commands indicate use of event handling and background processing.
- Component-based design in the frontend: Laravel Livewire and Blade components for modular, reusable UI elements.

d. Technologies, Frameworks, and Libraries:
- Laravel Framework (PHP), utilizing modern PHP (PHP 8 and above as per requirements).
- Laravel Livewire, Blade templates for frontend interactivity.
- MySQL Database with Laravel’s Eloquent ORM.
- Frontend stacks like Tailwind CSS and potentially Bootstrap (noted in asset files).
- Composer for dependency management and PHP Artisan for command-line operations.
- Additional libraries for mailing (app/Mail), notifications, and laratrust for role/permission management.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Frontend/UI"
        A["Blade Templates"]:::frontend
        B["Livewire Views"]:::frontend
    end

    subgraph "Business Logic (Controllers, Livewire, Middleware, Actions)"
        C["HTTP Controllers"]:::business
        D["Livewire Components"]:::business
        E["Middleware"]:::business
        F["Fortify Actions"]:::business
    end

    subgraph "Data Layer (Eloquent Models & Database)"
        G["Eloquent Models"]:::data
        H["Database Migrations"]:::data
        I["Seeders"]:::data
    end

    subgraph "Infrastructure & External Services"
        J["Configuration Files"]:::infra
        K["Mail Services"]:::infra
        L["Notifications"]:::infra
        M["File Storage"]:::infra
        N["Frontend Assets"]:::infra
    end

    A -->|"SendsRequest"| C
    B -->|"DynamicUpdates"| D
    C -->|"ProcessRequest"| G
    D -->|"InteractWith"| G
    G -->|"DBOperations"| H
    G -->|"UsesData"| I
    C -->|"UsesMiddleware"| E
    C -->|"CallsFortify"| F
    C -->|"UtilizesConfig"| J
    D -->|"UploadsFiles"| M
    C -->|"TriggersMail"| K
    C -->|"SendsNotif"| L
    A -->|"LoadsAssets"| N
    B -->|"LoadsAssets"| N

    click A "https://github.com/oyenet1/course_allocation/blob/master/resources/views/layouts/app.blade.php"
    click B "https://github.com/oyenet1/course_allocation/blob/master/resources/views/livewire/admin-dashboard.blade.php"
    click C "https://github.com/oyenet1/course_allocation/blob/master/app/Http/Controllers/Controller.php"
    click D "https://github.com/oyenet1/course_allocation/blob/master/app/Http/Livewire/Allocation.php"
    click E "https://github.com/oyenet1/course_allocation/blob/master/app/Http/Middleware/Authenticate.php"
    click F "https://github.com/oyenet1/course_allocation/blob/master/app/Actions/Fortify/CreateNewUser.php"
    click G "https://github.com/oyenet1/course_allocation/blob/master/app/Models/Course.php"
    click H "https://github.com/oyenet1/course_allocation/blob/master/database/migrations/2023_02_15_012942_create_courses_table.php"
    click I "https://github.com/oyenet1/course_allocation/blob/master/database/seeders/CourseSeeder.php"
    click J "https://github.com/oyenet1/course_allocation/blob/master/config/fortify.php"
    click K "https://github.com/oyenet1/course_allocation/blob/master/app/Mail/ContactMail.php"
    click L "https://github.com/oyenet1/course_allocation/blob/master/app/Notifications/CheckoutReminder.php"
    click M "https://github.com/oyenet1/course_allocation/tree/master/public/img"
    click N "https://github.com/oyenet1/course_allocation/blob/master/resources/js/app.js"

    classDef frontend fill:#A2D9CE,stroke:#1ABC9C,stroke-width:2px;
    classDef business fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef data fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef infra fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
```
