- Go 38%
- HTML 27.5%
- JavaScript 18.9%
- CSS 15.6%
| database | ||
| handlers | ||
| middleware | ||
| models | ||
| services | ||
| static | ||
| .env.bak | ||
| .gitignore | ||
| go.mod | ||
| go.sum | ||
| main.go | ||
| README.md | ||
| schema.sql | ||
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
-
Install Go (version 1.21 or higher)
# Download from https://golang.org/dl/ -
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/ -
Clone or download this project
-
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 -
Configure environment variables
cp .env.example .env # Edit .env with your database credentials -
Install dependencies
cd innovative-axis go mod download
Running the Application
-
Ensure PostgreSQL is running
# Check if PostgreSQL is running psql -U postgres -c "SELECT version();" -
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 -
Start the server
go run main.go -
Access the application Open your browser and navigate to:
http://localhost:8080
API Endpoints
Public Endpoints
GET /- Serves the main pageGET /api/files- Get all markdown filesGET /api/files/:id- Get a specific file by IDPOST /api/subscribe- Subscribe (placeholder)POST /api/login- User login (placeholder)
Protected Endpoints (require authentication)
POST /api/upload- Upload a new markdown fileGET /api/profile- Get user profilePUT /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
- Define the handler in
handlers/handlers.go - Add the route in
main.go - Update the model if needed in
models/models.go - Implement business logic in
services/
Adding Authentication
The middleware/auth.go file contains a placeholder for JWT authentication. To implement:
- Install JWT library (already in go.mod)
- Create user authentication service
- Generate JWT tokens on login
- Validate tokens in middleware
- 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 frameworkgithub.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.