aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2025-10-20 05:11:00 +0530
committerBobby <[email protected]>2025-10-20 05:11:00 +0530
commit5c6e040e5a8163d747fc6b54db4fddc22b839adf (patch)
tree708b34290d643164becfdcd590c51c690f5c5cff
parent851c37ffdf540a749dd66a1341d643f46eff22a7 (diff)
downloadcomplexity-analyzer-5c6e040e5a8163d747fc6b54db4fddc22b839adf.tar.xz
complexity-analyzer-5c6e040e5a8163d747fc6b54db4fddc22b839adf.zip
added working application
-rw-r--r--main.go49
-rw-r--r--templates/index.html60
2 files changed, 109 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..f83a439
--- /dev/null
+++ b/main.go
@@ -0,0 +1,49 @@
+package main
+
+import (
+ "complexity-analyzer/handlers"
+ "log"
+
+ "github.com/gofiber/fiber/v2"
+ "github.com/gofiber/fiber/v2/middleware/cors"
+ "github.com/gofiber/fiber/v2/middleware/logger"
+ "github.com/gofiber/template/html/v2"
+ "github.com/joho/godotenv"
+)
+
+func main() {
+ // Load .env file
+ if err := godotenv.Load(); err != nil {
+ log.Println("No .env file found, using system environment variables")
+ }
+
+ // Initialize template engine
+ engine := html.New("./templates", ".html")
+
+ app := fiber.New(fiber.Config{
+ Views: engine,
+ BodyLimit: 10 * 1024 * 1024,
+ })
+
+ // Middleware
+ app.Use(logger.New())
+ app.Use(cors.New())
+
+ // Static files
+ app.Static("/css", "./static/css")
+ app.Static("/js", "./static/js")
+
+ // Routes
+ app.Get("/", func(c *fiber.Ctx) error {
+ return c.Render("index", fiber.Map{
+ "Title": "Algorithm Complexity Analyzer",
+ })
+ })
+
+ // API routes
+ api := app.Group("/api")
+ api.Post("/analyze", handlers.AnalyzeCode)
+
+ log.Println("Server starting on http://localhost:3000")
+ log.Fatal(app.Listen(":3000"))
+}
diff --git a/templates/index.html b/templates/index.html
new file mode 100644
index 0000000..aca4f30
--- /dev/null
+++ b/templates/index.html
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Algorithm Complexity Analyzer</title>
+ <link rel="stylesheet" href="/css/main.css" />
+ </head>
+ <body>
+ <div class="container">
+ <header>
+ <h1>
+ <div class="logo">Ω</div>
+ Algorithm Complexity Analyzer
+ </h1>
+ </header>
+
+ <div class="main-content">
+ <div class="editor-panel">
+ <div class="toolbar">
+ <label for="languageSelect" class="visually-hidden">Language</label>
+ <select
+ id="languageSelect"
+ class="language-select"
+ title="Language"
+ aria-label="Language"
+ >
+ <option value="javascript">JavaScript</option>
+ <option value="python">Python</option>
+ <option value="go">Go</option>
+ </select>
+ <button type="button" class="analyze-btn" id="analyzeBtn">
+ <span>🔍 Analyze Complexity</span>
+ </button>
+ </div>
+ <div id="editor"></div>
+ </div>
+
+ <div class="results-panel">
+ <div class="results-header">
+ <h2>Analysis Results</h2>
+ </div>
+ <div class="results-content" id="resultsContent">
+ <div class="empty-state">
+ <p>Write your algorithm and click Analyze</p>
+ </div>
+ </div>
+ <div class="loading" id="loadingState">
+ <div class="spinner"></div>
+ <p>Analyzing algorithm...</p>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/chart.umd.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.44.0/min/vs/loader.min.js"></script>
+ <script src="/js/app.js"></script>
+ </body>
+</html>