Index: backend/ai/openaiClient.js
===================================================================
--- backend/ai/openaiClient.js	(revision 2597069a2270a28e5919f672626a85a8129d728c)
+++ backend/ai/openaiClient.js	(revision 2597069a2270a28e5919f672626a85a8129d728c)
@@ -0,0 +1,7 @@
+const { OpenAI } = require('openai');
+require('dotenv').config({ path: '../.env' }); // Load environment variables from .env file
+const openai = new OpenAI({
+  apiKey: process.env.OPENAI_KEY, // Use dotenv for safety
+});
+
+module.exports = openai;
Index: backend/ai/processRequestAi.js
===================================================================
--- backend/ai/processRequestAi.js	(revision 2597069a2270a28e5919f672626a85a8129d728c)
+++ backend/ai/processRequestAi.js	(revision 2597069a2270a28e5919f672626a85a8129d728c)
@@ -0,0 +1,57 @@
+const openai = require('./openaiClient');
+
+/**
+ * @param {string} title
+ * @param {string} content
+ * @returns {Promise<{aiResponse: string, isAppropriate: boolean, reason: string}>}
+ */
+async function analyzePostContent(title, content) {
+  try {
+    const prompt = `Analyze the following forum post title and content and determine if it's appropriate for a public forum about programming exercises.
+    
+    IMPORTANT INSTRUCTIONS:
+    - The forum allows content in both English and Macedonian languages
+    - Content in Macedonian about programming IS appropriate
+    - The post should not contain offensive language, slurs or cussing in any language
+    - The post MUST be related to programming, coding, or computer science topics
+    - Posts about other topics are inappropriate
+    
+    Title: ${title}
+    Content: ${content}
+    
+    First, determine if the content is in English or Macedonian.
+    Then determine if it's programming-related.
+    Finally, check for inappropriate language.
+    
+    Respond just with "APPROPRIATE" if the content is programming-related and contains no inappropriate language,
+    or "INAPPROPRIATE" if the content is either off-topic or contains inappropriate language.`;
+
+    const response = await openai.chat.completions.create({
+      model: 'gpt-3.5-turbo',
+      messages: [{ role: 'user', content: prompt }],
+      temperature: 0.2, // Even lower temperature for more consistent responses
+    });
+
+    const aiResponse = response.choices[0].message.content.trim();
+    const isAppropriate = aiResponse === 'APPROPRIATE';
+
+    return {
+      aiResponse,
+      isAppropriate,
+      reason: isAppropriate
+        ? 'Content is appropriate'
+        : 'Content is not appropriate for a programming forum',
+    };
+  } catch (error) {
+    console.error('AI analysis error:', error);
+    return {
+      aiResponse: 'ERROR',
+      isAppropriate: true,
+      reason: 'AI analysis unavailable',
+    };
+  }
+}
+
+module.exports = {
+  analyzePostContent,
+};
Index: backend/controllers/forumController.js
===================================================================
--- backend/controllers/forumController.js	(revision 16160a4c1d2614a1e39956b2be6205509c92e4cd)
+++ backend/controllers/forumController.js	(revision 2597069a2270a28e5919f672626a85a8129d728c)
@@ -6,54 +6,100 @@
 filter.add(mkProfanity);
 const safeWords = require('../filters/safeWords');
