This project began as a GitHub Markdown content fetcher and HTML converter but has evolved into a comprehensive dashboard application built with Go and HTMX. The application is compiled into a single binary and provides four main functionalities:
- Markdown Content fetcher and Parser
- Data Management for Blogs/Projects List
- Newsletter Email Management
- Website Analytics
flowchart TD
subgraph Client
A[Web Browser]
end
subgraph Application
B[Router Layer]
C[Handler Layer]
D[Repository Layer]
E[Database Layer]
F[Markdown Parser]
G[GitHub Fetcher]
end
subgraph External
H[GitHub API]
I[SMTP Server]
end
%% Main Flow
A -->|HTTP Request| B
B -->|Route Match| C
C -->|Data Operations| D
D -->|SQL Queries| E
%% Markdown Flow
C -->|MD Request| G
G -->|Fetch Content| H
G -->|Raw MD| F
F -->|HTML| C
%% Email Flow
C -->|Feedback| I
%% Response Flow
C -->|Response| B
B -->|HTTP Response| A
%% Style
classDef external fill:#f96,stroke:#333
class H,I external
sequenceDiagram
participant C as Client
participant R as Router
participant H as Handler
participant Repo as Repository
participant DB as Database
participant GH as GitHub
%% Blogs/Projects List Flow
C->>+R: GET /blogs or /projects
R->>+H: HandleBlogsList/HandleProjectsList
H->>+Repo: GetBlogs/GetProjects
Repo->>+DB: Query
DB-->>-Repo: Data
Repo-->>-H: Results
H-->>-R: JSON Response
R-->>-C: Data
%% Markdown Flow
C->>+R: GET /md?url=github.com/...
R->>+H: MarkdownHandler
H->>+GH: Fetch Content
GH-->>-H: Raw MD
H->>H: Convert to HTML
H-->>R: HTML Response
R-->>-C: Rendered Content
%% Analytics Flow
C->>+R: POST /analytics
R->>+H: HandleAnalytics
H->>+Repo: SaveAnalytics
Repo->>+DB: Insert
DB-->>-Repo: Success
Repo-->>-H: Result
H-->>-R: Response
R-->>-C: Confirmation
-
Router Layer (
/internal/router/
)- Handles all incoming HTTP requests
- Manages route definitions and middleware
- Separates admin and public API routes
-
Handler Layer (
/internal/handler/
)- Processes incoming requests
- Coordinates between different services
- Manages business logic
-
Repository Layer (
/internal/repository/
)- Handles database operations
- Provides data access abstraction
- Manages CRUD operations
-
Database Layer (
/internal/database/
)- PostgreSQL database integration
- Manages migrations
- Handles connection pooling
-
Authentication (
/internal/auth/
)- JWT-based authentication
- GitHub authentication integration
-
Middleware (
/internal/middleware/
)- Authentication middleware
- Rate limiting
- Request logging
The application exposes several public API endpoints that don't require authentication:
-
GET /blogs
- Returns list of blog entries
- Direct database query through repository
- No pagination implemented yet
-
GET /projects
- Returns list of project entries
- Similar structure to blogs endpoint
- Direct database query through repository
-
GET /md
- Accepts URL parameter:
/md?url=https://github.com/username/repo
- Fetches markdown content from GitHub
- Convert Markdown content to HTML content
- Returns converted HTML
- Accepts URL parameter:
-
POST /analytics
- Accepts page name in request body
- Records analytics data
- Only POST method allowed
-
POST /feedback
- Accepts name, email and feedback message
- Send it to the developer
- Using SMTP server
- Only POST method allowed and Rate limited
-
POST /newsletter
- Accepts email address
- Save it to the database
- Only POST method allowed and Rate limited
The dashboard (accessible after authentication) provides:
-
Blog Management
- Add/Edit/Delete blog entries
- Manage GitHub repository URLs
- Additional metadata management
-
Project Management
- Similar to blog management
- Project-specific metadata
-
Newsletter Management
- Subscriber management
-
Analytics Dashboard
- View page visit statistics
- Data visualization
The application follows a clean architectural pattern where:
- Router receives the request
- Routes to the appropriate handler
- Handler processes request and calls repository
- Repository communicates with the database
- Response flows back through the same layers
The database structure is managed through migrations:
- Newsletter Subscriptions (001)
- Blogs (002)
- Projects (003)
- Analytics (004)
- Backend: Go 1.22.0
- Frontend: HTMX
- Database: PostgreSQL
- Authentication: JWT
- Container: Docker
- External APIs: GitHub API
- Email: SMTP Integration
The project follows a clean, modular structure with clear separation of concerns:
.
├── cmd/ # Application entry points
├── internal/ # Private application code
│ ├── auth/ # Authentication logic
│ ├── database/ # Database and migrations
│ ├── fetcher/ # External content fetching
│ ├── handler/ # Request handlers
│ ├── middleware/ # HTTP middleware
│ ├── parser/ # Markdown parsing
│ ├── repository/ # Data access layer
│ ├── router/ # HTTP routing
│ └── templates/ # HTML templates
├── pkg/ # Public library code
│ └── models/ # Data models
└── static/ # Static assets
- Implement pagination for blogs and projects endpoints
- Add rate limiting for GitHub requests
- Enhance analytics visualization
- Add verification of the email for newsletter
- Add HTML template and campaign management