A deployable markdown editor that connects with your self hosted files and lets you edit in a beautiful interface
1# Project Context
2
3## Project Structure
4- **Root:**
5 - `backend/`: Go backend service.
6 - `frontend/`: Astro + React frontend.
7 - `Makefile`: Build commands.
8 - `docker-compose.yml`: Container orchestration.
9
10## Backend (`/backend`)
11- **Language:** Go
12- **Framework:** Chi (Router)
13- **Database:** SQLite (with `modernc.org/sqlite` driver)
14- **Authentication:** Goth (GitHub OAuth)
15- **Key Directories:**
16 - `internal/api/`: Handlers and routing.
17 - `router.go`: Defines API routes.
18 - `handlers/`: Contains logic for Auth, Repos, etc.
19 - `internal/database/`: Database connection, models, and queries.
20 - `models.go`: Struct definitions (`User`, `AuthToken`, `BranchState`, `DraftContent`).
21 - `queries.go`: SQL queries.
22 - `migrations/`: SQL migration files.
23 - `internal/connectors/`: External API integrations (GitHub).
24 - `github.go`: Handles GitHub API calls (listing repos, files).
25
26## Frontend (`/frontend`)
27- **Framework:** Astro (Static Site Generation / Server Side Rendering) with React islands.
28- **Styling:** Tailwind CSS.
29- **State Management:** React Query (TanStack Query).
30- **Key Directories:**
31 - `src/pages/`:
32 - `index.astro`: Landing page.
33 - `dashboard.astro`: Main application entry point.
34 - `src/components/dashboard/`:
35 - `DashboardApp.tsx`: Main React component for the dashboard.
36 - `SetupWizard.tsx`: Component for selecting repository and folder (To be refactored).
37 - `FileTree.tsx`: Displays repository file structure.
38 - `src/lib/api/`: API client and endpoints.
39 - `repos.ts`: Calls to backend repo endpoints.
40
41## Current Functionality
421. **Auth:** GitHub OAuth flow via `/api/auth/github/login`.
432. **Repo Selection:** Users select a repo and optional folder path via `SetupWizard`.
443. **File Listing:** Fetches file tree from GitHub via Backend. Currently shows all folders, even empty ones.
454. **Editing:** Markdown editing (implied, likely using TipTap or similar based on `node_modules`).
46
47## Proposed Changes Context
48- **Last Repo Persistence:** Currently, the app doesn't remember the selected repo across sessions. We need to add `last_repo` to the `User` model.
49- **Folder Selection:** The user finds the folder selection step unnecessary. We will enforce root (`""`) as the default.
50- **Empty Folders:** The file tree currently is "dumb" and shows the full structure. We need to make the backend filtering "smart" to only return relevant paths.
51- **Navigation:** The dashboard currently handles both setup and editing in one view. Splitting this into `/select-repo` and `/dashboard` will improve UX and browser history management.