This repository has been archived on 2026-02-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
BreakPilot Dev 19855efacc
Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
feat: BreakPilot PWA - Full codebase (clean push without large binaries)
All services: admin-v2, studio-v2, website, ai-compliance-sdk,
consent-service, klausur-service, voice-service, and infrastructure.
Large PDFs and compiled binaries excluded via .gitignore.
2026-02-11 13:25:58 +01:00

134 lines
4.8 KiB
Go

package main
import (
"log"
"github.com/breakpilot/school-service/internal/config"
"github.com/breakpilot/school-service/internal/database"
"github.com/breakpilot/school-service/internal/handlers"
"github.com/breakpilot/school-service/internal/middleware"
"github.com/gin-gonic/gin"
)
func main() {
// Load configuration
cfg, err := config.Load()
if err != nil {
log.Fatalf("Failed to load configuration: %v", err)
}
// Set Gin mode based on environment
if cfg.Environment == "production" {
gin.SetMode(gin.ReleaseMode)
}
// Connect to database
db, err := database.Connect(cfg.DatabaseURL)
if err != nil {
log.Fatalf("Failed to connect to database: %v", err)
}
defer db.Close()
// Run migrations
if err := database.Migrate(db); err != nil {
log.Fatalf("Failed to run migrations: %v", err)
}
// Create handler
handler := handlers.NewHandler(db.Pool, cfg.LLMGatewayURL)
// Create router
router := gin.New()
router.Use(gin.Recovery())
router.Use(middleware.RequestLogger())
router.Use(middleware.CORS())
router.Use(middleware.RateLimiter())
// Health endpoint (no auth required)
router.GET("/health", handler.Health)
// API routes (auth required)
api := router.Group("/api/v1/school")
api.Use(middleware.AuthMiddleware(cfg.JWTSecret))
{
// School Years
api.GET("/years", handler.GetSchoolYears)
api.POST("/years", handler.CreateSchoolYear)
// Classes
api.GET("/classes", handler.GetClasses)
api.POST("/classes", handler.CreateClass)
api.GET("/classes/:id", handler.GetClass)
api.DELETE("/classes/:id", handler.DeleteClass)
// Students (nested under classes)
api.GET("/classes/:id/students", handler.GetStudents)
api.POST("/classes/:id/students", handler.CreateStudent)
api.POST("/classes/:id/students/import", handler.ImportStudents)
api.DELETE("/classes/:id/students/:studentId", handler.DeleteStudent)
// Subjects
api.GET("/subjects", handler.GetSubjects)
api.POST("/subjects", handler.CreateSubject)
api.DELETE("/subjects/:id", handler.DeleteSubject)
// Exams
api.GET("/exams", handler.GetExams)
api.POST("/exams", handler.CreateExam)
api.GET("/exams/:id", handler.GetExam)
api.PUT("/exams/:id", handler.UpdateExam)
api.DELETE("/exams/:id", handler.DeleteExam)
api.POST("/exams/:id/generate-variant", handler.GenerateExamVariant)
api.GET("/exams/:id/results", handler.GetExamResults)
api.POST("/exams/:id/results", handler.SaveExamResults)
api.PUT("/exams/:id/results/:studentId/approve", handler.ApproveExamResult)
api.GET("/exams/:id/needs-rewrite", handler.GetStudentsNeedingRewrite)
// Grades
api.GET("/grades/:classId", handler.GetClassGrades)
api.GET("/grades/student/:studentId", handler.GetStudentGrades)
api.PUT("/grades/:studentId/:subjectId/oral", handler.UpdateOralGrade)
api.POST("/grades/calculate", handler.CalculateFinalGrades)
api.POST("/grades/transfer", handler.TransferApprovedGrades)
api.PUT("/grades/:studentId/:subjectId/lock", handler.LockFinalGrade)
api.PUT("/grades/:studentId/:subjectId/weights", handler.UpdateGradeWeights)
// Statistics
api.GET("/statistics/:classId", handler.GetClassStatistics)
api.GET("/statistics/:classId/subject/:subjectId", handler.GetSubjectStatistics)
api.GET("/statistics/student/:studentId", handler.GetStudentStatistics)
api.GET("/statistics/:classId/notenspiegel", handler.GetNotenspiegel)
// Attendance
api.GET("/attendance/:classId", handler.GetClassAttendance)
api.GET("/attendance/student/:studentId", handler.GetStudentAttendance)
api.POST("/attendance", handler.CreateAttendance)
api.POST("/attendance/:classId/bulk", handler.BulkCreateAttendance)
api.DELETE("/attendance/:id", handler.DeleteAttendance)
// Gradebook Entries
api.GET("/gradebook/:classId", handler.GetGradebookEntries)
api.GET("/gradebook/student/:studentId", handler.GetStudentEntries)
api.POST("/gradebook", handler.CreateGradebookEntry)
api.DELETE("/gradebook/:id", handler.DeleteGradebookEntry)
// Certificates
api.GET("/certificates/templates", handler.GetCertificateTemplates)
api.GET("/certificates/class/:classId", handler.GetClassCertificates)
api.GET("/certificates/feedback/:studentId", handler.GenerateGradeFeedback)
api.POST("/certificates/generate", handler.GenerateCertificate)
api.POST("/certificates/generate-bulk", handler.BulkGenerateCertificates)
api.GET("/certificates/detail/:id", handler.GetCertificate)
api.PUT("/certificates/detail/:id", handler.UpdateCertificate)
api.PUT("/certificates/detail/:id/finalize", handler.FinalizeCertificate)
api.GET("/certificates/detail/:id/pdf", handler.GetCertificatePDF)
api.DELETE("/certificates/detail/:id", handler.DeleteCertificate)
}
// Start server
log.Printf("School Service starting on port %s", cfg.Port)
if err := router.Run(":" + cfg.Port); err != nil {
log.Fatalf("Failed to start server: %v", err)
}
}