# notn0xys/femspice architecture

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

- Interactive diagram: https://gitdiagram.com/notn0xys/femspice
- Repository: https://github.com/notn0xys/femspice

## Overview

##### Project type and purpose
- This is a full-stack web application named “FEMspice,” combining a React/TypeScript frontend with a Python FastAPI backend.
- The frontend provides a visual circuit-building interface (components like ResistorNode, CapacitorNode, etc.).
- The backend exposes REST endpoints for authentication, user management, and (presumably) simulation jobs, backed by a database.

##### File structure
- Top-level directories:
– backend: FastAPI service with main.py, routers (auth), model (user), schema, config (db connection), utils (security).
– frontend/Femspice: Vite-based React app with pages (login, signup, mainpage, about), UI components, electric component nodes, hooks, and asset folders.
- Build and deployment: package.json and lockfiles in both backend and frontend; vercel.json in frontend indicates deployment on Vercel.
- Configuration:
– backend/config/db.py configures database URI, connection pooling.
– frontend/vite.config.ts holds build settings.
- Observed patterns: clearly separated presentation layer (React), API layer (FastAPI), data layer (DB).

##### Key architectural insights from README
- README is minimal; project name implies a circuit simulation (“SPICE”) tool built with finite-element methods or front-end modeling.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Browser["User Browser\n(React SPA)"]:::frontend
        Entry["main.tsx\n(Entry Point)"]:::frontend
        AppComp["App.tsx\n(Root App)"]:::frontend
        Sidebar["app-sidebar.tsx\n(Sidebar)"]:::frontend
        Layout["layout.tsx\n(Generic Layout)"]:::frontend
        UILib["UI Components\n(ui/*.tsx)"]:::frontend
        Nodes["Circuit Nodes\n(Capacitor, Resistor,\nInductor, Voltage)"]:::frontend
        Pages["Pages\n(login, signup,\nmainpage, about)"]:::frontend
        Hook["use-mobile.ts\n(Responsive Hook)"]:::frontend
        UtilsFE["utils.ts\n(Utility Functions)"]:::frontend
        BuildCfg["vite.config.ts\n& vercel.json"]:::frontend

        Browser --> Entry
        Entry --> AppComp
        AppComp --> Sidebar
        AppComp --> Layout
        Layout --> UILib
        Layout --> Nodes
        Layout --> Pages
        Layout --> Hook
        Layout --> UtilsFE
        AppComp --> BuildCfg
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        APIGateway["API Gateway\n(Vercel Routing)"]:::backend
        FastAPI["FastAPI Service\n(main.py)"]:::backend
        AuthRouter["auth.py\n(Authentication Router)"]:::backend
        SimRouter["simulate.py\n(Simulation Router)"]:::backend
        UserModel["user.py\n(ORM Model)"]:::backend
        Schemas["schemas.py\n(Pydantic Schemas)"]:::backend
        DBConfig["db.py\n(Database Config)"]:::backend
        SecUtils["security.py\n(Security Utils)"]:::backend

        Browser -->|HTTPS /api/*| APIGateway
        APIGateway --> FastAPI
        FastAPI --> AuthRouter
        FastAPI --> SimRouter
        AuthRouter --> Schemas
        AuthRouter --> SecUtils
        AuthRouter --> UserModel
        SimRouter --> Schemas
        FastAPI --> DBConfig
    end

    %% Data & Compute Layer
    subgraph "Data & Compute Layer"
        direction TB
        Database["Database\n(PostgreSQL)"]:::data
        Queue["Job Queue\n(Redis/RabbitMQ)"]:::data
        SimEngine["Simulation Engine\n(Worker)"]:::backend
        BlobStore["Blob Store\n(Optional)"]:::data

        DBConfig --> Database
        FastAPI -->|Read/Write| Database
        SimRouter -->|Enqueue Job| Queue
        Queue --> SimEngine
        SimEngine -->|Store Results| BlobStore
        SimEngine -->|Store Metadata| Database
        SimEngine -->|Return Results| FastAPI
    end

    %% External Services
    subgraph "External Services"
        direction TB
        OAuth["OAuth Provider"]:::external
        EmailSvc["Email Service"]:::external
        Monitoring["Logging & Monitoring"]:::external

        AuthRouter --> OAuth
        AuthRouter --> EmailSvc
        FastAPI --> Monitoring
    end

    %% Click Events
    click Entry "https://github.com/notn0xys/femspice/blob/main/frontend/Femspice/src/main.tsx"
    click AppComp "https://github.com/notn0xys/femspice/blob/main/frontend/Femspice/src/App.tsx"
    click Sidebar "https://github.com/notn0xys/femspice/blob/main/frontend/Femspice/src/components/app-sidebar.tsx"
    click Layout "https://github.com/notn0xys/femspice/blob/main/frontend/Femspice/src/components/layout.tsx"
    click UILib "https://github.com/notn0xys/femspice/tree/main/frontend/Femspice/src/components/ui"
    click Nodes "https://github.com/notn0xys/femspice/tree/main/frontend/Femspice/src/electric_components"
    click Hook "https://github.com/notn0xys/femspice/blob/main/frontend/Femspice/src/hooks/use-mobile.ts"
    click UtilsFE "https://github.com/notn0xys/femspice/blob/main/frontend/Femspice/src/lib/utils.ts"
    click BuildCfg "https://github.com/notn0xys/femspice/blob/main/frontend/Femspice/vite.config.ts"
    click BuildCfg "https://github.com/notn0xys/femspice/blob/main/frontend/Femspice/vercel.json"
    click AuthRouter "https://github.com/notn0xys/femspice/blob/main/backend/routers/auth.py"
    click FastAPI "https://github.com/notn0xys/femspice/blob/main/backend/main.py"
    click UserModel "https://github.com/notn0xys/femspice/blob/main/backend/model/user.py"
    click Schemas "https://github.com/notn0xys/femspice/blob/main/backend/schema/schemas.py"
    click DBConfig "https://github.com/notn0xys/femspice/blob/main/backend/config/db.py"
    click SecUtils "https://github.com/notn0xys/femspice/blob/main/backend/utils/security.py"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#005A9C,color:#000;
    classDef backend fill:#DFFFD0,stroke:#4B8B00,color:#000;
    classDef data fill:#FFF5C2,stroke:#B58900,color:#000;
    classDef external fill:#FFD0D0,stroke:#9C0000,color:#000;
```
