Skip to content

heyitsgautham/AcademiaSync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

24 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ“ AcademiaSync

Smart Learning Management System with OAuth & Role-Based Access Control

CI Status Docker Build Terraform Docker Next.js TypeScript Node.js PostgreSQL AWS License

A modern, scalable learning platform built with microservices architecture, featuring Google OAuth authentication, real-time analytics, and comprehensive course management.

πŸš€ Quick Start β€’ ✨ Features β€’ πŸ—οΈ Architecture β€’ πŸ“– Documentation


πŸ“‹ Table of Contents


πŸš€ Quick Start

Prerequisites

Installation

Step 1: Google OAuth Setup

  1. Go to Google Cloud Console
  2. Create a new project or select an existing one
  3. Navigate to APIs & Services β†’ Credentials
  4. Click Create Credentials β†’ OAuth 2.0 Client ID
  5. Configure OAuth consent screen
  6. Set application type to Web application
  7. Add authorized redirect URI:
    http://localhost:3000/api/auth/callback/google
    
  8. Copy your Client ID and Client Secret

Step 2: Clone & Configure

# Clone the repository
git clone https://github.com/heyitsgautham/AcademiaSync.git
cd AcademiaSync

# Copy environment files
cp .env.example .env
cp frontend/.env.example frontend/.env.local

# Edit .env and frontend/.env.local with your Google OAuth credentials

Required Environment Variables:

# .env (root)
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=academiasync
DB_PORT=5432
USER_SERVICE_PORT=5000
COURSE_SERVICE_PORT=5001
JWT_SECRET=<your-jwt-secret>
JWT_REFRESH_SECRET=<your-jwt-refresh-secret>
GOOGLE_CLIENT_ID=<your-google-client-id>
GOOGLE_CLIENT_SECRET=<your-google-client-secret>
NEXTAUTH_SECRET=<generate-with-openssl-rand-base64-32>
NEXTAUTH_URL=http://localhost:3000
NEXT_PUBLIC_BACKEND_URL=http://localhost:5000
NEXT_PUBLIC_COURSE_SERVICE_URL=http://localhost:5001
INTERNAL_BACKEND_URL=http://user-service:5000
INTERNAL_COURSE_SERVICE_URL=http://course-service:5001

πŸ’‘ Generate NEXTAUTH_SECRET: Run openssl rand -base64 32 in terminal

Step 3: Launch with Docker

# Start all services
docker-compose up -d

# Check service health
docker-compose ps

# View logs
docker-compose logs -f

Step 4: Access the Application

Service URL Description
🌐 Frontend http://localhost:3000 Main application
πŸ”§ User Service http://localhost:5000/health Auth & user management
πŸ”§ Course Service http://localhost:5001/health Courses & assignments
πŸ“Š API Docs http://localhost:5000/api-docs Swagger documentation

Step 5: Create Admin Account

After first login with Google:

# Access the database
docker exec -it academiasync-db psql -U postgres -d academiasync

# Promote your user to admin (replace with your email)
UPDATE users SET role = 'Admin' WHERE email = 'your-email@gmail.com';
\q

Stopping the Application

# Stop all services
docker-compose down

# Stop and remove volumes (reset database)
docker-compose down -v

✨ Features

πŸ” Authentication & Authorization

  • Google OAuth 2.0 integration via NextAuth.js
  • JWT-based authentication with access & refresh tokens
  • Role-based access control (Student, Teacher, Admin)
  • Secure httpOnly cookies for token storage
  • Automatic session management and token refresh

πŸ‘¨β€πŸŽ“ Student Portal

  • Dashboard with personalized stats and progress tracking
  • Course enrollment and management
  • Assignment submissions with deadline tracking
  • Analytics dashboard with performance charts
  • Grade tracking across all courses

πŸ‘¨β€πŸ« Teacher Portal

  • Course creation and management
  • Assignment creation with due dates
  • Student management by course
  • Submission grading with feedback
  • Analytics for student performance tracking
  • Recent activity monitoring

