π What is Zero?
Zero is a note-taking and content management platform designed for students and educators. It provides concrete, no-nonsense tools for organizing study materials, creating notes, and managing content with modern web technologies.
π Database Schema
ποΈ Core Entities
- Users: Phone-based authentication with email support
- Notes: Rich content with title, description, and resources
- NoteLikes: Social interaction tracking
- NoteReposts: Content sharing with optional comments
- PasswordTokens: Secure password reset functionality
π Relationships
- Users can create multiple notes
- Notes can have multiple likes and reposts
- Users can like and repost notes from others
- Password tokens are linked to specific users
π File Management
- Resource Attachment: JSON array of file and URL resources
- Cloud Storage: Multi-provider support (AWS S3, GCS, Azure)
- File Validation: Size limits and type checking
- Async Processing: Background file handling
π Search & Discovery
- User Search: Find users by name or phone
- Note Search: Full-text search across note content
- Admin Filters: Advanced filtering in admin panel
- Public Feed: Browse publicly available notes
π― Current Implementation
π Note Management
- Create & Edit: Rich note creation with title, description, and content
- Resource Attachment: Add URLs and file uploads to notes
- Visibility Control: Set notes as public or private
- Share Links: Generate unique sharing tokens for notes
- AI Processing: Background AI curriculum generation (placeholder)
π₯ Social Features
- Like System: Users can like notes from others
- Repost Feature: Share notes with optional comments
- User Profiles: Basic user management with phone-based authentication
- Public Feed: Browse and interact with public notes
π Authentication & Security
- Phone Verification: WhatsApp-based registration and login
- Password Reset: Email-based password recovery
- Secure Tokens: JWT-based authentication system
- Admin Access: Administrative panel for user and content management
π¨ User Interface
- Responsive Design: Mobile-first approach with TailwindCSS
- Component-Based: Type-safe HTML with Gomponents
- Interactive Elements: HTMX for dynamic interactions
- Modern Styling: DaisyUI components for consistent design
π οΈ Tech Stack
- Backend: Go with Fiber framework
- Database: PostgreSQL with Ent ORM
- Frontend: HTMX + DaisyUI + TailwindCSS
- Components: Gomponents for type-safe HTML
- Authentication: Phone-based with WhatsApp verification
- File Storage: Multi-provider support (AWS S3, GCS, Azure Blob)
- Email: SMTP integration for password reset
- Background Jobs: Async task processing with worker queues
- Admin Panel: User and content management interface
- Mobile Integration: WhatsApp API for phone verification
- Air - Live reloading
- Make - Build automation
- Go 1.24+ - Latest Go features
π― Quick Start
Prerequisites
1. Get the Code
git clone https://github.com/r-scheele/zero.git
cd zero
2. Install Dependencies
make install # Installs Ent, Air, and Tailwind CSS
3. Create Admin Account
make admin phone=+1234567890
# Note the generated password from console output
4. Start Development Server
make watch # With live reloading
# OR
make run # Standard run
π That's it! Visit http://localhost:8000 to see your application.
πΈ Screenshots
πΌοΈ View Screenshots
User Registration with Validation
Interactive Modal with HTMX
Admin Panel - User Management
Admin Panel - User Editing
Background Task Monitoring
ποΈ Project Structure
zero/
βββ cmd/
β βββ admin/ # Admin CLI tools
β βββ web/ # Web server entry point
βββ config/ # Configuration management
βββ ent/ # Database entities and ORM
βββ pkg/
β βββ handlers/ # HTTP request handlers
β βββ middleware/ # Custom middleware
β βββ services/ # Business logic services
β βββ ui/ # UI components and layouts
β βββ tasks/ # Background tasks
βββ public/ # Static assets
βββ uploads/ # File uploads
π§ Development
Available Commands
make help # Show all available commands
make install # Install all dependencies
make run # Start the application
make watch # Start with live reloading
make test # Run tests
make css # Build Tailwind CSS
make build # Build production binary
make ent-gen # Generate ORM code
make ent-new name=X # Create new entity
make admin phone=X # Create admin user
Creating New Entities
# Create a new database entity
make ent-new name=Product
# Edit the schema in ent/schema/product.go
# Then generate the code
make ent-gen
Development Workflow
- Create handler in
pkg/handlers/
- Add route in
pkg/handlers/router.go
- Create page component in
pkg/ui/pages/
- Add navigation if needed
π¨ UI Development
Component-Based Architecture
Zero uses Gomponents to write HTML in Go, providing type safety and reusability:
func MyComponent(title string) Node {
return Div(
Class("card bg-base-100 shadow-xl"),
Div(
Class("card-body"),
H2(Class("card-title"), Text(title)),
P(Text("Component content here")),
),
)
}
HTMX Integration
Add interactivity without JavaScript:
Button(
Class("btn btn-primary"),
Attr("hx-post", "/api/action"),
Attr("hx-target", "#result"),
Text("Click Me"),
)
Styling with DaisyUI
Use semantic component classes:
Div(
Class("hero min-h-screen bg-base-200"),
Div(
Class("hero-content text-center"),
H1(Class("text-5xl font-bold"), Text("Hello World")),
),
)
π Authentication & Authorization
Features
- β
User registration with email verification
- β
Secure login/logout
- β
Password reset via email
- β
Phone number verification
- β
Admin role management
- β
Session management
- β
CSRF protection
Usage
// Protect routes with authentication
protected := e.Group("/dashboard")
protected.Use(middleware.RequireAuth)
// Admin-only routes
admin := e.Group("/admin")
admin.Use(middleware.RequireAdmin)
π Admin Panel
The admin panel provides comprehensive tools for educators and administrators:
- π₯ Student Management - View, edit, and manage student accounts
- π Content Management - Upload and organize study materials
- π§ Quiz Administration - Create, edit, and monitor quiz performance
- π Analytics Dashboard - Track student progress and engagement
- π Advanced Search - Filter by name, email, course, progress
- π± Mobile Responsive - Manage your platform from any device
- π¨ Intuitive Interface - Clean, educator-friendly design
Educational Features
- Student enrollment management
- Course and material organization
- Quiz creation and grading
- Progress tracking and reporting
- Bulk operations for efficiency
- Real-time student activity monitoring
Access
- Create admin account:
make admin phone=+1234567890
- Login at
/login
- Access admin panel at
/admin
ποΈ Database
Entity Definition
// ent/schema/user.go
func (User) Fields() []ent.Field {
return []ent.Field{
field.String("name").NotEmpty(),
field.String("email").Unique(),
field.String("phone_number").Optional(),
field.Bool("verified").Default(false),
}
}
Querying
// Get users with filters
users, err := client.User.
Query().
Where(user.NameContainsFold("john")).
Order(ent.Asc(user.FieldCreatedAt)).
Limit(10).
All(ctx)
π§ Email System
Templates
Email templates are written in Go using Gomponents:
func WelcomeEmail(userName string) Node {
return HTML(
Head(Title(Text("Welcome!"))),
Body(
H1(Text("Welcome "+userName)),
P(Text("Thanks for joining us!")),
),
)
}
Sending
err := mailService.Send(
"user@example.com",
"Welcome!",
WelcomeEmail("John"),
)
π Background Tasks
Define Tasks
type EmailTask struct {
To string `json:"to"`
Subject string `json:"subject"`
Body string `json:"body"`
}
func (t EmailTask) Handle(ctx context.Context) error {
return sendEmail(t.To, t.Subject, t.Body)
}
Queue Tasks
task := EmailTask{
To: "user@example.com",
Subject: "Welcome!",
Body: "Welcome to our platform!",
}
err := taskService.Queue(task)
π Deployment
Local Development
# Set up environment
cp .env.example .env
# Edit .env with your configuration
# Run database migrations
make migrate
# Create admin user
make admin phone=+1234567890
# Start development server
make dev
Production Deployment
# Build binary
make build
# Run production server
./bin/zero
Docker Deployment
# Build Docker image
docker build -t zero-notes .
# Run with environment variables
docker run -p 8080:8080 \
-e DATABASE_URL="postgres://user:pass@localhost/zero" \
-e SMTP_HOST="smtp.gmail.com" \
zero-notes
Environment Configuration
# Database
DATABASE_URL="postgres://user:password@localhost:5432/zero"
# SMTP for password reset
SMTP_HOST="smtp.gmail.com"
SMTP_PORT=587
SMTP_USERNAME="your-email@gmail.com"
SMTP_PASSWORD="your-app-password"
# WhatsApp Integration (360dialog)
WHATSAPP_API_KEY="your-360dialog-api-key"
WHATSAPP_CHANNEL_ID="your-channel-id"
# Cloud Storage (optional)
AWS_ACCESS_KEY_ID="your-aws-key"
AWS_SECRET_ACCESS_KEY="your-aws-secret"
AWS_REGION="us-east-1"
S3_BUCKET="your-bucket"
# Or Google Cloud Storage
GCS_BUCKET="your-gcs-bucket"
GOOGLE_APPLICATION_CREDENTIALS="path/to/service-account.json"
# Or Azure Blob Storage
AZURE_STORAGE_ACCOUNT="your-account"
AZURE_STORAGE_KEY="your-key"
AZURE_CONTAINER="your-container"
π€ Contributing
We welcome contributions from developers interested in note-taking and content management platforms!
π― Focus Areas
- Core Features: Note management, social features, file handling
- User Experience: Interface improvements, mobile responsiveness
- Performance: Database optimization, background job processing
- Integration: Cloud storage providers, notification systems
- API Development: REST endpoints, authentication improvements
π Development Guidelines
- Follow Go best practices and conventions
- Write tests for new features
- Update documentation for any changes
- Ensure mobile-first responsive design
- Maintain type safety with Gomponents
π Getting Started
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature)
- Make your changes following the existing patterns
- Test thoroughly with different user scenarios
- Commit your changes (
git commit -m 'Add amazing feature')
- Push to the branch (
git push origin feature/amazing-feature)
- Open a Pull Request with detailed description
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Credits
Zero is built on the shoulders of giants. Special thanks to: