# ishaan1013/axiom architecture

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

- Interactive diagram: https://gitdiagram.com/ishaan1013/axiom
- Repository: https://github.com/ishaan1013/axiom

## Overview

##### Project Type and Purpose
- This is a full-stack collaborative editor interface for “George” (a tool for logic and computation assignments). Users get an interactive, VSCode-like editor with real-time collaboration features (via workspaces and multiplayer editing) as well as advanced language support.
- The frontend is built using Next.js 14 with Typescript, enhanced by libraries such as Monaco Editor, Y.js, TailwindCSS, and Shadcn UI.
- The backend uses Express (with Node.js and Typescript), Socket.io for websockets, and Prisma as an ORM for database handling.

##### File Structure Insights
- The project is clearly separated into two main components via directories — “frontend” and “backend”.
– The “frontend” directory contains Next.js pages and application shell, UI components (for editor, settings, tabs, upload, etc.), hooks, and libraries organized by purpose.
– The “backend” directory holds the server logic: Express server logic, socket.io communication (in socketio.ts), and configuration for Prisma migrations and the database schema.
- The “george” directory includes several subdirectories filled with “.grg” files. These are likely static or importable domain files used by the editor to load assignments or examples.
- The presence of various config files (e.g., package.json, tsconfig.json, nodemon.json) confirms development and runtime setup.

a. Main Components:
– Frontend Client: Built with Next.js. Include subcomponents:
- The Editor Interface (with Monaco Editor for VSCode-like editing, tabs, sidebars, and panels).
- Collaboration and Workspace Components (managing real-time collaboration via Y.js and socket.io).
- UI Components: Buttons, dialogs, file uploaders, and other reusable shadcn UI elements.
– Backend Server: Built with Express and Node.js.
- HTTP API endpoints for authentication, file management, and collaboration.
- WebSocket Communication: Real-time data exchange using socket.io.
- Prisma Integration: Includes schema, migrations, and seeding functionalities to manage the DB.
– Database: Managed via Prisma (likely an SQLite file based on the “file:./dev.db” hint). Represents persisted state for users, workspaces, and file data.
– Integration/External Services:
- Third-Party Libraries: Y.js, Monaco Editor (frontend) and Socket.io (both in frontend and backend).
- “George” Files: The static assignment files that may be loaded into the editor, representing domain-specific content.

b. Relationships and Interactions:
– The Browser (client) runs the Next.js frontend. It makes HTTP requests and establishes WebSocket (socket.io) connections to the backend server.
– The frontend sends collaboration events (e.g., workspace updates and file changes) in real time to the backend.
– The backend, built on Express with socket.io, receives these events, processes them, and updates the database (through Prisma) or to synchronize changes among multiple users.
– The collaboration layer (Y.js) is integrated to manage real-time document changes in the frontend.

c. Architectural Patterns and Design Principles:
– MVC/Separation of Concerns: The clear separation between frontend (view and domain logic) and backend (API and real-time communication) demonstrates separation of concerns.
– Real-time Collaboration: Use of socket.io and Y.js highlights an event-driven architecture.
– Database Migrations: Use of Prisma for systematic schema evolution, seeding, and data exploration via Prisma Studio.
– Modular and Component-driven: The division of UI components and hooks in the frontend shows an emphasis on reusability and modular design.

d. Key Technologies and Frameworks:
– Frontend: Next.js 14, Typescript, Monaco Editor, Y.js, Socket.io (client side), TailwindCSS, Shadcn UI, Tanstack Query.
– Backend: Express, Typescript, Node.js, Socket.io (server side), and Prisma.
– Database: Likely a SQLite database or similar file-based DB indicated by the DATABASE_URL in the prisma config.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser (User)"]:::external

    subgraph "Frontend (Next.js Application)"
        FrontendClient["Frontend Client"]:::frontend
        EditorUI["Editor UI Components"]:::frontend
        Collaboration["Collaboration & Workspace"]:::frontend
        ReusableUI["Reusable UI Components"]:::frontend
        UtilityLib["Utility Libraries"]:::frontend
    end

    subgraph "Backend (Express & Socket.io Server)"
        BackendAPI["Backend API"]:::backend
        SocketIO["WebSocket Service"]:::backend
        PrismaIntegration["Prisma Integration"]:::backend
    end

    Database["Database"]:::db
    GeorgeFiles["Static Domain Files (George Assignments)"]:::external

    Browser -->|"HTTPRequest"| FrontendClient
    FrontendClient -->|"APICall"| BackendAPI
    FrontendClient -->|"WSConnect"| SocketIO
    Collaboration -->|"RealTimeUpdate"| SocketIO
    BackendAPI -->|"DBOperation"| PrismaIntegration
    PrismaIntegration -->|"CRUDQuery"| Database
    EditorUI -->|"LoadFiles"| GeorgeFiles

    click FrontendClient "https://github.com/ishaan1013/axiom/tree/main/frontend/app"
    click EditorUI "https://github.com/ishaan1013/axiom/tree/main/frontend/components/editor"
    click Collaboration "https://github.com/ishaan1013/axiom/blob/main/frontend/lib/collaboration.ts"
    click ReusableUI "https://github.com/ishaan1013/axiom/tree/main/frontend/components/ui"
    click UtilityLib "https://github.com/ishaan1013/axiom/tree/main/frontend/lib"
    click BackendAPI "https://github.com/ishaan1013/axiom/blob/main/backend/src/index.ts"
    click SocketIO "https://github.com/ishaan1013/axiom/blob/main/backend/src/socketio.ts"
    click PrismaIntegration "https://github.com/ishaan1013/axiom/tree/main/backend/prisma"
    click GeorgeFiles "https://github.com/ishaan1013/axiom/tree/main/george"

    classDef frontend fill:#C6E2FF,stroke:#000,stroke-width:2px;
    classDef backend fill:#FAD6A5,stroke:#000,stroke-width:2px;
    classDef db fill:#FFE699,stroke:#000,stroke-width:2px;
    classDef external fill:#D5A6BD,stroke:#000,stroke-width:2px;
```