πŸ‘¨β€πŸ’Ό Admin Portal

  • User management (Students & Teachers)
  • Role promotion/demotion
  • Platform-wide analytics
  • Course oversight
  • System health monitoring

πŸ“Š Analytics & Reporting

  • Interactive charts using Recharts
  • Student performance metrics
  • Course completion rates
  • Enrollment statistics
  • Age demographics visualization

🎨 User Experience

  • Dark/Light theme toggle with persistence
  • Responsive design for all devices
  • Toast notifications for user feedback
  • Confirmation modals for critical actions
  • Loading states and skeleton screens

πŸ—οΈ Architecture

System Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           FRONTEND                                   β”‚
β”‚                    Next.js 14 (App Router)                          β”‚
β”‚            React + TypeScript + TailwindCSS + shadcn/ui             β”‚
β”‚                        Port: 3000                                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚                       β”‚
                    β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       USER SERVICE          β”‚   β”‚      COURSE SERVICE         β”‚
β”‚   Express.js + Node.js      β”‚   β”‚   Express.js + Node.js      β”‚
β”‚        Port: 5000           β”‚   β”‚        Port: 5001           β”‚
β”‚                             β”‚   β”‚                             β”‚
β”‚  β€’ Authentication (OAuth)   β”‚   β”‚  β€’ Course Management        β”‚
β”‚  β€’ User Management          β”‚   β”‚  β€’ Assignment Management    β”‚
β”‚  β€’ Admin Operations         β”‚   β”‚  β€’ Enrollment Management    β”‚
β”‚  β€’ JWT Token Management     β”‚   β”‚  β€’ Submission Management    β”‚
β”‚  β€’ Profile Management       β”‚   β”‚  β€’ Student/Teacher Routes   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚                                  β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
               β”‚        PostgreSQL 16        β”‚
               β”‚         Port: 5432          β”‚
               β”‚                             β”‚
               β”‚  β€’ Users & Roles            β”‚
               β”‚  β€’ Courses & Enrollments    β”‚
               β”‚  β€’ Assignments              β”‚
               β”‚  β€’ Submissions              β”‚
               β”‚  β€’ Refresh Tokens           β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Authentication Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  User    │────▢│ Frontend │────▢│  NextAuth   │────▢│    Google    β”‚
β”‚          β”‚     β”‚  :3000   β”‚     β”‚  OAuth      β”‚     β”‚   OAuth 2.0  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                         β”‚
                                         β–Ό
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚  User Service   β”‚
                              β”‚   POST /auth/   β”‚
                              β”‚  google-signin  β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                       β”‚
                                       β–Ό
                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚   JWT Tokens    β”‚
                              β”‚  (Access +      β”‚
                              β”‚   Refresh)      β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Docker Network

All services communicate via the academiasync-network bridge network:

Container Internal Hostname External Port
Frontend frontend 3000
User Service user-service 5000
Course Service course-service 5001
PostgreSQL db 5432

πŸ› οΈ Tech Stack

Frontend

Technology Purpose Version
Next.js React Framework (App Router) 14.x
TypeScript Type Safety 5.0.x
React UI Library 18.x
TailwindCSS Styling 3.4.x
shadcn/ui UI Components Latest
React Query Server State Management 5.64.x
NextAuth.js Authentication 4.x
Recharts Data Visualization 2.x
React Hook Form Form Management 7.x
Yup Schema Validation 1.x
next-themes Theme Management 0.3.x

Backend

Technology Purpose Version
Node.js Runtime Environment 20.x
Express.js Web Framework 4.x
PostgreSQL Database 16.x
JWT Token Authentication 9.x
Google Auth OAuth 2.0 9.x
Morgan HTTP Logging 1.10.x
Swagger API Documentation 5.x

DevOps & Infrastructure

