This project is a FastAPI-based backend API for a Math and Physics Educational Platform. It provides various endpoints for mathematical calculations, physics simulations, and data visualizations. The platform is designed to be easily extendable and can be used as a foundation for educational tools or scientific computing applications.
- Complex function visualization
- Fourier transform analysis
- Differential equation solver
- Projectile motion simulation
- Damped harmonic motion simulation
math_physics_platform/
├── app/
│ ├── __init__.py
│ ├── main.py
│ ├── api/
│ │ ├── __init__.py
│ │ ├── math_routes.py
│ │ └── physics_routes.py
│ ├── core/
│ │ ├── __init__.py
│ │ └── config.py
│ ├── models/
│ │ └── __init__.py
│ ├── services/
│ │ ├── __init__.py
│ │ ├── math_service.py
│ │ └── physics_service.py
│ └── utils/
│ ├── __init__.py
│ └── plotting.py
├── tests/
│ └── __init__.py
├── .env
├── .gitignore
├── Dockerfile
├── requirements.txt
└── README.md
-
Clone the repository:
git clone https://github.com/raheesahmed/math-physics-learning-platform.git
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Create a
.env
file in the root directory and add the following:PROJECT_NAME=Math and Physics Educational Platform PROJECT_VERSION=1.0.0 ALLOWED_ORIGINS=http://localhost:3000
-
Run the FastAPI server:
uvicorn app.main:app --reload
The server will start running on http://localhost:8000
.
-
Complex Function Visualization
- Endpoint:
POST /api/math/complex_function
- Payload:
{ "function": "z^2", "x_range": [-5, 5], "y_range": [-5, 5] }
- Endpoint:
-
Fourier Transform
- Endpoint:
POST /api/math/fourier_transform
- Payload:
{ "signal_type": "sine", "frequency": 10, "duration": 1, "sample_rate": 1000 }
- Endpoint:
-
Differential Equation Solver
- Endpoint:
POST /api/math/differential_equation
- Payload:
{ "equation_type": "predator_prey", "parameters": {"a": 1.0, "b": 0.1, "c": 1.5, "d": 0.075}, "initial_conditions": [10, 5], "t_span": [0, 30] }
- Endpoint:
-
Projectile Motion
- Endpoint:
POST /api/physics/projectile_motion
- Payload:
{ "initial_velocity": 50, "angle_degrees": 45, "gravity": 9.8 }
- Endpoint:
-
Damped Harmonic Motion
- Endpoint:
POST /api/physics/damped_harmonic_motion
- Payload:
{ "mass": 1, "spring_constant": 10, "damping_coefficient": 0.5, "initial_displacement": 1, "initial_velocity": 0, "duration": 10 }
- Endpoint:
CHECK MORE ABOUT CODE here CODE DOCS
You can use curl to test the API endpoints. Here are some examples:
-
Complex Function Visualization:
curl -X POST "http://localhost:8000/api/math/complex_function" \ -H "Content-Type: application/json" \ -d '{"function": "z^2", "x_range": [-2, 2], "y_range": [-2, 2]}'
-
Fourier Transform:
curl -X POST "http://localhost:8000/api/math/fourier_transform" \ -H "Content-Type: application/json" \ -d '{"signal_type": "sine", "frequency": 10, "duration": 1, "sample_rate": 1000}'
-
Differential Equation Solver:
curl -X POST "http://localhost:8000/api/math/differential_equation" \ -H "Content-Type: application/json" \ -d '{ "equation_type": "predator_prey", "parameters": {"a": 1.0, "b": 0.1, "c": 1.5, "d": 0.075}, "initial_conditions": [10, 5], "t_span": [0, 30] }'
-
Projectile Motion:
curl -X POST "http://localhost:8000/api/physics/projectile_motion" \ -H "Content-Type: application/json" \ -d '{"initial_velocity": 50, "angle_degrees": 45, "gravity": 9.8}'
-
Damped Harmonic Motion:
curl -X POST "http://localhost:8000/api/physics/damped_harmonic_motion" \ -H "Content-Type: application/json" \ -d '{"mass": 1, "spring_constant": 10, "damping_coefficient": 0.5, "initial_displacement": 1, "initial_velocity": 0, "duration": 10}'
To run the application using Docker:
-
Build the Docker image:
docker build -t math-physics-platform .
-
Run the Docker container:
docker run -p 8000:8000 math-physics-platform
The API will be available at http://localhost:8000
.
Contributions to this project are welcome! Please fork the repository and submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
For any questions or concerns, please open an issue on the GitHub repository.