|
1 | | -# JavaScriptSolidServer |
2 | | -JavaScriptSolidServer |
| 1 | +# Vision |
| 2 | + |
| 3 | +The goal of this project is to create a hyper-modern, performant, and minimalist JavaScript Solid server. While drawing inspiration from Node Solid Server (NSS), this new implementation will address its shortcomings and prioritize scalability, modularity, and developer usability. |
| 4 | + |
| 5 | +## Key Objectives |
| 6 | + |
| 7 | +- **Performance First:** Capable of handling enterprise-scale loads, targeting thousands to millions of users. |
| 8 | +- **Minimalist Design:** Remove unused and experimental features; focus on what matters most. |
| 9 | +- **Modularity:** Clear separation of identity, authentication, storage, and onboarding. |
| 10 | +- **Developer Friendly:** Clean, well-documented, and extensible codebase that adheres to the Solid specification. |
| 11 | +- **Modern Tooling:** Leverage async/await, native modules, fast HTTP servers like Fastify, and cutting-edge JavaScript runtimes. |
| 12 | +- **HTTP Simplicity:** Prioritize simple HTTP/1.1 compatibility for maximum interoperability. |
| 13 | +- **Frontend Agnostic:** Work with any frontend or application layer via standardized APIs. |
| 14 | +- **Testable and CI Ready:** Fully integrated with Solid test suites and modern CI/CD pipelines. |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +# ARCHITECTURE |
| 19 | + |
| 20 | +## Overview |
| 21 | + |
| 22 | +The architecture is inspired by NSS but modernized and streamlined. Each subsystem is designed to operate independently and follow the single-responsibility principle. |
| 23 | + |
| 24 | +### Components |
| 25 | + |
| 26 | +- **HTTP Layer** |
| 27 | + |
| 28 | + - Fastify server |
| 29 | + - Routing and middleware based on HTTP verbs and Solid operations |
| 30 | + - Blazingly fast, with benchmarks from the start |
| 31 | + |
| 32 | +- **Identity Provider (IDP)** |
| 33 | + |
| 34 | + - Handles Pod based WebIDs |
| 35 | + - Handles external WebIDs |
| 36 | + - Minimal by default, extendable via plugins |
| 37 | + |
| 38 | +- **Authenticaion Module (AUthn)** |
| 39 | + |
| 40 | + - Handles WebID-based authentication, including WebID-TLS |
| 41 | + - OIDC-compliant with modular Authentication |
| 42 | + - Single sign-on including WebID-TLS |
| 43 | + |
| 44 | +- **Authorization Module (Authz)** |
| 45 | + |
| 46 | + - Supports Web Access Control (WAC) |
| 47 | + - Token-based permissions model |
| 48 | + - Modular Authorization system |
| 49 | + |
| 50 | +- **Storage Engine** |
| 51 | + |
| 52 | + - Modular backend adapters (e.g. file system, S3, memory) |
| 53 | + - POD-level quota management (optional) |
| 54 | + - Interoperable with existing Cloud |
| 55 | + |
| 56 | +- **Account and Onboarding** |
| 57 | + - API-first registration |
| 58 | + - Public, private, invite modes |
| 59 | + - Extensible account templates |
| 60 | + |
| 61 | +### Deployment Model |
| 62 | + |
| 63 | +- Works as a single binary or serverless function |
| 64 | +- Container-friendly (Docker, Deno, etc.) |
| 65 | +- CLI for local dev setup and testing |
| 66 | + |
| 67 | +### Separation of Concerns |
| 68 | + |
| 69 | +- Each subsystem lives in its own module/package |
| 70 | +- Clear boundaries between IDP and storage |
| 71 | +- Frontend-independent API endpoints |
| 72 | + |
| 73 | +### Compatibility |
| 74 | + |
| 75 | +- Solid-compliant, LWS Compliant |
| 76 | +- API parity with NSS where applicable |
| 77 | +- API parity with CSS where applicable |
| 78 | + |
| 79 | +--- |
| 80 | + |
| 81 | +# MVP Implementation |
| 82 | + |
| 83 | +This is a minimal viable product (MVP) implementation of the JavaScriptSolid server. It includes the core components needed to demonstrate the concept while omitting some of the more complex features for simplicity. |
| 84 | + |
| 85 | +## Getting Started |
| 86 | + |
| 87 | +### Prerequisites |
| 88 | + |
| 89 | +- Node.js 18 or higher |
| 90 | + |
| 91 | +### Installation |
| 92 | + |
| 93 | +```bash |
| 94 | +# Clone the repository |
| 95 | +git clone https://github.com/yourusername/javascript-solid-server.git |
| 96 | +cd javascript-solid-server |
| 97 | + |
| 98 | +# Install dependencies |
| 99 | +npm install |
| 100 | +``` |
| 101 | + |
| 102 | +### Running the Server |
| 103 | + |
| 104 | +```bash |
| 105 | +# Start the server |
| 106 | +npm start |
| 107 | +``` |
| 108 | + |
| 109 | +The server will be available at http://localhost:3000 by default. |
| 110 | + |
| 111 | +## Features Included in MVP |
| 112 | + |
| 113 | +- **HTTP Server**: Based on Fastify for high performance |
| 114 | +- **Basic Identity Provider**: Simple user registration and login with JWT tokens |
| 115 | +- **Simple Authorization**: Basic implementation of WAC (Web Access Control) |
| 116 | +- **File-based Storage**: Local filesystem storage for Solid resources |
| 117 | +- **Basic Solid Protocol Support**: GET, PUT, DELETE, PATCH, and HEAD operations |
| 118 | + |
| 119 | +## Features Omitted in MVP (to be added later) |
| 120 | + |
| 121 | +1. WebID-TLS Authentication |
| 122 | +2. Full OIDC implementation |
| 123 | +3. Advanced WAC features and ACL file parsing |
| 124 | +4. Quotas and resource limits |
| 125 | +5. Advanced container management |
| 126 | +6. SPARQL and N3 Patch support |
| 127 | +7. Notification systems |
| 128 | + |
| 129 | +## API Usage Examples |
| 130 | + |
| 131 | +### User Registration |
| 132 | + |
| 133 | +```bash |
| 134 | +curl -X POST http://localhost:3000/register \ |
| 135 | + -H "Content-Type: application/json" \ |
| 136 | + -d '{"username": "alice", "password": "secret", "email": "alice@example.com"}' |
| 137 | +``` |
| 138 | + |
| 139 | +### Login |
| 140 | + |
| 141 | +```bash |
| 142 | +curl -X POST http://localhost:3000/login \ |
| 143 | + -H "Content-Type: application/json" \ |
| 144 | + -d '{"username": "alice", "password": "secret"}' |
| 145 | +``` |
| 146 | + |
| 147 | +### Accessing Resources |
| 148 | + |
| 149 | +```bash |
| 150 | +# Get a resource |
| 151 | +curl -X GET http://localhost:3000/alice/profile \ |
| 152 | + -H "Authorization: Bearer YOUR_TOKEN_HERE" |
| 153 | + |
| 154 | +# Create or update a resource |
| 155 | +curl -X PUT http://localhost:3000/alice/profile \ |
| 156 | + -H "Authorization: Bearer YOUR_TOKEN_HERE" \ |
| 157 | + -H "Content-Type: text/turtle" \ |
| 158 | + -d '@prefix foaf: <http://xmlns.com/foaf/0.1/>. <#me> a foaf:Person; foaf:name "Alice".' |
| 159 | +``` |
| 160 | + |
| 161 | +## Performance Benchmarking |
| 162 | + |
| 163 | +This project includes a comprehensive benchmarking tool to measure server performance under various loads. |
| 164 | + |
| 165 | +### Running the Benchmark |
| 166 | + |
| 167 | +```bash |
| 168 | +# Make sure the server is running in a separate terminal |
| 169 | +npm start |
| 170 | + |
| 171 | +# In another terminal, run the benchmark |
| 172 | +npm run benchmark |
| 173 | +``` |
| 174 | + |
| 175 | +The benchmark will: |
| 176 | + |
| 177 | +1. Create multiple test users |
| 178 | +2. Execute various operations (register, login, read, write, delete) |
| 179 | +3. Measure response times for each operation type |
| 180 | +4. Test different concurrency levels (1, 5, 10, 50, 100 users) |
| 181 | +5. Calculate throughput (operations per second) |
| 182 | + |
| 183 | +### Visualizing Results |
| 184 | + |
| 185 | +After running the benchmark, you can generate a visual report: |
| 186 | + |
| 187 | +```bash |
| 188 | +# Generate an HTML report with charts |
| 189 | +npm run visualize benchmark-report-[timestamp].json |
| 190 | +``` |
| 191 | + |
| 192 | +Open the generated HTML file in a browser to see: |
| 193 | + |
| 194 | +- Average response times for each operation type |
| 195 | +- Throughput metrics at different concurrency levels |
| 196 | +- Visual charts for easy performance analysis |
| 197 | + |
| 198 | +### Customizing Benchmarks |
| 199 | + |
| 200 | +You can customize the benchmark parameters in `benchmark.js`: |
| 201 | + |
| 202 | +- Concurrent users levels |
| 203 | +- Operations per user |
| 204 | +- Test duration |
| 205 | +- Test user credentials |
| 206 | + |
| 207 | +## Contributing |
| 208 | + |
| 209 | +Contributions are welcome! Please feel free to submit a Pull Request. |
0 commit comments