Converting the UI to Angular Material for Angular 17+
Since Angular 17+ introduced Standalone Components and Signal-Based State Management, we'll build the company website using Angular Material with the latest best practices.
Step 1: Create a New Angular Project
Ensure you have Angular 17+ installed. If not, update your CLI:
npm install -g @angular/cli
Create a new Angular project:
ng new company-website --standalone
Navigate into the project folder:
cd company-website
Step 2: Install Angular Material
Run the following command:
ng add @angular/material
- Choose a theme (e.g., Indigo/Pink).
- Enable global typography and animations.
Step 3: Set Up Routing
Since the website has multiple pages, enable routing during project creation. If skipped, add it manually:
Edit app.config.ts
:
import { ApplicationConfig } from '@angular/core';
import { provideRouter, Routes } from '@angular/router';
import { importProvidersFrom } from '@angular/core';
import { provideAnimations } from '@angular/platform-browser/animations';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { ServicesComponent } from './services/services.component';
import { ContactComponent } from './contact/contact.component';
const routes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'about', component: AboutComponent },
{ path: 'services', component: ServicesComponent },
{ path: 'contact', component: ContactComponent },
];
export const appConfig: ApplicationConfig = {
providers: [
provideRouter(routes),
provideAnimations(),
],
};
Step 4: Create Standalone Components
Run the following commands:
ng g component home --standalone
ng g component about --standalone
ng g component services --standalone
ng g component contact --standalone
ng g component navbar --standalone
ng g component footer --standalone
Each component will be created as a Standalone Component.
Step 5: Create Navigation (Header & Footer)
5.1: Navbar using Angular Material
Modify navbar.component.ts
:
import { Component } from '@angular/core';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatButtonModule } from '@angular/material/button';
import { RouterModule } from '@angular/router';
@Component({
selector: 'app-navbar',
standalone: true,
imports: [MatToolbarModule, MatButtonModule, RouterModule],
templateUrl: './navbar.component.html',
styleUrls: ['./navbar.component.css']
})
export class NavbarComponent {}
Modify navbar.component.html
:
<mat-toolbar color="primary">
<span>Company Name</span>
<span class="spacer"></span>
<a mat-button routerLink="/">Home</a>
<a mat-button routerLink="/about">About</a>
<a mat-button routerLink="/services">Services</a>
<a mat-button routerLink="/contact">Contact</a>
</mat-toolbar>
Modify navbar.component.css
:
.spacer {
flex: 1;
}
Include <app-navbar></app-navbar>
in app.component.html
.
5.2: Footer with Social Media Links
Modify footer.component.ts
:
import { Component } from '@angular/core';
import { MatDividerModule } from '@angular/material/divider';
import { MatIconModule } from '@angular/material/icon';
@Component({
selector: 'app-footer',
standalone: true,
imports: [MatDividerModule, MatIconModule],
templateUrl: './footer.component.html',
styleUrls: ['./footer.component.css']
})
export class FooterComponent {}
Modify footer.component.html
:
<footer>
<mat-divider></mat-divider>
<p>© 2025 Company Name</p>
<div class="social-links">
<a href="https://www.facebook.com" target="_blank">
<mat-icon>facebook</mat-icon>
</a>
<a href="https://wa.me/yourwhatsappnumber" target="_blank">
<mat-icon>chat</mat-icon>
</a>
<a href="https://www.instagram.com" target="_blank">
<mat-icon>photo_camera</mat-icon>
</a>
<a href="https://twitter.com" target="_blank">
<mat-icon>public</mat-icon>
</a>
</div>
</footer>
Modify footer.component.css
:
footer {
text-align: center;
padding: 10px;
background: #3f51b5;
color: white;
}
.social-links a {
color: white;
text-decoration: none;
margin: 0 10px;
padding: 0 5px;
}
Include <app-footer></app-footer>
in app.component.html
.
Step 6: Build the Home Page with a Stunning Hero Section
Modify home.component.ts
:
import { Component } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
@Component({
selector: 'app-home',
standalone: true,
imports: [MatButtonModule, MatCardModule],
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent {}
Modify home.component.html
:
<mat-card class="hero">
<div class="hero-content">
<h1>Welcome to Our Company</h1>
<p>Your success starts here.</p>
<button mat-raised-button color="accent" routerLink="/services">Our Services</button>
</div>
</mat-card>
Modify home.component.css
:
.hero {
height: 80vh;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
background: url('https://source.unsplash.com/1600x900/?business,technology') no-repeat center center/cover;
color: white;
}
.hero-content {
background: rgba(0, 0, 0, 0.5);
padding: 20px;
border-radius: 10px;
}
Step 7: Develop Other Pages
Modify about.component.html
, services.component.html
, and contact.component.html
using MatCard for content presentation.
Example for about.component.html
:
<mat-card>
<mat-card-title>About Us</mat-card-title>
<mat-card-content>
<p>We are a leading company in...</p>
</mat-card-content>
</mat-card>
Step 8: Run & Test the Application
Start the Angular development server:
ng serve
- Open
http://localhost:4200/
in your browser. - Navigate through pages and test the UI.
Step 9: Deploy the Website
To deploy the website using GitHub Pages, run:
ng build --output-path docs --base-href /company-website/
Commit and push changes, then enable GitHub Pages in the repository settings.
Final Notes
✅ You have successfully built a stunning Angular 17+ Material company website! 🚀
Let me know if you need further enhancements! 🎉
________________________________________________________________________
Creating a Teaching Agent using Pydantic-based RAG for Probability and Statistics involves multiple steps:
- Loading a textbook (PDF).
- Extracting key concepts.
- Generating structured lectures.
- Using RAG for answering queries.
📌 Lecture Schedule for "Probability and Statistics"
(Assumption: Using a standard Probability & Statistics textbook in PDF format.)
⏳ 3-Hour Lecture Plan
Time | Topic | Key Concepts |
---|---|---|
Hour 1 | Introduction to Probability & Statistics | Definitions, Importance, Applications |
Hour 1.5 | Probability Basics | Sample Spaces, Events, Probability Axioms |
Hour 2 | Random Variables & Distributions | Discrete vs. Continuous, PMF, PDF, CDF |
Hour 2.5 | Statistical Measures | Mean, Variance, Standard Deviation |
Hour 3 | Inferential Statistics & Hypothesis Testing | Confidence Intervals, p-values |
📌 Python Code for Teaching Agent Using Pydantic RAG
Here’s a step-by-step implementation of a RAG-based teaching assistant using Pydantic and ChromaDB.
1️⃣ Load and Extract Knowledge from PDF
from PyPDF2 import PdfReader
from pydantic import BaseModel
import chromadb
# Define a structured format for storing extracted content
class LectureContent(BaseModel):
title: str
text: str
# Load and extract content from a PDF
def extract_text_from_pdf(pdf_path):
reader = PdfReader(pdf_path)
text = "\n".join([page.extract_text() for page in reader.pages if page.extract_text()])
return text
# Example Usage
pdf_content = extract_text_from_pdf("Probability_and_Statistics.pdf")
print("PDF Loaded Successfully!")
2️⃣ Store Extracted Knowledge in ChromaDB
from chromadb.config import Settings
# Initialize ChromaDB
client = chromadb.Client(Settings(persist_directory="chroma_db", chroma_db_impl="duckdb+parquet"))
# Create a collection for lectures
collection = client.get_or_create_collection(name="probability_statistics_knowledge")
# Store structured lecture content
lecture = LectureContent(title="Probability Basics", text=pdf_content)
collection.add(
documents=[lecture.text],
metadatas=[{"title": lecture.title}]
)
print("Lecture Content Stored in ChromaDB!")
3️⃣ Query the Knowledge Base Using RAG
from scipy.spatial.distance import cosine
import openai
openai.api_key = "YOUR_OPENAI_API_KEY"
# Generate embeddings using OpenAI
def generate_embedding(text):
response = openai.Embedding.create(input=text, model="text-embedding-ada-002")
return response["data"][0]["embedding"]
# Query ChromaDB for the most relevant lecture
def query_lecture(query):
query_embedding = generate_embedding(query)
results = collection.query(query_embeddings=[query_embedding], n_results=3)
return results
# Test Query
user_query = "What is the probability of independent events?"
results = query_lecture(user_query)
# Print the most relevant lecture content
for doc, meta in zip(results["documents"], results["metadatas"]):
print(f"Topic: {meta['title']}\nContent: {doc}\n")
4️⃣ Interactive Teaching Agent Using Gradio
import gradio as gr
# Teaching Agent Function
def teaching_agent(query):
results = query_lecture(query)
if results["documents"]:
return f"Topic: {results['metadatas'][0]['title']}\n\nAnswer: {results['documents'][0]}"
return "No relevant information found in the knowledge base."
# Gradio Interface
def create_interface():
with gr.Blocks() as demo:
gr.Markdown("## Probability & Statistics Teaching Agent")
question_input = gr.Textbox(label="Ask a Question", placeholder="Enter your question...")
output = gr.Textbox(label="Answer", interactive=False)
query_button = gr.Button("Get Answer")
query_button.click(teaching_agent, inputs=[question_input], outputs=output)
return demo
if __name__ == "__main__":
interface = create_interface()
interface.launch()
✨ Features of the Teaching Agent
1️⃣ Loads a Probability & Statistics textbook in PDF.
2️⃣ Extracts and structures lecture content using Pydantic.
3️⃣ Stores knowledge in ChromaDB for fast retrieval.
4️⃣ Uses OpenAI embeddings for RAG-based search.
5️⃣ Provides a chatbot interface using Gradio.
📌 Next Steps
- Extend RAG to Web Content: Load Wikipedia & research papers.
- Enhance Query Understanding: Fine-tune retrieval using cosine similarity.
- Voice Integration: Convert text responses into speech.
This teaching agent makes learning Probability & Statistics more interactive and intelligent! 🚀 Let me know if you need more enhancements! 🎯