https://github.com/shuddha2021/rubyconnect
A professional web application built with Ruby, Sinatra, and SQLite.
https://github.com/shuddha2021/rubyconnect
bootstrap contactform database educational modaldialog professionalapp ruby sinatra sqlite3 usermanagement webapplication
Last synced: 3 months ago
JSON representation
A professional web application built with Ruby, Sinatra, and SQLite.
- Host: GitHub
- URL: https://github.com/shuddha2021/rubyconnect
- Owner: shuddha2021
- Created: 2024-04-09T15:19:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-01T20:05:53.000Z (about 2 years ago)
- Last Synced: 2025-02-17T07:42:15.024Z (over 1 year ago)
- Topics: bootstrap, contactform, database, educational, modaldialog, professionalapp, ruby, sinatra, sqlite3, usermanagement, webapplication
- Language: HTML
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RubyConnect
A full-featured user management web application built with Ruby, Sinatra, and SQLite3. Modern UI, full CRUD, search & pagination, role-based badges, contact form, dark/light theme, JSON API, and comprehensive test suite — all with zero JavaScript frameworks.




## Features
| Feature | Description |
|---|---|
| **Full CRUD** | Create, read, update, and delete users with server-side validation |
| **Search** | Real-time search across names and emails with result counts |
| **Pagination** | Automatic page splitting for large user lists |
| **Role Badges** | Color-coded admin / member / viewer role badges |
| **KPI Dashboard** | At-a-glance stats strip — total users, admins, members, viewers |
| **Contact Form** | Modal contact form that persists messages to the database |
| **Dark / Light Theme** | System-aware toggle, persisted in localStorage |
| **JSON API** | RESTful API endpoints for programmatic access |
| **Input Validation** | Server-side name, email, and duplicate checks |
| **Flash Messages** | Auto-dismissing success/error notifications |
| **Responsive** | Mobile-first layout; table columns hide gracefully on small screens |
| **Zero JS Frameworks** | Vanilla CSS + JS — no Bootstrap, no jQuery, no build step |
| **Test Suite** | 25+ Minitest tests covering routes, database, and edge cases |
## Architecture
```
app.rb ← Sinatra routes (web + API), helpers, config
config.ru ← Rack entry point (for Puma / deployment)
Gemfile ← Dependencies
Rakefile ← Database setup task
setup_db.rb ← Quick seed script
lib/
database.rb ← Thread-safe SQLite3 wrapper, all queries
views/
layout.erb ← HTML shell, nav, footer, contact modal
index.erb ← Dashboard: KPIs, toolbar, table, pagination
form.erb ← New / edit user form
not_found.erb ← 404 page
public/
style.css ← Full design system (CSS custom properties)
app.js ← Theme toggle, modal, alert auto-dismiss
test/
app_test.rb ← Integration tests (Rack::Test)
database_test.rb ← Unit tests for Database module
```
## Getting Started
### Prerequisites
- **Ruby 3.x** — [install](https://www.ruby-lang.org/en/downloads/)
- **Bundler** — `gem install bundler`
### Install & Run
```bash
git clone https://github.com/shuddha2021/RubyConnect.git
cd RubyConnect
bundle install
ruby setup_db.rb # creates & seeds the database
ruby app.rb # starts server on http://localhost:4567
```
### Run Tests
```bash
bundle exec ruby test/app_test.rb
bundle exec ruby test/database_test.rb
```
## API Reference
| Method | Endpoint | Description |
|---|---|---|
| `GET` | `/api/users` | All users (JSON array) |
| `GET` | `/api/users/:id` | Single user by ID |
| `GET` | `/api/stats` | Dashboard statistics |
### Example
```bash
curl http://localhost:4567/api/users | jq
curl http://localhost:4567/api/stats | jq
```
## Web Routes
| Method | Path | Description |
|---|---|---|
| `GET` | `/` | Dashboard with search & pagination |
| `GET` | `/users/new` | New user form |
| `POST` | `/users` | Create user |
| `GET` | `/users/:id/edit` | Edit user form |
| `POST` | `/users/:id` | Update user |
| `POST` | `/users/:id/delete` | Delete user |
| `POST` | `/contact` | Submit contact message |
## Customization
| Option | File | What to change |
|---|---|---|
| Port | `app.rb` | Set `PORT` env var or edit `set :port` |
| Theme colors | `public/style.css` | Edit CSS custom properties in `:root` |
| Seed data | `lib/database.rb` | Edit the `seed!` method |
| Roles | `lib/database.rb` + `app.rb` | Add to the CHECK constraint + validation arrays |
| Pagination size | `app.rb` | Change `per = 10` |
## License
MIT