A comprehensive full-stack application for tracking and managing your OneDrive-hosted video courses, built with Go and Next.js.
CourseTracker seamlessly integrates with Microsoft OneDrive to automatically fetch and organize your video courses, allowing you to track your learning progress with precision. The application provides a robust REST API backend written in Go and a modern Next.js frontend interface.
-
π Secure Authentication System
- User registration and login with bcrypt password hashing
- Session-based authentication with PostgreSQL session store
- Secure cookie management with HTTP-only and SameSite policies
- Protected routes with middleware authentication
-
π OneDrive Integration
- Automatic course fetching from OneDrive shared links
- Hierarchical course structure parsing (parts, sub-parts, files)
- Video duration extraction and aggregation
- Support for multiple file formats
-
π Progress Tracking
- Track watched time for each video resource
- Mark videos as completed
- View overall course progress with aggregated statistics
- Per-resource and per-course progress views
-
π Course Management
- Create courses from OneDrive URLs
- View all courses with metadata (name, duration, timestamps)
- Update course information and sync with OneDrive
- Delete courses with cascade deletion of progress data
- JSONB storage for flexible course structure
-
π€ User Management
- User profile retrieval
- Profile modification (username, email)
- User existence checks for validation
- Modern, responsive UI with Next.js 14+
- User authentication pages (login/signup)
- Dashboard for course overview
- Individual course detail pages
- Beautiful UI components with animations
- Database: PostgreSQL with pgx driver
- Session Management: Server-side sessions with 12-hour lifetime
- CORS: Configured for cross-origin requests
- Middleware: Request logging, security headers, authentication
- Migrations: SQL migrations with Goose
The following features are planned for future releases:
- Dedicated user profile dashboard
- Display user statistics and achievements
- Customizable profile settings
- Share your courses with other users
- Grant access to specific courses
- View courses shared by others
- Collaborative learning features
- Visual calendar showing daily login streaks
- Track learning consistency over time
- Gamification elements to encourage daily engagement
- Activity heatmap visualization
- Revoke shared course access
- Manage permissions for shared courses
- View list of users with access to your courses
- Notification system for sharing events
- Language: Go 1.25.4
- Web Framework: Standard library
net/httpwithalicemiddleware chaining - Database: PostgreSQL with
pgx/v5driver and connection pooling - Session Management:
scs/v2with PostgreSQL store - Authentication:
bcryptfor password hashing - OneDrive Integration: Microsoft Graph SDK for Go
- Azure Authentication:
azidentitywith device code flow - CORS:
rs/corsmiddleware - Environment:
godotenvfor configuration
- Framework: Next.js (TypeScript)
- Styling: Tailwind CSS
- UI Components: Custom components with animations
- Primary Database: PostgreSQL
- Migration Tool: Goose
- Schema: Users, Courses (JSONB), Progress tracking, Sessions
Before running the application, ensure you have:
- Go 1.25.4 or higher
- PostgreSQL 14 or higher
- Node.js 18+ and npm (for frontend)
- Microsoft Azure account with OneDrive API access
- Azure App Registration with appropriate permissions
git clone https://github.com/Piccio-Code/Course_Tracker.git
cd Course_Trackergo mod downloadCreate app/.env file with the following variables:
# Database
DATABASE_URL=postgres://username:password@localhost:5432/coursetracker?sslmode=disable
# Azure/OneDrive API
TENANT_ID=your-azure-tenant-id
CLIENT_ID=your-azure-app-client-id
# Server Configuration (optional)
PORT=8080# Install Goose (if not already installed)
go install github.com/pressly/goose/v3/cmd/goose@latest
# Run migrations
cd app/migrations
goose postgres "your-database-url" up# From the project root
cd app/backend
# Development mode (allows HTTP cookies)
go run . -dev
# With OneDrive integration
go run . -onedrive -dev
# Production mode (requires HTTPS)
go run . -onedriveCommand Line Flags:
-dev: Disables secure cookie requirement (use only for development)-onedrive: Enables OneDrive API connection with device code authentication
cd frontend
# Install dependencies
npm install
# Run development server
npm run dev
# Build for production
npm run build
npm startThe frontend will be available at http://localhost:3000
POST /auth/signup
Content-Type: application/json
{
"username": "string",
"email": "string",
"password": "string"
}POST /auth/login
Content-Type: application/json
{
"username": "string",
"email": "string",
"password": "string"
}POST /auth/logoutGET /userPUT /user
Content-Type: application/json
{
"username": "string",
"email": "string"
}POST /courses
Content-Type: application/json
{
"url": "onedrive-share-url",
"name": "Course Name (optional)"
}GET /coursesResponse:
[
{
"id": 1,
"name": "Course Name",
"duration": 3600000,
"created": "2024-01-01T00:00:00Z",
"lastUpdated": "2024-01-01T00:00:00Z"
}
]GET /courses/{id}Response:
{
"id": 1,
"courseResources": {
"name": "Course Name",
"duration": 3600000,
"url": "onedrive-url",
"parts": [...],
"files": [...]
},
"created": "2024-01-01T00:00:00Z",
"lastUpdated": "2024-01-01T00:00:00Z"
}PUT /courses/{id}
Content-Type: application/json
{
"url": "new-onedrive-url",
"name": "Updated Name"
}DELETE /courses/{id}GET /progressResponse:
[
{
"course_name": "Course Name",
"course_id": 1,
"course_total_time": 3600000,
"time_watched": 1800000
}
]GET /progress/{courseId}Response:
[
{
"id": 1,
"time_watched": 120000,
"completed": false,
"url": "video-url"
}
]POST /progress/{courseId}
Content-Type: application/json
{
"watchedTimeMills": 120000,
"completed": false,
"url": "video-resource-url"
}PUT /progress/{courseId}
Content-Type: application/json
{
"watchedTimeMills": 240000,
"completed": true,
"url": "video-resource-url"
}DELETE /progress/{courseId}
Content-Type: application/json
{
"url": "video-resource-url"
}CREATE TABLE users (
id SERIAL PRIMARY KEY,
username VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
password BYTEA NOT NULL,
UNIQUE(username),
UNIQUE(email)
);
CREATE INDEX idx_users_username ON users(username);
CREATE INDEX idx_users_email ON users(email);CREATE TABLE courses (
id SERIAL PRIMARY KEY,
course_resources JSONB NOT NULL,
user_id INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id)
);CREATE TABLE users_progress (
id SERIAL PRIMARY KEY,
time_watched INT NOT NULL DEFAULT 0,
completed BOOLEAN DEFAULT FALSE,
course_id INT NOT NULL,
user_id INT NOT NULL,
resource_url VARCHAR(255) NOT NULL,
FOREIGN KEY (course_id) REFERENCES courses(id),
FOREIGN KEY (user_id) REFERENCES users(id)
);Managed automatically by scs/pgxstore
CourseTracker/
βββ app/
β βββ backend/
β β βββ main.go # Application entry point
β β βββ routes.go # Route definitions
β β βββ handles.go # HTTP handlers
β β βββ middlewares.go # Middleware functions
β β βββ helpers.go # Helper functions
β βββ models/
β β βββ courseModels.go # Course data access
β β βββ userModels.go # User data access
β β βββ userProgressModel.go
β βββ customErrors/
β β βββ authErrors.go # Custom error types
β βββ migrations/ # Database migrations
βββ Wrapper/
β βββ onedrive.go # OneDrive API wrapper
βββ frontend/
β βββ src/
β βββ app/ # Next.js pages
β βββ components/ # React components
β βββ lib/ # Utilities and API client
βββ go.mod
βββ go.sum
βββ README.md
- Password Security: Bcrypt hashing with cost factor 12
- Session Security: HTTP-only cookies, SameSite protection
- HTTPS Enforcement: Secure cookies in production mode
- SQL Injection Prevention: Parameterized queries with pgx
- CORS Protection: Whitelist-based origin control
- Authentication Middleware: Protected routes require valid session
- Token Renewal: Session token renewal on authentication events
go test ./...- Models: Handle all database operations with transaction support
- Handlers: Process HTTP requests and delegate to models
- Middleware: Chain using alice for clean composition
- Context: Use context for passing user ID through request pipeline
| Variable | Description | Required |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes |
TENANT_ID |
Azure tenant ID | Yes (if using OneDrive) |
CLIENT_ID |
Azure app client ID | Yes (if using OneDrive) |
OneDrive Authentication Fails
- Ensure your Azure app has the required Graph API permissions
- Verify TENANT_ID and CLIENT_ID are correct
- Check that you're using device code flow authentication
Database Connection Errors
- Verify PostgreSQL is running
- Check DATABASE_URL format and credentials
- Ensure migrations have been run
CORS Errors
- Add your frontend URL to the
AllowedOriginsinmain.go - Check that credentials are being sent with requests
This project is licensed under a Proprietary License with free usage rights. You may use this software for free, but you cannot copy, modify, or distribute the source code. See the LICENSE file for full details.
All Rights Reserved - Copyright Β© 2024-2025 Piccio-Code
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This is a personal project created for learning and portfolio purposes. Use at your own risk.
Piccio-Code
This code is the intellectual property of the author. All rights reserved.
This is a closed-source personal project. While you cannot contribute code directly, suggestions and feedback are welcome! Feel free to open an issue if you find bugs or have feature requests.
For questions or inquiries, please open an issue on GitHub.
β If you find this project useful, consider giving it a star!