Technology Purpose Version
Docker Containerization 24.x
Docker Compose Orchestration 2.x
Terraform Infrastructure as Code 1.5.x
AWS ECS Container Orchestration Latest
AWS ECR Container Registry Latest
GitHub Actions CI/CD Pipeline Latest
Jest Testing Framework 29.x

πŸ“ Project Structure

AcademiaSync/
β”œβ”€β”€ πŸ“ frontend/                      # Next.js Application
β”‚   β”œβ”€β”€ πŸ“ app/                       # App Router pages
β”‚   β”‚   β”œβ”€β”€ layout.tsx                # Root layout with providers
β”‚   β”‚   β”œβ”€β”€ page.tsx                  # Landing page
β”‚   β”‚   β”œβ”€β”€ πŸ“ api/                   # API route handlers
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“ auth/[...nextauth] # OAuth configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“ student/           # Student API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“ teacher/           # Teacher API routes
β”‚   β”‚   β”‚   └── πŸ“ admin/             # Admin API routes
β”‚   β”‚   β”œβ”€β”€ πŸ“ student/               # Student dashboard pages
β”‚   β”‚   β”œβ”€β”€ πŸ“ teacher/               # Teacher dashboard pages
β”‚   β”‚   └── πŸ“ admin/                 # Admin dashboard pages
β”‚   β”œβ”€β”€ πŸ“ components/                # React components (60+)
β”‚   β”‚   β”œβ”€β”€ πŸ“ ui/                    # shadcn/ui base components
β”‚   β”‚   β”œβ”€β”€ student-*.tsx             # Student-specific components
β”‚   β”‚   β”œβ”€β”€ teacher-*.tsx             # Teacher-specific components
β”‚   β”‚   └── admin-*.tsx               # Admin-specific components
β”‚   β”œβ”€β”€ πŸ“ lib/                       # Utilities & API client
β”‚   β”œβ”€β”€ πŸ“ types/                     # TypeScript definitions
β”‚   β”œβ”€β”€ middleware.ts                 # Route protection
β”‚   └── Dockerfile                    # Multi-stage build
β”‚
β”œβ”€β”€ πŸ“ backend/
β”‚   β”œβ”€β”€ πŸ“ user-service/              # Auth & User Management
β”‚   β”‚   β”œβ”€β”€ πŸ“ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“ routes/            # API endpoints
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ auth.js           # OAuth & JWT
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ admin.js          # Admin operations
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard.js      # Dashboard data
β”‚   β”‚   β”‚   β”‚   └── users.js          # User CRUD
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“ middleware/        # Auth & authorization
β”‚   β”‚   β”‚   └── πŸ“ utils/             # HATEOAS, logging
β”‚   β”‚   β”œβ”€β”€ πŸ“ tests/                 # Jest test suites
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“ course-service/            # Courses & Assignments
β”‚   β”‚   β”œβ”€β”€ πŸ“ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ πŸ“ routes/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ courses.js        # Course CRUD
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ assignments.js    # Assignment CRUD
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ student.js        # Student operations
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ teacher.js        # Teacher operations
β”‚   β”‚   β”‚   β”‚   └── analytics.js      # Analytics data
β”‚   β”‚   β”‚   └── πŸ“ middleware/
β”‚   β”‚   β”œβ”€β”€ πŸ“ tests/
β”‚   β”‚   └── Dockerfile
β”‚   β”‚
β”‚   └── πŸ“ database/
β”‚       β”œβ”€β”€ init.sql                  # Schema initialization
β”‚       └── seed-demo-data.sql        # Demo data
β”‚
β”œβ”€β”€ πŸ“ terraform/                     # AWS Infrastructure
β”‚   β”œβ”€β”€ main.tf                       # Root module
β”‚   β”œβ”€β”€ variables.tf                  # Variable definitions
β”‚   β”œβ”€β”€ outputs.tf                    # Output values
β”‚   β”œβ”€β”€ πŸ“ modules/
β”‚   β”‚   β”œβ”€β”€ vpc/                      # VPC & networking
β”‚   β”‚   β”œβ”€β”€ ecr/                      # Container registry
β”‚   β”‚   β”œβ”€β”€ ecs/                      # ECS cluster & services
β”‚   β”‚   β”œβ”€β”€ cloudwatch/               # Monitoring
β”‚   β”‚   └── sns/                      # Notifications
β”‚   └── deploy.sh                     # Deployment script
β”‚
β”œβ”€β”€ πŸ“ .github/workflows/             # CI/CD Pipelines
β”‚   β”œβ”€β”€ ci.yml                        # Test suite
β”‚   β”œβ”€β”€ docker-build-push.yml         # Build & push to ECR
β”‚   └── terraform-deploy.yml          # Infrastructure deployment
β”‚
β”œβ”€β”€ πŸ“ deployment/                    # Deployment scripts
β”‚   β”œβ”€β”€ deploy.sh
β”‚   β”œβ”€β”€ init-db.sh
β”‚   └── setup-supabase.sql
β”‚
β”œβ”€β”€ πŸ“ docs/                          # Additional documentation
β”‚   β”œβ”€β”€ AWS_CONSOLE_GUIDE.md
β”‚   └── AWS_OAUTH_FIX_EXPLAINED.md
β”‚
β”œβ”€β”€ docker-compose.yml                # Local development
β”œβ”€β”€ .env.example                      # Environment template
└── README.md                         # This file

