# Project Context ## Project Structure - **Root:** - `backend/`: Go backend service. - `frontend/`: Astro + React frontend. - `Makefile`: Build commands. - `docker-compose.yml`: Container orchestration. ## Backend (`/backend`) - **Language:** Go - **Framework:** Chi (Router) - **Database:** SQLite (with `modernc.org/sqlite` driver) - **Authentication:** Goth (GitHub OAuth) - **Key Directories:** - `internal/api/`: Handlers and routing. - `router.go`: Defines API routes. - `handlers/`: Contains logic for Auth, Repos, etc. - `internal/database/`: Database connection, models, and queries. - `models.go`: Struct definitions (`User`, `AuthToken`, `BranchState`, `DraftContent`). - `queries.go`: SQL queries. - `migrations/`: SQL migration files. - `internal/connectors/`: External API integrations (GitHub). - `github.go`: Handles GitHub API calls (listing repos, files). ## Frontend (`/frontend`) - **Framework:** Astro (Static Site Generation / Server Side Rendering) with React islands. - **Styling:** Tailwind CSS. - **State Management:** React Query (TanStack Query). - **Key Directories:** - `src/pages/`: - `index.astro`: Landing page. - `dashboard.astro`: Main application entry point. - `src/components/dashboard/`: - `DashboardApp.tsx`: Main React component for the dashboard. - `SetupWizard.tsx`: Component for selecting repository and folder (To be refactored). - `FileTree.tsx`: Displays repository file structure. - `src/lib/api/`: API client and endpoints. - `repos.ts`: Calls to backend repo endpoints. ## Current Functionality 1. **Auth:** GitHub OAuth flow via `/api/auth/github/login`. 2. **Repo Selection:** Users select a repo and optional folder path via `SetupWizard`. 3. **File Listing:** Fetches file tree from GitHub via Backend. Currently shows all folders, even empty ones. 4. **Editing:** Markdown editing (implied, likely using TipTap or similar based on `node_modules`). ## Proposed Changes Context - **Last Repo Persistence:** Currently, the app doesn't remember the selected repo across sessions. We need to add `last_repo` to the `User` model. - **Folder Selection:** The user finds the folder selection step unnecessary. We will enforce root (`""`) as the default. - **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. - **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.