# sudoneoox/picton architecture

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

- Interactive diagram: https://gitdiagram.com/sudoneoox/picton
- Repository: https://github.com/sudoneoox/picton

## Overview

Based on our analysis of the file tree and README, this project is a full‐stack user management system with role‐based access control (RBAC). The backend is implemented in Django while the frontend is built with React (using Vite), and PostgreSQL is used for the primary database. Authentication is done via Office365, so that external integration should also be represented in the system design.

##### Main Components
- Frontend: Represent the React application (front-end) that handles routing and user interface. Indicate its directories (e.g., src, public, components, and styles).
- Backend: Illustrate the Django-based backend, which is divided into “api” and “config” components. Highlight important parts such as:
- API endpoints (URLs, views, serializers) for authentication, user management, forms, and admin functionalities.
- Management commands and migrations as part of operational or deployment tasks.
- Core functionality such as exception handling, permissions, and utility functions.
- External Authentication Service: Include Microsoft Office365 (Azure/Microsoft Graph) as an external authentication service. This should be connected to both the frontend and backend to indicate the integration.

##### Relationships and Interactions
- How the Frontend communicates with the Backend’s API endpoints (for user login, submission of forms, fetching dashboard data, etc.).
- How the Backend makes calls to the PostgreSQL database (for persistent user and form data).
- The callout from the Backend to Microsoft’s authentication service during the authentication flow.
- Separation of concerns:
- The frontend is responsible for presentation and client-side logic.
- The backend handles business logic, authentication, database interactions, and processing of forms.
- External services (Office365) are used for authentication and possibly user management.

##### Architectural Patterns and Design Principles
- Separation of Frontend and Backend layers (MVC-like pattern in Django, with clear distinctions between API, management, and configuration).
- Use of microservices or containerization patterns:
- Extensibility is suggested by the modular structure in both the backend (e.g., “api/core”, “api/views/forms”) and frontend (separated pages and components).
- Python and Django for the backend
- React (with Vite) for the frontend
- PostgreSQL for the database
- Microsoft Office365 integration for authentication (via Microsoft Graph)
- Docker (with provided Dockerfiles, docker-compose) for container orchestration

## Diagram (Mermaid)

```mermaid
graph TD
    %% Containerization Subgraph
    subgraph "Containerization (Docker)"
        FCT("Frontend Docker Container"):::container
        BCT("Backend Docker Container"):::container
        DC("Docker Compose Orchestration"):::container
        DS("Docker Scripts"):::container
    end

    %% Frontend Subgraph
    subgraph "Frontend (React)"
        FS("Source (src)"):::frontend
        FP("Static Assets (public)"):::frontend
        FC("Components Config"):::frontend
        FV("Vite Config"):::frontend
        FMC("Office365 Callback"):::frontend
        FAA("Auth API Client"):::frontend
        FMS("MSAL Config"):::frontend
    end

    %% Backend Subgraph
    subgraph "Backend (Django)"
        BUR("API Routing"):::backend
        BUV("API Views"):::backend
        BCU("Core Utilities"):::backend
        BUF("Utility Functions"):::backend
        BMC("Management Commands"):::backend
        BMG("Migrations"):::backend
        BCONF("Configuration"):::backend
        BAH("Auth Handler"):::backend
        BAS("Auth Serializer"):::backend
    end

    %% Database and External Service
    D("PostgreSQL Database"):::database
    E("Microsoft Office365 Service"):::external

    %% Containerization Connections
    DC -->|"orchestrates" | FCT
    DC -->|"orchestrates" | BCT
    DS -->|"runs" | DC

    %% Integration between Containerization and Application Components
    FCT -->|"hosts" | FS
    BCT -->|"hosts" | BUR

    %% Frontend to Backend Communication
    FS -->|"HTTPRequests/APICalls"| BUR

    %% Backend to Database Communication
    BUR -->|"CRUDOperations"| D

    %% Authentication Flows
    BAH -->|"AuthFlow"| E
    FAA -->|"AuthRequests"| E

    %% Additional Backend Flow
    BUV -->|"invokes"| BAH

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
```