πŸ“š API Documentation

User Service (Port 5000)

Method Endpoint Description Auth
POST /auth/google-signin Google OAuth sign-in Public
POST /auth/refresh Refresh access token Cookie
POST /auth/logout Logout user JWT
GET /profile Get user profile JWT
PUT /profile Update profile JWT
GET /admin/teachers List all teachers Admin
POST /admin/teachers Create teacher Admin
PUT /admin/teachers/:id Update teacher Admin
DELETE /admin/teachers/:id Delete teacher Admin
GET /admin/students List all students Admin
PUT /admin/promote-role Change user role Admin
GET /dashboard/stats Dashboard statistics JWT
GET /health Service health check Public

Course Service (Port 5001)

Method Endpoint Description Auth
Courses
GET /courses List all courses JWT
POST /courses Create course Teacher
PUT /courses/:id Update course Teacher
DELETE /courses/:id Delete course Teacher
Assignments
GET /assignments/course/:id Get course assignments JWT
POST /assignments Create assignment Teacher
PUT /assignments/:id Update assignment Teacher
DELETE /assignments/:id Delete assignment Teacher
Student Routes
GET /student/courses Get enrolled courses Student
POST /student/enroll Enroll in course Student
GET /student/assignments Get assignments Student
POST /student/submit Submit assignment Student
Teacher Routes
GET /teacher/courses Get teacher's courses Teacher
GET /teacher/students/:courseId Get course students Teacher
GET /teacher/submissions Get submissions Teacher
PUT /teacher/grade/:submissionId Grade submission Teacher
Analytics
GET /analytics/student Student analytics Student
GET /analytics/teacher Teacher analytics Teacher
GET /analytics/admin Platform analytics Admin
GET /health Service health check Public

Swagger Documentation

Access interactive API documentation at: http://localhost:5000/api-docs


πŸ—„οΈ Database Schema

