# csc929/ims_api_server architecture

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

- Interactive diagram: https://gitdiagram.com/csc929/ims_api_server
- Repository: https://github.com/csc929/ims_api_server

## Overview

##### Main Components
- API Server (Django Application):
- This is the core of the system. It is represented by the Django project (the solution file IMS_API_Server.sln and the main project folder).
- Django Apps:
- Accounts: Handles user management, authentication, permissions, and tests. Files include views.py, models.py, serializers.py, and custom logic (custom_permissions.py, custom_validators.py, stock_taker.py).
- IMS_Control: Manages inventory operations (add, edit, delete, view, search, pagination, etc.). Like Accounts, it contains models, views, serializers, and tests.
- App: Contains the static assets (CSS, JavaScript) and templates (HTML) for the frontend server-rendered pages (even though a separate frontend exists, this core project provides UI elements).
- Project Configuration:
- Includes common configuration files such as settings.py, urls.py (both global and per-app), and the WSGI entry point.
- Database:
- Although the README mentions options, the project is configured to use MySQL (but may also work with SQLite/PostgreSQL).
- External Dependencies:
- The RESTful API is consumed by the separate IMS_Frontend repository.
- Tools like API testing (Postman) and management tools (DBeaver) assist in development and troubleshooting.

##### Relationships & Interactions
- Incoming HTTP requests are routed via Django’s URL routing:
- Requests hit the project-level urls.py, which then delegates to the Accounts and IMS_Control apps’ urls.py.
- The Accounts app:
- Manages user authentication, permissions, and account-related operations.
- Contains custom validations and permission checks.
- The IMS_Control app:
- Implements the business logic for managing inventory, including CRUD operations.
- The “app” folder:
- Provides static content and HTML templates, ensuring that user interface components are rendered properly.
- The Database:
- Acts as the backend store where models from both Accounts and IMS_Control interact via Django’s ORM.
- Flow:
- Users interact via the frontend, which makes API calls to the Django REST endpoints.
- The Django server processes these API requests, executes business logic in the apps, and communicates with the database for persistence.

##### Architectural Patterns & Design Principles
- Django’s MVC (or MTV) pattern:
- Models represent the database structure.
- Templates (in the “app” folder) render data.
- Views process incoming requests and return responses.
- RESTful API design:
- Exposes endpoints for login, password changes, user management, and inventory operations.
- Emphasizes stateless communication between the frontend and backend.
- Separation of concerns:
- Clearly separated Django apps handle different aspects of functionality (Accounts for user management, IMS_Control for inventory operations).

##### Technologies & Frameworks to Highlight
- Python and Django, including Django REST framework.
- MySQL as the database backend (as configured in settings.py).
- Static assets management through Django’s templating system.
- Optional developer tools mentioned in the README (Visual Studio Code, PyCharm) that might integrate with the project structure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    IMS_Frontend["IMS_Frontend (Client)"]:::external
    API_Server["API Server (Django)"]:::django
    IMS_Frontend -->|"HTTP_Request"| API_Server

    subgraph "Django Server Components"
        GlobalConf["Global Project Configuration"]:::config
        Accounts["Accounts App"]:::app
        IMS_Control["IMS_Control App"]:::app
        AppFolder["App Folder (Templates & Static)"]:::app
    end

    API_Server -->|"Routes"| GlobalConf
    GlobalConf -->|"URL_Routing"| Accounts
    GlobalConf -->|"URL_Routing"| IMS_Control
    GlobalConf -->|"ServesUI"| AppFolder

    Database(("MySQL Database")):::db
    Accounts -->|"ORM_Query"| Database
    IMS_Control -->|"ORM_Query"| Database

    click API_Server "https://github.com/csc929/ims_api_server/tree/master/IMS_API_Server/"
    click GlobalConf "https://github.com/csc929/ims_api_server/tree/master/IMS_API_Server/IMS_API_Server/"
    click Accounts "https://github.com/csc929/ims_api_server/tree/master/IMS_API_Server/Accounts/"
    click IMS_Control "https://github.com/csc929/ims_api_server/tree/master/IMS_API_Server/IMS_Control/"
    click AppFolder "https://github.com/csc929/ims_api_server/tree/master/IMS_API_Server/app/"

    classDef external fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef django fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef config fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef app fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef db fill:#F08080,stroke:#333,stroke-width:2px;
```
