|
| 1 | +# ContractSpark ✦ |
| 2 | + |
| 3 | +**Beautiful Contracts That Protect You** |
| 4 | + |
| 5 | +ContractSpark is a premium, open-source contract generator for freelancers and small businesses. Create professional legal agreements in minutes — powered by AI, exported as perfect PDFs. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **8 Professional Templates** — Freelance Agreement, Service Contract, NDA, Consulting Agreement, Client Retainer, Partnership Agreement, Employment Offer, Website Design Contract |
| 12 | +- **AI Smart Builder** — Paste a project brief and get a complete contract instantly (powered by Claude) |
| 13 | +- **Live Preview** — Real-time document preview that mirrors your PDF exactly |
| 14 | +- **Custom Branding** — Upload your logo, pick accent colors, choose document styles |
| 15 | +- **Payment Milestones** — Visual payment schedule with percentage breakdowns |
| 16 | +- **One-Click PDF Export** — Print-ready, professional A4 documents |
| 17 | +- **Save & Load** — Store up to 20 contracts in browser localStorage |
| 18 | +- **Dark / Light Mode** — Beautiful in both themes |
| 19 | +- **100% Client-Side** — No backend, no account, no tracking |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Getting Started |
| 24 | + |
| 25 | +### Option 1: Just Open It |
| 26 | + |
| 27 | +```bash |
| 28 | +# Clone the repo |
| 29 | +git clone https://github.com/yourusername/contractspark.git |
| 30 | +cd contractspark |
| 31 | + |
| 32 | +# Open in browser (no build step required) |
| 33 | +open index.html |
| 34 | +``` |
| 35 | + |
| 36 | +### Option 2: Local Server |
| 37 | + |
| 38 | +```bash |
| 39 | +# Using Python |
| 40 | +python3 -m http.server 8080 |
| 41 | + |
| 42 | +# Using Node.js |
| 43 | +npx serve . |
| 44 | + |
| 45 | +# Then visit |
| 46 | +open http://localhost:8080 |
| 47 | +``` |
| 48 | + |
| 49 | +--- |
| 50 | + |
| 51 | +## AI Smart Builder Setup |
| 52 | + |
| 53 | +ContractSpark uses the [Anthropic Claude API](https://anthropic.com) for AI-powered contract generation. Without an API key, it gracefully falls back to template-based generation. |
| 54 | + |
| 55 | +To enable AI generation, the app calls `https://api.anthropic.com/v1/messages` directly from the browser. Note: for production use, you should proxy API calls through your own backend to protect your key. |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## Project Structure |
| 60 | + |
| 61 | +``` |
| 62 | +contractspark/ |
| 63 | +├── index.html # Main app entry point |
| 64 | +├── css/ |
| 65 | +│ └── style.css # All styles (dark theme, preview, forms) |
| 66 | +├── js/ |
| 67 | +│ ├── main.js # Alpine.js app controller |
| 68 | +│ ├── contract-data.js # Templates, clauses, data structures |
| 69 | +│ ├── smart-builder.js # AI generation + local fallback |
| 70 | +│ ├── preview-renderer.js # Live HTML preview rendering |
| 71 | +│ ├── pdf-export.js # jsPDF-based PDF generation |
| 72 | +│ └── utils.js # Shared helpers (dates, storage, colors) |
| 73 | +├── assets/ |
| 74 | +│ └── icons/ # SVG icon assets |
| 75 | +├── README.md |
| 76 | +├── LICENSE |
| 77 | +└── .gitignore |
| 78 | +``` |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +## Tech Stack |
| 83 | + |
| 84 | +| Layer | Technology | |
| 85 | +|-------|-----------| |
| 86 | +| UI Framework | [Alpine.js](https://alpinejs.dev/) v3 | |
| 87 | +| Styling | [Tailwind CSS](https://tailwindcss.com/) via CDN | |
| 88 | +| PDF Generation | [jsPDF](https://github.com/parallax/jsPDF) + AutoTable | |
| 89 | +| AI | [Anthropic Claude API](https://docs.anthropic.com/) | |
| 90 | +| Storage | Browser localStorage | |
| 91 | +| Fonts | Cormorant Garamond + DM Sans + DM Mono | |
| 92 | + |
| 93 | +--- |
| 94 | + |
| 95 | +## Customization |
| 96 | + |
| 97 | +### Adding a New Template |
| 98 | + |
| 99 | +In `js/contract-data.js`, add a new entry to the `CONTRACT_TEMPLATES` array: |
| 100 | + |
| 101 | +```javascript |
| 102 | +{ |
| 103 | + id: 'my-template', |
| 104 | + name: 'My Contract Type', |
| 105 | + description: 'What this contract is for.', |
| 106 | + tags: ['Tag1', 'Tag2'], |
| 107 | + icon: `<svg>...</svg>`, |
| 108 | + meta: { type: 'my-template', title: 'My Contract Agreement' }, |
| 109 | + getClauses: (data) => [ |
| 110 | + { |
| 111 | + id: 'clause-1', |
| 112 | + title: 'My Clause', |
| 113 | + enabled: true, |
| 114 | + content: `Clause content using ${data.partyA?.name} and ${data.scopeOfWork}...` |
| 115 | + }, |
| 116 | + // more clauses... |
| 117 | + ] |
| 118 | +} |
| 119 | +``` |
| 120 | +
|
| 121 | +### Changing Default Colors |
| 122 | +
|
| 123 | +Edit the `:root` CSS variables in `css/style.css`: |
| 124 | +
|
| 125 | +```css |
| 126 | +:root { |
| 127 | + --accent: #c9a96e; /* Main gold accent */ |
| 128 | +} |
| 129 | +``` |
| 130 | +
|
| 131 | +--- |
| 132 | +
|
| 133 | +## Browser Support |
| 134 | +
|
| 135 | +ContractSpark works in all modern browsers: |
| 136 | +- Chrome / Edge 90+ |
| 137 | +- Firefox 88+ |
| 138 | +- Safari 14+ |
| 139 | +- Mobile Safari / Chrome for iOS/Android |
| 140 | +
|
| 141 | +--- |
| 142 | +
|
| 143 | +## License |
| 144 | +
|
| 145 | +MIT License — free for personal and commercial use. See [LICENSE](./LICENSE). |
| 146 | +
|
| 147 | +--- |
| 148 | +
|
| 149 | +## Contributing |
| 150 | +
|
| 151 | +Pull requests welcome! Please open an issue first to discuss major changes. |
| 152 | +
|
| 153 | +--- |
| 154 | +
|
| 155 | +*ContractSpark is not a law firm and does not provide legal advice. Contracts generated are templates and should be reviewed by a qualified attorney before use in important business transactions.* |
0 commit comments