My NoteHub is a full-stack note-taking application featuring a FastAPI backend and a React frontend. This guide will help you understand the project structure, setup the environment, and run the application.
The project is divided into two main components:
- Backend: Developed using FastAPI and SQLAlchemy, it handles all server-side logic and database interactions.
- Frontend: Developed using React, TypeScript, and Tailwind CSS, it provides the user interface.
crud.py
: Contains functions for database operations such as create, read, update, and delete.database.py
: Configures the database connection and session management with SQLAlchemy.main.py
: Sets up the FastAPI application, including routes and middleware.models.py
: Defines the database models using SQLAlchemy’s ORM.schemas.py
: Provides Pydantic schemas for data validation and serialization.security.py
: Manages security functions like password hashing and JWT token handling.
-
Clone the Repository
git clone https://github.com/yourusername/my-notehub.git cd my-notehub/backend
-
Create a Virtual Environment
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies
pip install -r requirements.txt
-
Configure the Database
Edit
backend/app/database.py
to update your PostgreSQL connection settings. -
Run the Server
uvicorn app.main:app --reload
The backend server will be available at
http://127.0.0.1:8000
.
- POST /users/: Create a new user.
- POST /users/login/: Authenticate and get a JWT token.
- GET /users/check-username/{username}: Check username availability.
- POST /notes/: Create a new note.
- GET /notes/: List all notes.
- GET /notes/{note_id}: Get a specific note by ID.
- PUT /notes/{note_id}: Update a note by ID.
- DELETE /notes/{note_id}: Delete a note by ID.
- FastAPI: Modern web framework for building APIs.
- SQLAlchemy: ORM for database operations.
- Pydantic: Data validation and settings management.
- Passlib: Password hashing.
- Python-Jose: JSON Web Tokens (JWT) handling.
- Psycopg2: PostgreSQL adapter for Python.
src/components/
: React components such asNavbar.tsx
,NoteEditForm.tsx
, andPrivateRoute.tsx
.src/context/
: Context providers for global state, includingNoteContext.tsx
andUserContext.tsx
.src/pages/
: Page components likeDashboard.tsx
,Home.tsx
,Login.tsx
,NoteEdit.tsx
, andRegister.tsx
.src/utils/
: Utility functions such asdebounce.ts
.src/App.tsx
: Main application component setting up routing.src/main.tsx
: Entry point for the React application.src/types.ts
: TypeScript types for various data structures.
-
Navigate to the Frontend Directory
cd my-notehub/my-notehub-app
-
Install Dependencies
npm install
-
Run the Development Server
npm run dev
The frontend development server will be available at
http://localhost:3000
.
- Home Page (
/
): The landing page of the application. - Login Page (
/login
): User login page. - Register Page (
/register
): User registration page. - Dashboard Page (
/dashboard
): Displays and manages notes. - Note Edit Page (
/notes/:id/edit
): Edit an existing note. - Note Creation Page (
/notes/create
): Form for creating new notes.
- React: JavaScript library for building user interfaces.
- React Router: Routing library for React applications.
- Axios: HTTP client for making API requests.
- Tailwind CSS: Utility-first CSS framework for styling.
For more detailed information or troubleshooting, please refer to the project documentation or contact the maintainers. This README
provides a comprehensive overview of setting up and running both the backend and frontend components of My NoteHub.