@snps/framework
v0.1.0
Published
A zero-dependency, TypeScript-first fullstack web framework with strict enforcement
Maintainers
Readme
Synapse Framework
A zero-dependency, TypeScript-first fullstack web framework with strict enforcement of best practices, TDD, and design patterns. Built with Rust for maximum performance and Node.js for developer experience.
🚀 Features
- Zero Dependencies: Everything built from scratch in TypeScript and Rust
- Strict by Default: Enforce best practices at every level with no escape hatches
- TDD Mandatory: No code without tests - enforced at build time
- Multi-threaded: Leverage all available CPU cores with Rust backend
- Universal: Support any database, storage, hosting, protocol
- Extensible: Plugin system with strict guidelines and validation
- Type-Safe: Full TypeScript support with strict type checking
- High Performance: Rust-based compiler and bundler for maximum speed
- Developer Experience: Comprehensive CLI with all workflows
🏗️ Architecture
Core Components
- Runtime Engine: Multi-threaded Node.js runtime with worker pools
- Rust Compiler: High-performance TypeScript compiler written in Rust
- Rust Bundler: Parallel bundling and optimization engine
- Universal Router: File-based and programmatic routing
- State Management: Reactive state with strict immutability
- Testing Framework: Built-in TDD framework with 100% coverage enforcement
- Linting System: Custom linter with strict rules and auto-fix
- Plugin System: Extensible architecture with strict validation
Package Structure
@synapse/core/ # Core framework
├── runtime/ # Multi-threaded runtime engine
├── compiler/ # TypeScript compiler (Rust bridge)
├── bundler/ # High-performance bundler (Rust)
├── router/ # Universal routing system
├── state/ # Reactive state management
└── types/ # Core type definitions
@synapse/cli/ # Command line interface
├── commands/ # All CLI commands
├── generators/ # Code generators
├── validators/ # Project validators
└── workflows/ # Development workflows
@synapse/server/ # Server framework
├── http/ # HTTP server
├── websocket/ # WebSocket server
├── grpc/ # gRPC server
├── graphql/ # GraphQL server
└── middleware/ # Server middleware
@synapse/client/ # Client framework
├── dom/ # DOM manipulation
├── components/ # Component system
├── routing/ # Client-side routing
└── state/ # Client state management
@synapse/database/ # Database abstraction
├── adapters/ # Database adapters
├── query-builder/ # Query builder
├── migrations/ # Migration system
└── orm/ # ORM layer
@synapse/storage/ # Storage abstraction
├── filesystem/ # File system storage
├── cloud/ # Cloud storage adapters
├── memory/ # In-memory storage
└── cache/ # Caching layer
@synapse/testing/ # Testing framework
├── runner/ # Test runner
├── assertions/ # Assertion library
├── mocks/ # Mocking system
└── coverage/ # Coverage tracking
@synapse/linting/ # Linting system
├── rules/ # Custom linting rules
├── formatters/ # Code formatters
├── validators/ # Type validators
└── enforcers/ # Enforcement engine
@synapse/plugins/ # Plugin system
├── core/ # Core plugin interfaces
├── registry/ # Plugin registry
├── loader/ # Plugin loader
└── validator/ # Plugin validator
@synapse/deployment/ # Deployment system
├── builders/ # Build adapters
├── packagers/ # Package generators
├── deployers/ # Deployment adapters
└── monitors/ # Health monitoring🚀 Quick Start
Prerequisites
- Node.js 18+
- Rust 1.70+ (for building from source)
- Git
Installation
From Source (Recommended)
# Clone the repository
git clone https://github.com/synapse-framework/synapse.git
cd synapse
# Build the framework
make build
# Install globally
make installFrom NPM (Coming Soon)
# Install globally
npm install -g @synapse/frameworkCreate Your First Project
# Create new project
synapse init my-awesome-app
# Navigate to project
cd my-awesome-app
# Start development server
synapse dev📚 Usage
CLI Commands
# Project Management
synapse init <name> # Initialize new project
synapse generate <type> <name> # Generate code (component, api, test, etc.)
# Development
synapse dev # Start development server
synapse build # Build for production
synapse test # Run test suite
synapse test:watch # Run tests in watch mode
# Code Quality
synapse lint # Lint codebase
synapse format # Format code
synapse analyze # Analyze project
# Database
synapse db:migrate # Run migrations
synapse db:seed # Seed database
synapse db:reset # Reset database
# Deployment
synapse deploy # Deploy application
synapse deploy:preview # Create preview deployment
# Plugins
synapse plugin:install <name> # Install plugin
synapse plugin:uninstall <name> # Uninstall plugin
synapse plugin:list # List plugins
# Utilities
synapse clean # Clean build artifacts
synapse optimize # Optimize project
synapse monitor # Monitor applicationCode Generation
# Generate React component
synapse generate component Button --props '{"variant": "primary", "size": "large"}'
# Generate API endpoint
synapse generate api users --methods '["GET", "POST", "PUT", "DELETE"]'
# Generate database model
synapse generate model User --fields '{"name": "string", "email": "string", "age": "number"}'
# Generate test file
synapse generate test UserService --coverage
# Generate documentation
synapse generate docs API --format markdown🔧 Configuration
Framework Configuration (synapse.config.ts)
import { defineConfig } from '@synapse/framework';
export default defineConfig({
// Compiler options
compiler: {
target: 'ES2022',
strict: true,
minify: true,
sourceMaps: true,
treeShaking: true,
codeSplitting: true
},
// Server options
server: {
port: 3000,
host: 'localhost',
https: false,
cors: true
},
// Database options
database: {
type: 'postgresql',
connectionString: process.env.DATABASE_URL,
migrations: true,
seeding: true
},
// Testing options
testing: {
coverage: true,
threshold: 100,
parallel: true,
watch: false
},
// Linting options
linting: {
strict: true,
autoFix: true,
formatOnSave: true,
tddEnforcement: true
},
// Deployment options
deployment: {
platform: 'vercel',
environment: 'production',
autoDeploy: true
}
});TypeScript Configuration (tsconfig.json)
{
"extends": "@synapse/framework/tsconfig",
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"exactOptionalPropertyTypes": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true
}
}🧪 Testing
TDD Enforcement
Synapse enforces Test-Driven Development by default:
// ❌ This will fail - no tests
export function calculateTotal(items: Item[]): number {
return items.reduce((sum, item) => sum + item.price, 0);
}
// ✅ This will pass - has tests
export function calculateTotal(items: Item[]): number {
return items.reduce((sum, item) => sum + item.price, 0);
}
// tests/calculateTotal.test.ts
import { calculateTotal } from '../src/calculateTotal';
import { expect, test } from '@synapse/testing';
test('calculateTotal should sum item prices', () => {
const items = [
{ price: 10 },
{ price: 20 },
{ price: 30 }
];
expect(calculateTotal(items)).toBe(60);
});Test Commands
# Run all tests
synapse test
# Run tests in watch mode
synapse test:watch
# Run tests with coverage
synapse test --coverage
# Run specific test file
synapse test --pattern "**/*.test.ts"
# Run performance tests
synapse test:perf🔍 Linting & Formatting
Strict Linting Rules
Synapse includes comprehensive linting rules:
// ❌ These will fail linting
const unused = 'variable'; // Unused variable
let mutable = 'value'; // Mutable variable
function bad() { return; } // Missing return type
class Bad { prop = 1; } // Missing access modifier
// ✅ These will pass linting
const used = 'variable'; // Used variable
const immutable = 'value'; // Immutable variable
function good(): string { // Explicit return type
return 'value';
}
class Good {
public prop = 1; // Explicit access modifier
}Linting Commands
# Lint codebase
synapse lint
# Lint with auto-fix
synapse lint --fix
# Format code
synapse format
# Check formatting
synapse format --check🗄️ Database Support
Universal Database Abstraction
import { Database } from '@synapse/database';
// Works with any database
const db = new Database({
type: 'postgresql', // or 'mysql', 'sqlite', 'mongodb', etc.
connectionString: process.env.DATABASE_URL
});
// Type-safe queries
const users = await db.query<User>('SELECT * FROM users WHERE age > ?', [18]);
// Migrations
await db.migrate();
// Seeding
await db.seed('users', userData);Supported Databases
- SQL: PostgreSQL, MySQL, SQLite, SQL Server
- NoSQL: MongoDB, CouchDB, Redis
- Graph: Neo4j, ArangoDB
- Time-series: InfluxDB, TimescaleDB
- Search: Elasticsearch, Solr
🌐 Server Framework
Multiple Protocol Support
import { Server } from '@synapse/server';
const server = new Server({
port: 3000,
protocols: ['http', 'websocket', 'grpc', 'graphql']
});
// HTTP routes
server.get('/api/users', async (req, res) => {
const users = await db.query('SELECT * FROM users');
res.json(users);
});
// WebSocket
server.ws('/ws', (socket) => {
socket.on('message', (data) => {
socket.broadcast(data);
});
});
// GraphQL
server.graphql(`
type User {
id: ID!
name: String!
email: String!
}
type Query {
users: [User!]!
}
`);🔌 Plugin System
Creating Plugins
import { Plugin, PluginContext } from '@synapse/plugins';
export class MyPlugin implements Plugin {
readonly id = 'my-plugin';
readonly name = 'My Plugin';
readonly version = '1.0.0';
readonly dependencies = [];
readonly hooks = [];
readonly commands = [];
readonly middleware = [];
readonly components = [];
async install(context: PluginContext): Promise<void> {
// Plugin installation logic
}
async uninstall(context: PluginContext): Promise<void> {
// Plugin uninstallation logic
}
}Plugin Commands
# Install plugin
synapse plugin:install @synapse/plugin-auth
# Uninstall plugin
synapse plugin:uninstall @synapse/plugin-auth
# List plugins
synapse plugin:list🚀 Deployment
Supported Platforms
- Vercel: Zero-config deployment
- Netlify: Static site deployment
- AWS: Lambda, ECS, EC2
- Google Cloud: Cloud Run, App Engine
- Azure: Functions, App Service
- Docker: Container deployment
- Kubernetes: Container orchestration
Deployment Commands
# Deploy to production
synapse deploy
# Deploy preview
synapse deploy:preview
# Deploy to specific platform
synapse deploy --platform vercel
# Deploy with environment
synapse deploy --env staging⚡ Performance
Built-in Optimizations
- Rust Compiler: 10x faster than TypeScript compiler
- Parallel Processing: Multi-threaded compilation and bundling
- Tree Shaking: Dead code elimination
- Code Splitting: Automatic bundle optimization
- Asset Optimization: Image, font, and CSS optimization
- Caching: Intelligent build and runtime caching
Performance Monitoring
# Monitor application
synapse monitor
# Analyze bundle
synapse analyze --bundle
# Optimize project
synapse optimize🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
# Clone repository
git clone https://github.com/synapse-framework/synapse.git
cd synapse
# Install dependencies
make setup
# Build framework
make build
# Run tests
make test
# Start development
make dev📄 License
MIT License - see LICENSE file for details.
🙏 Acknowledgments
- Rust Community: For the amazing language and ecosystem
- TypeScript Team: For the excellent type system
- Node.js Community: For the runtime and ecosystem
- All Contributors: Thank you for making this possible!
📞 Support
- Documentation: docs.synapse.dev
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Discord: Join our Discord
Built with ❤️ by the Synapse Framework Team
