This project consists of two main components:
- Backend: A Go-based server that provides API endpoints for accessing program files, metadata, and cache management. 🏗️
- Frontend: A React and TypeScript application that displays a hierarchical sidebar for navigating classes, semesters, years, courses, and program files. The frontend also features a code editor for viewing and editing file contents with syntax highlighting. 🖥️✍️
The backend is implemented using Go with the Gin web framework and Redis for caching. It provides various API endpoints for retrieving and managing code files, metadata, and cache status.
GET /program/:year/:semester/:class/:course/:filename
: Retrieve a code file.GET /download/:year/:semester/:class/:course/:filename
: Download a code file.GET /structure
: Retrieve directory structure.GET /years
: Retrieve list of years.GET /years/semesters
: Retrieve list of semesters.GET /:year/:semester/:class/:course/:filename
: Handle metadata.GET /course/:year/:semester/:class
: Retrieve courses.GET /programs/:year/:semester/:class/:course
: Retrieve programs.GET /metadata/:year/:semester/:class/:course/:filename
: Retrieve metadata.GET /cache-status
: Retrieve cache status.POST /clear-cache
: Clear the cache.GET /health
: Health check.GET /metrics
: Retrieve metrics.GET /version
: Retrieve version information.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install Go and Redis:
-
Install Go dependencies:
cd backend go mod tidy
-
Run the server:
go run .
-
Ensure Redis is running:
redis-server
To build the backend for different operating systems:
-
Windows:
GOOS=windows GOARCH=amd64 go build -o backend.exe
-
Linux:
GOOS=linux GOARCH=amd64 go build -o backend
-
MacOS:
GOOS=darwin GOARCH=amd64 go build -o backend
The frontend is implemented using React with TypeScript, Vite, and Tailwind CSS. It includes a sidebar for navigating the hierarchical structure and a code editor for viewing and editing code files.
-
Navigate to the frontend directory:
cd frontend
-
Install Node.js dependencies:
npm install
-
Start the development server:
npm run dev
src/components/Sidebar.tsx
: Contains the sidebar component for displaying the hierarchy.src/components/CodeEditor.tsx
: Contains the code editor component with syntax highlighting.src/api/requests.ts
: Contains functions for making API requests to the backend.
- Use Vite for development and build tasks.
- Tailwind CSS is used for styling.
- React Router is used for routing.
- Axios is used for making HTTP requests.