Entity Relationship Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     users       β”‚       β”‚    courses      β”‚       β”‚   assignments   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ id (PK)         β”‚       β”‚ id (PK)         β”‚       β”‚ id (PK)         β”‚
β”‚ email           │◄──────│ teacher_id (FK) β”‚       β”‚ course_id (FK)  │──┐
β”‚ google_id       β”‚       β”‚ title           │◄──────│ title           β”‚  β”‚
β”‚ password_hash   β”‚       β”‚ description     β”‚       β”‚ description     β”‚  β”‚
β”‚ role            β”‚       β”‚ weeks           β”‚       β”‚ due_date        β”‚  β”‚
β”‚ first_name      β”‚       β”‚ created_at      β”‚       β”‚ created_at      β”‚  β”‚
β”‚ last_name       β”‚       β”‚ updated_at      β”‚       β”‚ updated_at      β”‚  β”‚
β”‚ age             β”‚       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚ specialization  β”‚                                          β”‚           β”‚
β”‚ profile_picture β”‚       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”
β”‚ created_at      β”‚       β”‚   enrollments   β”‚       β”‚    submissions       β”‚
β”‚ updated_at      β”‚       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€       β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚ id (PK)         β”‚       β”‚ id (PK)              β”‚
         β”‚                β”‚ student_id (FK) │──┐    β”‚ assignment_id (FK)   β”‚
         β”‚                β”‚ course_id (FK)  β”‚  β”‚    β”‚ student_id (FK)      │──┐
         β”‚                β”‚ enrolled_at     β”‚  β”‚    β”‚ submission_text      β”‚  β”‚
         β”‚                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚    β”‚ submitted_at         β”‚  β”‚
         β”‚                        β–²            β”‚    β”‚ grade                β”‚  β”‚
         β”‚                        β”‚            β”‚    β”‚ feedback             β”‚  β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                    β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                 β”‚
β”‚ refresh_tokens  β”‚                                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€                                 β”‚
β”‚ id (PK)         β”‚                                 β”‚
β”‚ user_id (FK)    β”‚β—„β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚ token           β”‚
β”‚ expires_at      β”‚
β”‚ created_at      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tables Overview

Table Description Key Fields
users All platform users role: Student/Teacher/Admin
courses Course catalog teacher_id links to creator
enrollments Student-course mapping Unique constraint on student+course
assignments Course assignments course_id links to parent course
submissions Student submissions grade & feedback fields
refresh_tokens JWT refresh tokens Auto-expires

πŸš€ Deployment

Local Development (Docker Compose)

# Start all services
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

AWS Production Deployment

The application is deployable to AWS ECS Fargate using Terraform:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        AWS Cloud                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚                         VPC                               β”‚   β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚   β”‚
β”‚  β”‚  β”‚  Public Subnet  β”‚    β”‚  Public Subnet  β”‚             β”‚   β”‚
β”‚  β”‚  β”‚     (AZ-1)      β”‚    β”‚     (AZ-2)      β”‚             β”‚   β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚   β”‚
β”‚  β”‚           β”‚                      β”‚                        β”‚   β”‚
β”‚  β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                        β”‚   β”‚
β”‚  β”‚                      β”‚                                    β”‚   β”‚
β”‚  β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”                           β”‚   β”‚
β”‚  β”‚              β”‚      ALB      β”‚                           β”‚   β”‚
β”‚  β”‚              β”‚ (Load Balancer)β”‚                          β”‚   β”‚
β”‚  β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜                           β”‚   β”‚
β”‚  β”‚                      β”‚                                    β”‚   β”‚
β”‚  β”‚    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚   β”‚
β”‚  β”‚    β”‚                 β”‚                 β”‚                 β”‚   β”‚
β”‚  β”‚    β–Ό                 β–Ό                 β–Ό                 β”‚   β”‚
β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚   β”‚
β”‚  β”‚ β”‚ ECS  β”‚       β”‚   ECS    β”‚     β”‚    ECS    β”‚          β”‚   β”‚
β”‚  β”‚ β”‚Front β”‚       β”‚  User    β”‚     β”‚  Course   β”‚          β”‚   β”‚
β”‚  β”‚ β”‚ end  β”‚       β”‚ Service  β”‚     β”‚  Service  β”‚          β”‚   β”‚
β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚   β”‚
β”‚  β”‚                                                          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚
β”‚  β”‚   ECR    β”‚  β”‚CloudWatchβ”‚  β”‚   SNS    β”‚  β”‚ Secrets  β”‚       β”‚
β”‚  β”‚ Registry β”‚  β”‚  Logs    β”‚  β”‚  Alerts  β”‚  β”‚ Manager  β”‚       β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Deployment Commands

