Skip to content

Guruprasanth-M/REST_API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Self-Hosted PHP REST API – Authentication & Notes

A production-ready REST API built in PHP for complete user authentication, account lifecycle management, and notes/folders CRUD. Designed for real deployment, security, and learning by building real systems.

Version: 1.0.0
📱 Mobile App: React Notes App built with this API → View on GitHub →
📖 Full Documentation: Read the Wiki →


⚙️ Requirements

  • PHP 8.3+
  • MySQL 5.7+
  • Composer
  • Apache2 with mod_rewrite

🚀 Quick Start

# Clone & install
git clone https://github.com/Guruprasanth-M/API-dev.git
cd API-dev
composer install

# Configure
cp .env.sample .env
# Edit .env with your database & email settings

See Environment Variables wiki page for all configuration options.


📡 API Endpoints

Authentication

Method Endpoint Description Auth Wiki
POST /signup Register a new user No Docs
POST /login Login with username/email + password No Docs
POST /logout Terminate session Yes Docs
POST /refresh Refresh expired access token No Docs

Email Verification

Method Endpoint Description Auth Wiki
POST /verify Verify email with token No Docs
POST /resendverification Resend verification email No Docs

Password Reset

Method Endpoint Description Auth Wiki
POST /requestpasswordreset Request reset token No Docs
POST /resetpassword Reset password with token No Docs

User

Method Endpoint Description Auth Wiki
POST /userexists Check if user exists Optional Docs
POST /isloggedin Check auth status Yes Docs
POST /about Get user profile + API info Yes Docs

Folders

Method Endpoint Description Auth Wiki
POST /foldercreate Create a new folder Yes Docs
POST /folderlist List all user folders Yes Docs
POST /folderrename Rename a folder Yes Docs
POST /folderdelete Delete folder and all notes Yes Docs
POST /foldernotes Get all notes in folder Yes Docs

Notes

Method Endpoint Description Auth Wiki
POST /notecreate Create a new note Yes Docs
POST /noteget Get a single note Yes Docs
POST /noteedit Edit note title/body Yes Docs
POST /notedelete Delete a note Yes Docs

🔐 Authentication Flow

Signup → Verify Email → Login → Use API (Bearer Token) → Refresh → Logout
# 1. Register
curl -X POST https://your-domain.com/api/signup \
  -d "username=johndoe&password=secret123&email=john@example.com&phone=9876543210"

# 2. Verify email (token from email)
curl -X POST https://your-domain.com/api/verify \
  -d "token=<verification_token>"

# 3. Login
curl -X POST https://your-domain.com/api/login \
  -d "username=johndoe&password=secret123"

# 4. Use access token on protected routes
curl -X POST https://your-domain.com/api/about \
  -H "Authorization: Bearer <access_token>"

# 5. Refresh when token expires
curl -X POST https://your-domain.com/api/refresh \
  -d "refresh_token=<refresh_token>"

See Authentication Overview for the full token lifecycle.


🧪 Response Format

All endpoints return consistent JSON:

{
  "status": "SUCCESS | FAILED | UNAUTHORIZED",
  "msg": "Readable message",
  "error": "Details if any"
}

See Error Handling for every possible error response.


📖 Documentation (Wiki)

Page Description
Home Quick start & endpoint index
Authentication Overview Token types, session lifecycle, security
Error Handling All error responses with HTTP codes
Database Schema Full users + sessions table schema
Architecture Project structure & request lifecycle
Services Reference All service classes & methods
Environment Variables .env configuration reference

🏗️ Project Structure

api/
├── htdocs/
│   ├── index.php          # API entry point
│   └── web.php            # API dashboard (HTML)
├── src/
│   ├── Core/              # REST handler, Router, Base Controller
│   ├── Controllers/       # One controller per endpoint (auto-discovered)
│   ├── Store/             # Business logic (Auth, Session, User, Email)
│   ├── Services/          # Utilities (Validation, Password, Token, Response)
│   └── Database/          # Connection, Migrations
├── notes/
│   ├── Controllers/       # Folder & Note controllers
│   ├── Store/             # Folder & Note business logic
│   └── Database/          # Notes migrations
├── .env                   # Configuration
└── composer.json

See Architecture for the full request lifecycle and how to add new endpoints.


🗺️ Roadmap

v2 — Enhanced Features (Coming Soon)

  • Profile Management — Update username, email, profile picture
  • Voice Notes API — Upload and stream audio files
  • Note Sharing — Share notes between users
  • AI Integration — Text summarization, smart search
  • Rich Text Support — Markdown/HTML content
  • File Attachments — Image and document uploads
  • Tags & Categories — Better organization
  • Search API — Full-text search across notes
  • Rate Limiting — API abuse protection
  • Backend Migration — Node.js/Python (FastAPI) rewrite

v3 — Community Platform (Future)

  • Public Notes — Shareable public links
  • User Profiles — Public profiles and following
  • Collaborative Editing — Real-time multi-user editing
  • Comments & Reactions — Social features
  • Note Templates — Reusable templates
  • Analytics Dashboard — Usage statistics
  • Admin Panel — User management

🔗 Related Projects

Project Description Link
Notes App React Native mobile app using this API GitHub

👨‍💻 Author

Guruprasanth M
Building real systems, learning by doing.


📄 License

MIT License — feel free to use, modify, and distribute.

About

Developing an API as a learning tool for API fundamentals

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages