A collaborative physics documentation platform built with Astro, featuring real-time editing capabilities and GitHub-powered collaboration.
- π Collaborative Editing: Edit physics documentation directly in your browser with live preview
- π§ GitHub Integration: Seamless integration with GitHub for version control and collaboration
- π Multilingual Support: Full internationalization support (English and Italian)
- β‘ Modern Tech Stack: Built with Astro 5, React 19, and TailwindCSS 4
- π¨ Beautiful UI: Styled with daisyUI for consistent, accessible design
- π± Responsive Design: Works perfectly on desktop, tablet, and mobile devices
- π Search Functionality: Find physics concepts and documentation quickly
- πΌοΈ Image Management: Upload and manage images directly through the editor
- π Math Support: KaTeX integration for mathematical expressions
- π― Custom Components: Specialized MDX components for educational content
- Node.js 18.20.8+ or 20.3.0+ or 22.0.0+
- pnpm (recommended) or npm
-
Clone the repository
git clone https://github.com/your-username/OpenPhysica.git cd OpenPhysica
-
Install dependencies
pnpm install
-
Start the development server
pnpm dev
-
Open your browser Navigate to
http://localhost:4321
Create a .env
file in the root directory:
# GitHub OAuth Configuration (for editing features)
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
# Repository Configuration
GITHUB_REPO_OWNER=your-username
GITHUB_REPO_NAME=OpenPhysica
# Optional: Analytics
ANALYTICS_ID=your_analytics_id
OpenPhysica/
βββ content/docs/ # Documentation content (MDX files)
βββ public/ # Static assets
βββ src/
β βββ components/ # Reusable components
β β βββ mdx/ # Custom MDX components
β β βββ react/ # React components
β β βββ pages/ # Page components
β βββ layouts/ # Page layouts
β βββ lib/ # Utility functions
β βββ pages/ # Astro pages/routes
β βββ types/ # TypeScript type definitions
βββ astro.config.mjs # Astro configuration
βββ package.json # Dependencies and scripts
βββ tailwind.config.js # TailwindCSS configuration
- Astro 5 - Modern web framework
- React 19 - Interactive components
- TypeScript - Type safety
- MDX - Markdown with JSX components
- TailwindCSS 4 - Utility-first CSS framework
- daisyUI 5 - Component library
- Lucide Icons - Beautiful icons
- GitHub API - Repository management
- Octokit - GitHub API client
- KaTeX - Math rendering
- Shiki - Syntax highlighting
OpenPhysica supports all standard Markdown features:
**Bold text**
_Italic text_
~~Strikethrough~~
`Inline code`
# Heading 1
## Heading 2
### Heading 3
#### Heading 4
##### Heading 5
###### Heading 6
- Unordered list item 1
- Unordered list item 2
- Nested item
- Another nested item
1. Ordered list item 1
2. Ordered list item 2
1. Nested numbered item
2. Another nested numbered item
[Link text](https://example.com)
[Link with title](https://example.com "Title")


```javascript
function greet(name) {
return `Hello, ${name}!`;
}
```
def calculate_force(mass, acceleration):
return mass * acceleration
E = mc^2
#### Blockquotes
```markdown
> This is a blockquote
>
> It can span multiple lines
>
> > And can be nested
| Property | Symbol | Unit | Description |
| ------------ | ------ | ---- | ----------------------- |
| Force | F | N | Newton's second law |
| Mass | m | kg | Amount of matter |
| Acceleration | a | m/sΒ² | Rate of velocity change |
---
---
---
OpenPhysica supports LaTeX math rendering through KaTeX:
The speed of light is $c = 3 \times 10^8$ m/s.
$$
F = ma
$$
$$
E = \frac{1}{2}mv^2 + mgh
$$
$$
\begin{align}
v &= v_0 + at \\
x &= x_0 + v_0t + \frac{1}{2}at^2 \\
v^2 &= v_0^2 + 2a(x - x_0)
\end{align}
$$
OpenPhysica provides specialized components for educational content:
Use callouts to highlight important information:
<Callout type="info">
This is an informational callout with helpful context.
</Callout>
<Callout type="success">Great job! You've mastered this concept.</Callout>
<Callout type="warning">
Be careful with this calculation - it's easy to make mistakes.
</Callout>
<Callout type="error">
This is a common misconception that should be avoided.
</Callout>
<Callout type="note">Here's an interesting fact related to this topic.</Callout>
Custom Titles:
<Callout type="info" title="Physics Insight">
Custom callout with a specific title.
</Callout>
Organize content into tabbed sections:
<Tabs labels={["Theory", "Example", "Practice"]}>
<div slot="tab-0">
## Theoretical Foundation Here's the theoretical explanation of the concept.
</div>
<div slot="tab-1">## Worked Example Let's solve a problem step by step.</div>
<div slot="tab-2">
## Practice Problems Try these exercises to test your understanding.
</div>
</Tabs>
Multiple Tabs:
<Tabs labels={["Kinematics", "Dynamics", "Energy", "Momentum", "Waves"]}>
<div slot="tab-0">Content about kinematics equations and motion.</div>
<div slot="tab-1">Content about forces and Newton's laws.</div>
<div slot="tab-2">Content about kinetic and potential energy.</div>
<div slot="tab-3">Content about conservation of momentum.</div>
<div slot="tab-4">Content about wave properties and behavior.</div>
</Tabs>
Create collapsible content sections:
<Details summary="Click to see the detailed solution">
Here's the step-by-step solution that was hidden:
1. First, identify the given values
2. Choose the appropriate equation
3. Substitute the values
4. Solve for the unknown
5. Check units and reasonableness
</Details>
<Details summary="Advanced Topics" open={true}>
This section starts expanded and covers advanced concepts that build upon the
basic material.
</Details>
<Callout type="info" title="Multi-Step Problem">
This problem requires several physics concepts.
<Details summary="Hint 1">Start by drawing a free body diagram.</Details>
<Details summary="Hint 2">
Apply Newton's second law in both x and y directions.
</Details>
<Tabs labels={["Method 1", "Method 2"]}>
<div slot="tab-0">
## Energy Approach
Use conservation of energy to solve.
</div>
<div slot="tab-1">
## Force Approach
Use Newton's laws directly.
</div>
</Tabs>
</Callout>
<Callout type="note" title="Interactive Simulation">
Try adjusting the parameters in this simulation:
<Details summary="Simulation Controls">
- Mass: Use slider to change from 1-10 kg
- Force: Adjust from 0-50 N
- Friction: Toggle on/off
</Details>
</Callout>
We welcome contributions from the physics and education community! Here's how you can help:
- Content Creation: Add new physics topics, improve explanations
- Translation: Help translate content to other languages
- Bug Reports: Report issues with the platform or content
- Feature Requests: Suggest new features or improvements
- Code Contributions: Improve the platform itself
- Fork the repository on GitHub
- Clone your fork locally
- Create a feature branch:
git checkout -b feature/new-physics-topic
- Make your changes using the built-in editor or locally
- Test your changes with
pnpm dev
- Commit your changes:
git commit -m "Add quantum mechanics section"
- Push to your fork:
git push origin feature/new-physics-topic
- Create a Pull Request on GitHub
For content contributions, you can use the built-in editor:
- Navigate to any page you want to edit
- Click the "Edit Page" button (requires GitHub login)
- Make your changes in the editor with live preview
- Submit a pull request directly from the interface
- Accuracy: Ensure all physics content is scientifically accurate
- Clarity: Write for students at the appropriate level
- Examples: Include worked examples and practice problems
- Visuals: Add diagrams and illustrations where helpful
- Citations: Reference authoritative sources
- Use Prettier for code formatting
- Follow TypeScript best practices
- Write meaningful commit messages
- Add tests for new functionality
OpenPhysica supports multiple languages:
- English (
en
) - Primary language - Italian (
it
) - Secondary language
-
Create language files in the appropriate directory:
content/docs/topic-name.en.mdx content/docs/topic-name.it.mdx
-
Update navigation in
src/lib/translations.json
-
Test translations with the language switcher
- Maintain the same structure across languages
- Adapt examples to local contexts when appropriate
- Ensure mathematical notation remains consistent
- Preserve component usage and formatting
- Connect your GitHub repository to Vercel
- Configure environment variables in the Vercel dashboard
- Deploy automatically on every push to main
-
Build the project:
pnpm build
-
Deploy the
dist
folder to your hosting provider
For production deployment, set these environment variables:
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
GITHUB_REPO_OWNER=your-username
GITHUB_REPO_NAME=OpenPhysica
SITE_URL=https://your-domain.com
The platform integrates with GitHub for:
- Authentication: OAuth login for contributors
- Content Management: Reading and writing MDX files
- Version Control: Creating pull requests for changes
- Image Storage: Uploading images to the repository
- Real-time Preview: See changes instantly
- Syntax Highlighting: MDX and code block highlighting
- Error Detection: Catch syntax errors before submission
- Diff View: Compare changes with original content
- Image Upload: Drag-and-drop image support
Key configuration options in astro.config.mjs
:
export default defineConfig({
integrations: [react(), mdx(), vercel()],
markdown: {
shikiConfig: {
theme: "dracula",
langs: ["javascript", "python", "latex"],
},
},
});
Custom configuration for educational content:
module.exports = {
content: ["./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}"],
plugins: [require("@tailwindcss/typography"), require("daisyui")],
daisyui: {
themes: ["light", "dark"],
},
};
Q: Is OpenPhysica free to use? A: Yes, OpenPhysica is completely free and open source.
Q: Do I need GitHub to view content? A: No, GitHub is only required for editing and contributing content.
Q: Can I use OpenPhysica offline? A: The site requires an internet connection, but content can be downloaded for offline reading.
Q: What browsers are supported? A: Modern browsers including Chrome, Firefox, Safari, and Edge.
Q: Can I self-host OpenPhysica? A: Yes, follow the deployment instructions above.
Q: How do I report a bug? A: Create an issue on the GitHub repository with detailed information.
Q: How do I add mathematical equations?
A: Use LaTeX syntax with KaTeX for inline ($...$
) or display ($$...$$
) math.
Q: Can I add interactive simulations? A: Currently, simulations must be embedded as external content or images.
Q: How do I upload images?
A: Use the image upload feature in the editor or add images to the public
folder.
This project is licensed under the MIT License - see the LICENSE file for details.
- Astro Team for the amazing web framework
- React Team for the powerful UI library
- TailwindCSS Team for the utility-first CSS framework
- daisyUI Team for the beautiful component library
- KaTeX Team for mathematical typesetting
- GitHub for hosting and collaboration tools
- Physics Education Community for inspiration and content
- Documentation: Visit our documentation site
- GitHub Issues: Report bugs and request features
- Community: Join our discussions in GitHub Discussions
- Email: Contact us at support@your-domain.com
Made with β€οΈ for the physics education community