Echo web app
  • Go 38%
  • HTML 27.5%
  • JavaScript 18.9%
  • CSS 15.6%
Find a file
2025-11-04 18:34:21 -08:00
database first commit 2025-11-04 18:34:21 -08:00
handlers first commit 2025-11-04 18:34:21 -08:00
middleware first commit 2025-11-04 18:34:21 -08:00
models first commit 2025-11-04 18:34:21 -08:00
services first commit 2025-11-04 18:34:21 -08:00
static first commit 2025-11-04 18:34:21 -08:00
.env.bak first commit 2025-11-04 18:34:21 -08:00
.gitignore first commit 2025-11-04 18:34:21 -08:00
go.mod first commit 2025-11-04 18:34:21 -08:00
go.sum first commit 2025-11-04 18:34:21 -08:00
main.go first commit 2025-11-04 18:34:21 -08:00
README.md first commit 2025-11-04 18:34:21 -08:00
schema.sql first commit 2025-11-04 18:34:21 -08:00

Innovative Axis - Go Echo Application

A modern content management platform built with Go and the Echo web framework for displaying and managing markdown documents.

Tech Stack

  • Backend: Go with Echo framework
  • Frontend: Vanilla JavaScript, HTML5, CSS3
  • Authentication: JWT (to be implemented)
  • Storage: In-memory (will be replaced with database)

Project Structure

innovative-axis/
├── main.go                 # Application entry point
├── go.mod                  # Go module dependencies
├── handlers/
│   └── handlers.go        # HTTP request handlers
├── middleware/
│   └── auth.go           # Authentication middleware
├── models/
│   └── models.go         # Data structures
├── services/
│   └── markdown.go       # Business logic
├── static/
│   ├── index.html        # Main HTML page
│   ├── styles.css        # Styling with theme variables
│   └── script.js         # Frontend JavaScript
└── README.md             # This file

Installation

  1. Install Go (version 1.21 or higher)

    # Download from https://golang.org/dl/
    
  2. Install PostgreSQL (version 12 or higher)

    # macOS
    brew install postgresql@14
    brew services start postgresql@14
    
    # Ubuntu/Debian
    sudo apt update
    sudo apt install postgresql postgresql-contrib
    sudo systemctl start postgresql
    
    # Windows
    # Download from https://www.postgresql.org/download/windows/
    
  3. Clone or download this project

  4. Set up the database

    # Create database and schema
    psql -U postgres -f database/schema.sql
    
    # Or manually:
    psql -U postgres
    CREATE DATABASE innovative_axis;
    \c innovative_axis
    # Then run the schema from database/schema.sql
    
  5. Configure environment variables

    cp .env.example .env
    # Edit .env with your database credentials
    
  6. Install dependencies

    cd innovative-axis
    go mod download
    

Running the Application

  1. Ensure PostgreSQL is running

    # Check if PostgreSQL is running
    psql -U postgres -c "SELECT version();"
    
  2. Set environment variables (if not using .env file)

    export DB_HOST=localhost
    export DB_PORT=5432
    export DB_USER=postgres
    export DB_PASSWORD=your_password
    export DB_NAME=innovative_axis
    export DB_SSLMODE=disable
    
  3. Start the server

    go run main.go
    
  4. Access the application Open your browser and navigate to:

    http://localhost:8080
    

API Endpoints

Public Endpoints

  • GET / - Serves the main page
  • GET /api/files - Get all markdown files
  • GET /api/files/:id - Get a specific file by ID
  • POST /api/subscribe - Subscribe (placeholder)
  • POST /api/login - User login (placeholder)

Protected Endpoints (require authentication)

  • POST /api/upload - Upload a new markdown file
  • GET /api/profile - Get user profile
  • PUT /api/profile/theme - Update user theme

Configuration

Environment Variables

Create a .env file in the root directory (see .env.example):

# Database Configuration
DB_HOST=localhost          # PostgreSQL host
DB_PORT=5432              # PostgreSQL port
DB_USER=postgres          # Database user
DB_PASSWORD=your_password # Database password
DB_NAME=innovative_axis   # Database name
DB_SSLMODE=disable        # SSL mode (disable for local dev)

# Application Configuration
PORT=8080                 # Server port

Database Schema

The application automatically creates tables on startup:

  • users: Admin and user accounts
  • themes: User theme preferences
  • markdown_files: Markdown document storage with GIN-indexed tags

Database Management

# View all files
psql -U postgres -d innovative_axis -c "SELECT id, title, date FROM markdown_files;"

# Delete a file
psql -U postgres -d innovative_axis -c "DELETE FROM markdown_files WHERE id='file-id';"

# Clear all files
psql -U postgres -d innovative_axis -c "TRUNCATE markdown_files;"

Markdown File Format

Each markdown file should follow this structure:

# Title of the Document
Date: YYYY-MM-DD
Tags: tag1, tag2, tag3

Main content goes here...

Uploading Files via API

curl -X POST http://localhost:8080/api/upload \
  -H "Content-Type: application/json" \
  -d '{
    "content": "# My Document\nDate: 2025-01-15\nTags: tutorial, guide\n\nContent here...",
    "filename": "my-document.md"
  }'

Theme Customization

The application uses CSS variables for theming. All theme colors are defined in static/styles.css under the :root selector.

Available Theme Variables

  • Header: --header-bg, --header-text
  • Buttons: --btn-subscribe-bg, --btn-login-bg, etc.
  • Containers: --container-border, --container-bg
  • Sidebar: --sidebar-bg, --sidebar-width
  • Content: --content-bg, --content-text
  • Search: --search-border, --search-bg
  • File items: --file-item-bg, --file-item-hover

Updating Theme via API

curl -X PUT http://localhost:8080/api/profile/theme \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "headerBg": "#1a1a1a",
    "headerText": "#ffffff",
    ...
  }'

Features

Current Implementation

Echo web server with routing
RESTful API for markdown files
PostgreSQL database integration
Database schema with users, themes, and markdown_files tables
Markdown parsing (title, date, tags)
Responsive frontend interface
Collapsible sidebar (1/4 width)
Tag-based search with GIN index
Theme system with CSS variables
CORS middleware
Logging middleware
Environment-based configuration

Planned Features

🔲 JWT authentication
🔲 User registration and login
🔲 User profile management
🔲 Theme persistence per user
🔲 Subscription functionality
🔲 API rate limiting
🔲 File versioning
🔲 Full-text search
🔲 File update/delete endpoints

Development

Adding New Endpoints

  1. Define the handler in handlers/handlers.go
  2. Add the route in main.go
  3. Update the model if needed in models/models.go
  4. Implement business logic in services/

Adding Authentication

The middleware/auth.go file contains a placeholder for JWT authentication. To implement:

  1. Install JWT library (already in go.mod)
  2. Create user authentication service
  3. Generate JWT tokens on login
  4. Validate tokens in middleware
  5. Extract user from token and set in context

Testing

# Run tests
go test ./...

# Run with coverage
go test -cover ./...

Building for Production

# Build binary
go build -o innovative-axis

# Run binary
./innovative-axis

Dependencies

  • github.com/labstack/echo/v4 - Web framework
  • github.com/golang-jwt/jwt/v5 - JWT authentication (for future use)
  • github.com/lib/pq - PostgreSQL driver

License

[Your License Here]

Contributing

Contributions are welcome! Please open an issue or submit a pull request.