# pseudo-sm/ejudiciary architecture

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

- Interactive diagram: https://gitdiagram.com/pseudo-sm/ejudiciary
- Repository: https://github.com/pseudo-sm/ejudiciary

## Overview

##### System’s Major Components
a. Frontend: Representing static HTML/CSS/JS files (including Bootstrap assets) and Django templates (found under ejapp/templates). This part renders interfaces for the four user panels.
b. Backend (Django Application): The core logic is split into several submodules:
- URL routing and views – “eJudiciary/urls.py” and “ejapp/views.py” and “ejapp/main.py”.
- Business logic and models – “ejapp/models.py” and migration folders indicate use of an ORM with Django.
- Administration panel – Noticing files like “admin.py” and specialized templates (e.g., admin.html) that support admin functions.
c. Database Layer: Although the README cites Firebase Realtime Database, the project’s file tree includes a local SQLite file (“db.sqlite3”) which could serve as a development database or fallback.
d. Machine Learning Modules:
- A regression model (indicated by files like “model200.pickle” and associated CSV files).
- Text similarity module under “ejapp/triathon_text_similarity” managing tasks like preprocessing, prediction, and similarity computations.
e. Static Assets: These include static files for CSS, JavaScript, fonts, and images to support the frontend and possibly admin control panels.

##### Relationships and Interactions
- The client (web browser) communicates with the server (Django) via HTTP requests. The URL dispatcher directs these to the proper view functions.
- The views interact with Django models to retrieve/update data in the database.
- The business logic includes invoking the ML modules for generating credit scores and finding related cases using text similarity algorithms.
- The Django backend renders templates that tie into static assets.
- Although the project uses a local SQLite database in development, mark the external dependency to Firebase (as per the README) for production or realtime features.
- There is a separation of concerns: user interfaces (templates/static files), backend logic (views/models), and auxiliary components (ML models).

##### Architectural Patterns and Design Principles
- MVC/MVT Pattern: The project adheres to Django’s Model-View-Template (MVT) structure, where models hold the data, views contain the logic, and templates present the data.
- Modularity: The separation between “eJudiciary” (project settings and configuration) and “ejapp” (the primary app logic) ensures a clean separation of concerns.
- Extensibility for Machine Learning: The ML components (regression and cosine similarity modules) are separated in their own subdirectory, making them independent and easier to update.

##### Relevant Technologies
- Django 2.X: Driving the web framework structure.
- HTML/CSS/JS with Bootstrap: For designing responsive user interfaces.
- SQLite / Firebase: Database technologies, with the possibility of integrating Firebase for a real-time experience.
- Python and associated libraries for Machine Learning and text similarity (implicit from the file names and model files).
- Deployment through WSGI (eJudiciary/wsgi.py) indicating standard Django deployment practices.

##### Specific Elements the Principal Software Engineer Should Include
- Component labels: Label nodes such as “User Interface (Templates/Static Files)”, “Django Views & URL Dispatcher”, “Django Models & ORM”, “SQLite/Firebase Database”, “Machine Learning Module (Regression & Text Similarity)”, and “WSGI Server”.
- Integration points: Mark how machine learning outputs (e.g., credit scores, similar cases) feed back into the decision-making process and display layers.
- Annotations to indicate that while SQLite is used in the development environment, the intended design may include Firebase Realtime Database for actual deployments.

– Represent the separation between frontend (user panels and static resources) and backend (Django’s MVT architecture).
– Highlight data flows and interactions between the database, ML modules, user interfaces, and business logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Subgraph: Client Layer
    subgraph "Client Layer"
        Browser["User Browser"]:::client
    end

    %% Subgraph: Server Layer
    subgraph "Server Layer"
        WSGI["WSGI Server"]:::backend
        URL["URL Routing & Views"]:::backend
        BL["Business Logic & Models"]:::backend
        DB["Database (SQLite/Firebase)"]:::database
    end

    %% Subgraph: Frontend Layer
    subgraph "Frontend Layer"
        T["Templates (HTML)"]:::frontend
        S["Static Assets (CSS/JS/Bootstrap)"]:::frontend
        APT["Administration Panel Templates"]:::frontend
    end

    %% Subgraph: Machine Learning Layer
    subgraph "ML Layer"
        ML["Machine Learning Module (Regression & Text Similarity)"]:::ml
    end

    %% Data Flow Connections
    Browser -->|"HTTP Request"| WSGI
    WSGI -->|"Routes Request"| URL
    URL -->|"Invokes"| BL
    BL -->|"Reads/Writes"| DB
    BL -->|"ML Processing"| ML
    ML -->|"Returns Results"| BL
    URL -->|"Renders"| T
    T -->|"Loads Assets"| S
    T -->|"Displays Response"| Browser
    BL -->|"Admin Operations"| APT

    %% Click Events for Frontend Components
    click T "https://github.com/pseudo-sm/ejudiciary/tree/master/ejapp/templates"
    click S "https://github.com/pseudo-sm/ejudiciary/tree/master/ejapp/static"
    click APT "https://github.com/pseudo-sm/ejudiciary/blob/master/ejapp/templates/admin.html"
    click APT "https://github.com/pseudo-sm/ejudiciary/tree/master/ejapp/templates/admin2"

    %% Click Events for URL Routing and Views Components
    click URL "https://github.com/pseudo-sm/ejudiciary/blob/master/eJudiciary/urls.py"
    click URL "https://github.com/pseudo-sm/ejudiciary/blob/master/ejapp/views.py"
    click URL "https://github.com/pseudo-sm/ejudiciary/blob/master/ejapp/main.py"

    %% Click Events for Business Logic and Models
    click BL "https://github.com/pseudo-sm/ejudiciary/blob/master/ejapp/models.py"
    click BL "https://github.com/pseudo-sm/ejudiciary/blob/master/ejapp/admin.py"
    click BL "https://github.com/pseudo-sm/ejudiciary/tree/master/ejapp/migrations"

    %% Click Event for Database
    click DB "https://github.com/pseudo-sm/ejudiciary/blob/master/db.sqlite3"

    %% Click Events for Machine Learning Module
    click ML "https://github.com/pseudo-sm/ejudiciary/blob/master/ejapp/model200.pickle"
    click ML "https://github.com/pseudo-sm/ejudiciary/blob/master/model200.pickle"
    click ML "https://github.com/pseudo-sm/ejudiciary/tree/master/ejapp/triathon_text_similarity"

    %% Click Event for WSGI Deployment
    click WSGI "https://github.com/pseudo-sm/ejudiciary/blob/master/eJudiciary/wsgi.py"

    %% Styles
    classDef client fill:#cff,stroke:#333,stroke-width:2px;
    classDef backend fill:#f9f,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ccf,stroke:#333,stroke-width:2px;
    classDef ml fill:#cfc,stroke:#333,stroke-width:2px;
    classDef database fill:#fc9,stroke:#333,stroke-width:2px;
```