-
+const { analyzePostContent } = require('../ai/processRequestAi');
 const createForumPost = async (req, res) => {
   const { title, content, authorId, authorName } = req.body;
 
   try {
-    // Create domain object first
-    const post = new ForumPost({
-      title,
-      content,
-      authorName,
-    });
-    const isProfane = filter.check(post.title);
-
-    if (isProfane) {
-      console.log('Profanity detected!');
-      return res.status(400).json({
-        error: 'Content contains inappropriate language',
-      });
-    } else if (filter.check(post.content)) {
-      console.log('Profanity detected in content!');
-      return res.status(400).json({
-        error: 'Content contains inappropriate language',
-      });
-    } else if (
-      !(safeWords.includes(post.content) || safeWords.includes(post.title))
-    ) {
-      console.log('Safe words check failed!');
-      // TUKA VIKAME AI
-    }
-    const savedPost = await prisma.forum_posts.create({
+    const user = await prisma.users.findUnique({
+      where: { id: authorId },
+    });
+    const postCounter = user.postCounter;
+
+    if (postCounter > 0) {
+      const post = new ForumPost({
+        title,
+        content,
+        authorName,
+      });
+      const isProfane = filter.check(post.title);
+
+      if (isProfane) {
+        console.log('Profanity detected!');
+        return res.status(400).json({
+          error: 'Content contains inappropriate language',
+        });
+      } else if (filter.check(post.content)) {
+        console.log('Profanity detected in content!');
+        return res.status(400).json({
+          error: 'Content contains inappropriate language',
+        });
+      } else if (
+        !(safeWords.includes(post.content) || safeWords.includes(post.title))
+      ) {
+        console.log('Safe words check failed!');
+        try {
+          const aiResponse = await analyzePostContent(post.title, post.content);
+          console.log(aiResponse);
+          if (aiResponse.aiResponse === 'APPROPRIATE') {
+            console.log('AI analysis passed');
+          } else if (aiResponse.aiResponse === 'INAPPROPRIATE') {
+            console.log('AI analysis failed:', aiResponse.reason);
+            return res.status(400).json({
+              error: 'Content is not appropriate for the forum',
+            });
+          } else {
+            console.log('AI analysis inconclusive:', aiResponse.reason);
+          }
+        } catch (error) {
+          console.error('AI analysis error:', error);
+          return res.status(500).json({
+            error: 'AI analysis failed, please try again later',
+          });
+        }
+      }
+      const savedPost = await prisma.forum_posts.create({
+        data: {
+          title: post.title,
+          content: post.content,
+          author_id: authorId,
+          author_name: post.authorName,
+        },
+      });
+
+      // Update the domain object with the generated ID
+      post.id = savedPost.id;
+      await decrementPostCounter(authorId);
+
+      res.status(201).json({
+        message: 'Forum post created successfully',
+        post: savedPost,
+      });
+    } else {
+      return res.status(403).json({
+        error: 'You have reached your post limit for today',
+      });
+    }
+  } catch (err) {
+    console.error('Server error:', err);
+    res.status(500).json({ error: 'Internal server error' });
+  }
+};
+
+async function decrementPostCounter(userId) {
+  try {
+    await prisma.users.update({
+      where: { id: userId },
       data: {
-        title: post.title,
-        content: post.content,
-        author_id: authorId,
-        author_name: post.authorName,
-      },
-    });
-
-    // Update the domain object with the generated ID
-    post.id = savedPost.id;
-
-    res.status(201).json({
-      message: 'Forum post created successfully',
-      post: savedPost,
-    });
-  } catch (err) {
-    console.error('Server error:', err);
-    res.status(500).json({ error: 'Internal server error' });
-  }
-};
+        postCounter: { decrement: 1 },
+      },
+    });
+  } catch (error) {
+    console.error(
+      `Failed to decrement post counter for user ${userId}:`,
+      error
+    );
+    // We don't throw here to prevent blocking the main operation
+  }
+}
 
 const getForumPosts = async (req, res) => {
Index: client/src/CreatePost/CreatePost.jsx
===================================================================
--- client/src/CreatePost/CreatePost.jsx	(revision 16160a4c1d2614a1e39956b2be6205509c92e4cd)
+++ client/src/CreatePost/CreatePost.jsx	(revision 2597069a2270a28e5919f672626a85a8129d728c)
@@ -35,4 +35,9 @@
         }),
       });
+      if (response.status === 204) {
+        navigate('/dashboard/forum');
+        return;
+      }
+
       const data = await response.json();
       if (!response.ok) {
