Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
cfa3505
NO change in version.py
GorkiPower Nov 28, 2025
4c3e908
add main.py; add model.py
GorkiPower Nov 28, 2025
9cc70a9
add: from datetime import datetime
GorkiPower Nov 28, 2025
8681ea8
add simple FARM-Stack
GorkiPower Nov 28, 2025
621e3fd
Ready to start -> uvicorn backend.main:app --reload
GorkiPower Nov 28, 2025
65b4a20
add
GorkiPower Nov 28, 2025
6f58f29
frontend is working without 404 Not Found
GorkiPower Nov 28, 2025
efebed4
Add Next.js frontend
GorkiPower Nov 28, 2025
4cf11e4
Starting Clean Backend Frontend NOT working together
GorkiPower Dec 1, 2025
ca11ef8
Server are NOT TALKING TO EACH OTHER
GorkiPower Dec 1, 2025
4494a01
Server a running - Frontend and Backend are NOT communiating
GorkiPower Dec 1, 2025
32f49ac
Update REAMDE
GorkiPower Dec 1, 2025
1568c6d
Updated README
GorkiPower Dec 1, 2025
8f057e1
ruff check .; ruff check . --fix; ruff format .; Add Ruff to pyprojec…
GorkiPower Dec 3, 2025
6ebd4f7
Update pyproject.toml
GorkiPower Dec 3, 2025
e83a983
Update: backend/_version.py
GorkiPower Dec 3, 2025
297ddf2
Apply Ruff formatting
GorkiPower Dec 3, 2025
f5dacc3
Update database.py, datamodel.py, main.py, model.py
GorkiPower Dec 3, 2025
05c1ce3
Updated datamodel.py main.py model.py
GorkiPower Dec 3, 2025
dcbf01e
run ruff check . --fix and ruff format .
GorkiPower Dec 3, 2025
1a728af
clean model.py
GorkiPower Dec 3, 2025
eb80f2f
bugs are fixed - ruff is happy
GorkiPower Dec 3, 2025
5c597aa
Merging model.py and datamodel.py has led to challenges :D Works now …
GorkiPower Dec 3, 2025
be2ef20
Clean all the rubbish
GorkiPower Dec 3, 2025
78a303e
delete model.py
GorkiPower Dec 3, 2025
fda8f59
Update: main before more verbose
GorkiPower Dec 3, 2025
db59966
It works fine
GorkiPower Dec 3, 2025
b8d2af9
BugFix: ruff check . --fix; ruff format .
GorkiPower Dec 4, 2025
46c4338
Update main.py
GorkiPower Dec 8, 2025
158dff2
feat: use jsonable_encoder with custom ObjectId encoder for clean RES…
GorkiPower Dec 8, 2025
9a8e751
SchemaDefinition with Optional Fields
GorkiPower Dec 8, 2025
f977b81
Refactored main.py 🔑 id: str ~ improve clarity and prepare for future…
GorkiPower Dec 9, 2025
93d86eb
Updated backend/datamodel.py
GorkiPower Dec 9, 2025
bc4e036
Refactored/CleanUp main.py: using list[dict[str, Any]] for Python(3.9+)
GorkiPower Dec 9, 2025
3b17c4a
Cleanup datamodel.py
GorkiPower Dec 9, 2025
9895288
Files cleaned up
GorkiPower Dec 9, 2025
bca088f
id: using hashlib implemented
GorkiPower Dec 10, 2025
ea934ef
Update datamodel.py, main.py - hashing is working
GorkiPower Dec 10, 2025
47984cf
Implement schema editing for flat JSON
GorkiPower Dec 10, 2025
3740f8d
Bugfix
GorkiPower Dec 10, 2025
170b761
ruff format .
GorkiPower Dec 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# added
.MyNotes/
.venv_jsoned


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[codz]
Expand Down Expand Up @@ -182,9 +187,9 @@ cython_debug/
.abstra/

# Visual Studio Code
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# and can be added to the global gitignore or merged into this file. However, if you prefer,
# you could uncomment the following to ignore the entire vscode folder
# .vscode/

Expand Down
285 changes: 285 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,287 @@
# jsoned
A full-stack application to visualize and edit entities and their relations defined in JSON Schema.



***

# JSONED — Full Teaching Guide

> **Goal:** Learn how to build and run a full-stack app to **visualize and edit JSON Schema entities** using **FastAPI** (backend) and **React** (frontend). Includes MongoDB integration as an advanced option.

***

## ✅ Quick Start

### 1. Clone the repository

```bash
jsoned> git clone https://github.com/BAMresearch/jsoned.git
jsoned> cd jsoned
jsoned> dir # Windows
jsoned> ls # Linux/macOS
```

***

### 2. Backend Setup (Terminal 1)

```bash
jsoned> cd backend
backend> python -m venv venv
backend> source venv/bin/activate # Windows: venv\Scripts\activate

backend(venv)> pip install -r requirements.txt

backend(venv)> uvicorn main:app --reload
# or specify host/port
backend(venv)> uvicorn main:app --reload --host 127.0.0.1 --port 8000
```