cd terraform

# Initialize Terraform
terraform init

# Preview changes
terraform plan

# Deploy infrastructure
terraform apply

# Destroy infrastructure
terraform destroy

See terraform/README.md for detailed deployment instructions.


πŸ”„ CI/CD Pipeline

GitHub Actions Workflows

1. CI Pipeline (ci.yml)

  • Triggers: Push to main/develop, Pull requests
  • Jobs:
    • Test User Service
    • Test Course Service
    • Build Frontend

2. Docker Build & Push (docker-build-push.yml)

  • Triggers: Changes to app-deployment/**
  • Jobs:
    • Detect changed services
    • Build Docker images
    • Run security scans (Trivy)
    • Push to AWS ECR

3. Terraform Deploy (terraform-deploy.yml)

  • Triggers: Changes to terraform/**
  • Jobs:
    • Validate Terraform
    • Plan infrastructure changes
    • Apply changes (manual approval)

Pipeline Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Push to   │────▢│   Run CI     │────▢│   Build &    β”‚
β”‚    main      β”‚     β”‚   Tests      β”‚     β”‚   Push ECR   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                  β”‚
                                                  β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚   Deploy     │◀────│  Terraform   β”‚
                     β”‚   to ECS     β”‚     β”‚    Apply     β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

βš™οΈ Environment Configuration

Required Environment Variables

Root .env

# Database
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=academiasync
DB_PORT=5432

# Services
USER_SERVICE_PORT=5000
COURSE_SERVICE_PORT=5001

# JWT
JWT_SECRET=<your-jwt-secret>
JWT_REFRESH_SECRET=<your-jwt-refresh-secret>
JWT_ACCESS_EXPIRY=15m
JWT_REFRESH_EXPIRY=7d

# OAuth
GOOGLE_CLIENT_ID=<your-google-client-id>
GOOGLE_CLIENT_SECRET=<your-google-client-secret>

# NextAuth
NEXTAUTH_SECRET=<generate-with-openssl>
NEXTAUTH_URL=http://localhost:3000

# Service URLs (external)
NEXT_PUBLIC_BACKEND_URL=http://localhost:5000
NEXT_PUBLIC_COURSE_SERVICE_URL=http://localhost:5001

# Service URLs (internal Docker network)
INTERNAL_BACKEND_URL=http://user-service:5000
INTERNAL_COURSE_SERVICE_URL=http://course-service:5001

Production (AWS)

For production deployment, store secrets in AWS Secrets Manager and reference them in terraform.tfvars:

# terraform/terraform.tfvars
nextauth_secret      = "aws-secrets-manager-arn"
google_client_id     = "your-client-id"
google_client_secret = "aws-secrets-manager-arn"
jwt_secret           = "aws-secrets-manager-arn"
database_url         = "postgresql://..."

πŸ“– Documentation

Additional Resources

Document Description
AWS Console Guide AWS setup walkthrough
AWS OAuth Fix OAuth troubleshooting
Terraform README Infrastructure deployment
Copilot Instructions Development conventions

Key Architecture Decisions

  1. Microservices Architecture: Separation of user management and course management for independent scaling
  2. JWT + OAuth: Hybrid authentication for security and user convenience
  3. Docker Compose for Dev: Consistent local development environment
  4. Terraform for Prod: Infrastructure as Code for reproducible deployments
  5. Next.js App Router: Modern React patterns with server components
  6. shadcn/ui: Accessible, customizable UI components

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow the Copilot Instructions for coding conventions
  • Always use Docker for running services
  • Write tests for new features
  • Update documentation as needed

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸŽ“ Built with ❀️ for Education

AcademiaSync - Empowering Teachers, Inspiring Students

⬆ Back to Top


Made with β˜• and πŸ’» | Β© 2025 AcademiaSync

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors