Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 2 additions & 47 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,49 +1,4 @@
# .gitignore

# Node
node_modules/
node_modules
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
package-lock.json
yarn.lock
.pnp/
.pnp.js

# Build Output
dist/
build/
out/
.next/
*.log

# Environment Variables
.env
.env.local
.env.*.local

# Python
__pycache__/
*.pyc
*.pyo
*.pyd
env/
venv/
.venv/

# OS Files
.DS_Store
Thumbs.db

# IDE Files
.vscode/
.idea/

# Cache & Temp
.cache/
coverage/
tmp/

# TypeScript
*.tsbuildinfo
frontend/dist
17 changes: 17 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "backend",
"version": "1.0.0",
"description": "DelegateOS backend server",
"main": "src/index.js",
"scripts": {
"start": "node src/index.js"
},
"keywords": [],
"author": "",
"license": "MIT",
"type": "commonjs",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.18.2"
}
}
8 changes: 8 additions & 0 deletions backend/src/api/committees.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const express = require('express');
const { getCommittees } = require('../controllers/committeeController');

const router = express.Router();

router.get('/committees', getCommittees);

module.exports = router;
5 changes: 5 additions & 0 deletions backend/src/controllers/committeeController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const committees = require('../models/committee');

exports.getCommittees = (req, res) => {
res.json(committees);
};
19 changes: 19 additions & 0 deletions backend/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const express = require('express');
const cors = require('cors');
const committeesRouter = require('./api/committees');

const app = express();
const PORT = process.env.PORT || 3000;

app.use(cors());
app.use(express.json());

app.use(committeesRouter);

app.get('/', (req, res) => {
res.send('DelegateOS backend running');
});

app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
4 changes: 4 additions & 0 deletions backend/src/models/committee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = [
{ id: 1, name: "UNGA", description: "General Assembly" },
{ id: 2, name: "UNSC", description: "Security Council" }
];
12 changes: 12 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>DelegateOS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.2"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.4",
"vite": "^5.4.10"
}
}
52 changes: 52 additions & 0 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.app {
max-width: 960px;
margin: 0 auto;
padding: 24px;
}

.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 0;
border-bottom: 1px solid #e5e7eb;
margin-bottom: 24px;
}

.nav {
display: flex;
gap: 16px;
}

.nav-link {
font-weight: 600;
padding: 8px 12px;
border-radius: 6px;
}

.nav-link:hover {
background-color: #e5e7eb;
}

.content h1 {
margin-top: 0;
}

.table {
width: 100%;
border-collapse: collapse;
background-color: white;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.table th,
.table td {
padding: 12px;
border: 1px solid #e5e7eb;
text-align: left;
}

.error {
color: #b91c1c;
font-weight: 600;
}
33 changes: 33 additions & 0 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Routes, Route, Link } from 'react-router-dom';
import Committees from './pages/Committees';
import './App.css';

function Home() {
return (
<section className="content">
<h1>Welcome to DelegateOS</h1>
<p>Select a page from the navigation.</p>
</section>
);
}

function App() {
return (
<div className="app">
<header className="header">
<nav className="nav">
<Link to="/" className="nav-link">Home</Link>
<Link to="/committees" className="nav-link">Committees</Link>
</nav>
</header>
<main>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/committees" element={<Committees />} />
</Routes>
</main>
</div>
);
}

export default App;
18 changes: 18 additions & 0 deletions frontend/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
:root {
font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
color: #1f2937;
background-color: #f9fafb;
}

body {
margin: 0;
}

#root {
min-height: 100vh;
}

a {
color: inherit;
text-decoration: none;
}
13 changes: 13 additions & 0 deletions frontend/src/main.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import App from './App';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<BrowserRouter>
<App />
</BrowserRouter>
</React.StrictMode>
);
60 changes: 60 additions & 0 deletions frontend/src/pages/Committees.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { useEffect, useState } from 'react';

const API_BASE = import.meta.env.VITE_API_BASE || '';

function Committees() {
const [committees, setCommittees] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState('');

useEffect(() => {
const fetchCommittees = async () => {
try {
setLoading(true);
setError('');
const response = await fetch(`${API_BASE}/committees`);
if (!response.ok) {
throw new Error('Failed to fetch committees');
}
const data = await response.json();
setCommittees(data);
} catch (err) {
setError(err.message || 'An error occurred');
} finally {
setLoading(false);
}
};

fetchCommittees();
}, []);

return (
<section className="content">
<h1>Committees</h1>
{loading && <p>Loading…</p>}
{error && <p className="error">{error}</p>}
{!loading && !error && (
<table className="table">
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{committees.map((committee) => (
<tr key={committee.id}>
<td>{committee.id}</td>
<td>{committee.name}</td>
<td>{committee.description}</td>
</tr>
))}
</tbody>
</table>
)}
</section>
);
}

export default Committees;
11 changes: 11 additions & 0 deletions frontend/vite.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
plugins: [react()],
server: {
proxy: {
'/committees': 'http://localhost:3000'
}
}
});