#### If using `pyproject.toml`:

```bash
# using install -e .
pip install -e .
pip install -e .[dev] #when dev is defined

# Check which tool is used (Poetry or Pipenv)

# If Poetry:
backend> pip install poetry
backend> poetry install
backend> poetry shell

# If Pipenv:
backend> pip install pipenv
backend> pipenv install
backend> pipenv shell

# If standard PEP 621:
backend> pip install .
```

**Check:** Open `http://127.0.0.1:8000/docs` → FastAPI docs should appear.

***

### 3. Frontend Setup (Terminal 2)

**Create React app:**

```bash
jsoned> npx create-react-app gui
jsoned> cd gui
gui> dir # Windows
gui> ls # Linux/macOS
```

**Install Axios for API calls:**

```bash
gui> npm install axios
gui> npm audit #Run audit details
gui> npm audit fix #Fix automatically

```

**Run frontend:**

```bash
gui> npm start # Standard start command

#OR
gui> npm run dev # Alias for developer mode

INFO:To npm run dev DO THE FOLLOWING:
in package.json add ->> "dev": "react-scripts start":

"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"dev": "react-scripts start"
}

```

✔ **Difference?**

* `npm start` → Runs the default development server.
* `npm run dev` → Custom alias (same behavior here).

📂 **Where are App.js and App.css?**

* Located in `gui/src/`:
* `App.js` → Main React component
* `App.css` → Styling for App.js

✅ **Check:**

* `http://localhost:3000`

***

## ✅ Architecture & Diagrams

### **High-Level Architecture**

+-------------------+ HTTP API +-------------------+ MongoDB
| React Frontend | <--------------------> | FastAPI | <----> | Database |
| (Components/UI) | | (Routes/Models) | | Schemas |
+-------------------+ +-------------------+ +----------+

***

### **Detailed Component Flow**

[User Action] --> [React Component] --> [Axios API Call] --> [FastAPI Endpoint]
| |
| v
| [MongoDB Query]
| |
v v
[Updated State] <-- [JSON Response] <-- [FastAPI Response] <-- [Database Result]

***

### **Backend Layer Diagram**

+-------------------+
| main.py | -> Routes & Controllers
+-------------------+
| models.py | -> Pydantic Schemas
+-------------------+
| database.py | -> MongoDB Connection
+-------------------+

***

### **Frontend Folder Structure**

gui/
├── public/
├── src/
│ ├── App.js # Main React Component
│ ├── api.js # Axios API Calls
│ ├── components/ # UI Components
│ └── App.css # Styling

***

### **Request Lifecycle**

User Click -> React -> Axios -> FastAPI -> MongoDB -> Response -> React State Update

***

### **MVC Mapping**

Model -> Pydantic schemas (datamodel.py, model.py)
View -> React components (App.jsx)
Controller -> FastAPI routes (main.py)

***

### **Sequence Flow (Add Version)**

User -> React -> FastAPI -> In-memory DB
| | | |
| Click Add | |
|---------------> | |
| POST /version |
| -> Append SchemaDefinition

***

### **UML Class Diagram**

+-------------------------+
| SchemaDefinition |
+-------------------------+
| id: str |
| name: str |
| version: str |
| content: dict |
| updated_at: datetime |
+-------------------------+

+-------------------------+
| UpdateSchema |
+-------------------------+
| name: str | None |
| version: str | None |
+-------------------------+

***

### **MongoDB Integration Flow**

+-----------+ Axios HTTP +-----------+ PyMongo +-----------+
| React | ---> POST /version -> | FastAPI | ---> Insert Doc -> | MongoDB |
| Frontend | GET /version | Backend | Query Docs | Database |
+-----------+ PATCH /version +-----------+ Return JSON +-----------+

***

## ✅ MongoDB Atlas Setup (Optional Advanced)

1. Create account at <https://www.mongodb.com/atlas>
2. Create cluster and get connection string
3. Add `.env` in `backend`:

<!---->

MONGO_URI="your-atlas-uri"

4. Use `pymongo` in `database.py`:

```python
from pymongo import MongoClient
from dotenv import load_dotenv
import os

load_dotenv()
client = MongoClient(os.getenv("MONGO_URI"))
db = client.jsoned_db
```

***

## ✅ API Endpoints

GET /version
POST /version
PUT /version/{id}
PATCH /version/{id}
DELETE /version/{id}

***

## ✅ Best Practices

* Use `.env` for secrets
* Enable CORS for frontend
* Keep code modular

***

## ✅ Troubleshooting

* **CORS errors**: Add `CORSMiddleware`
* **npm issues**: Delete `node_modules` → `npm install`
* **Port conflicts**: Change port in `uvicorn` or `npm run dev`

***



## ✅ Resources

* <https://fastapi.tiangolo.com/>
* <https://docs.pydantic.dev/>
* <https://react.dev/>
* <https://www.mongodb.com/docs/>

***
5 changes: 5 additions & 0 deletions backend/database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pymongo import MongoClient

client = MongoClient("mongodb://localhost:27017/")
db = client["jsoned_db"]
schemas_collection = db["schemas"]
Loading