How connortran216/horizon-blog works
Project type and purpose
• This is a single-page, full-stack-ready frontend application (Personal Blog) built with React, TypeScript, Vite, and Chakra UI.
• It provides a responsive blog with authentication, rich-text editing (using Lexical), search/filter, and contact features.
• Although it’s currently using localStorage via a blogStorage service, it is designed to integrate with a backend (e.g., Django REST API).
File structure
• Top level:
• Dockerfile, docker-compose.yml — containerization
• index.html, public/ — static assets
• src/ — all application code
• src/ folders:
• core/ — shared business logic (services, types, utils, ErrorBoundary)
• components/ — feature-specific UI (layout, editor, reader)
• pages/ — route-level React views
• context/ — global state (AuthContext)
• config/ — editor and runtime config
• theme/ — Chakra UI theme
• Routes.tsx & App.tsx — React Router setup and root component
• main.tsx — entry point (renders App with providers)
• Config files: tsconfig.json, vite.config.ts, .env variants, package.json.
README for additional insights
• Mentions planned REST endpoints (/api/auth/login, /api/posts, etc.).
• Describes directory intentions under “Project Architecture.”
a. Main components:
1. Client (Browser)
2. Static server / CDN (serves index.html & JS bundle)
3. React SPA
• App shell + Router
• AuthContext provider
• Page components (Home, Blog, BlogDetail, BlogEditor, etc.)
• UI components (Navbar, Footer, Editor, Reader)
4. Core services
• AuthService → /api/auth
• ApiService → /api/posts, /api/contact
• StorageService → localStorage (fallback)
5. Lexical Editor subsystem
• MilkdownEditor, plugins, Markdown support
6. External services (future)
• REST API (Django backend)
• Auth (JWT)
b. Relationships & interactions:
• Browser requests index.html → Static server (Docker/Nginx).
• React SPA initializes in Browser, sets up AuthContext.
• User navigates via React Router to pages.
• Page components call core services:
• AuthService.login() → HTTP POST to /api/auth/login
• ApiService.getPosts() → HTTP GET /api/posts
• StorageService.read()/write() → localStorage fallback.
• BlogEditor uses Lexical editor components and plugins.
• Contact page posts to /api/contact.
c. Architectural patterns & principles:
• Component hierarchy: Pages → Feature components → Core UI components.
• Separation of concerns:
• UI layer (components/layout, pages)
• Business logic layer (core/services, core/utils)
• State management (context)
• Single source of truth for config (.env, vite.config, src/config).
• Fallback pattern: localStorage service until API is available.
d. Key technologies:
• React 18 + TS + Vite
• Chakra UI for styling
• React Router DOM for client-side routing
• Lexical editor with Markdown plugin
• Axios or fetch within ApiService (not shown but implied)
• Docker + docker-compose for containerization
Detailed capturing of essential elements
• Data flow on login, fetch posts, save post.
• Context provider and theme/provider wrappers.
• Environment configs (.env.development vs production).