How yashu1113/applysmart-platform-api works
1. Overall shape
ApplySmart Backend is a FastAPI application with a feature-based layout and MongoDB as the persistence layer. The code is split into shared platform concerns under app/core and business capabilities under app/features.
2. Application entrypoint
app/main.py is the startup boundary. It is the place where the FastAPI app is created and feature routers are typically mounted, so the request path begins there and fans out into the feature modules.
3. Core platform layer
app/core contains cross-cutting infrastructure used by multiple features:
- config.py for environment/runtime configuration
- database.py for MongoDB connection setup
- dependencies.py for reusable FastAPI dependencies
- security.py for authentication/authorization primitives
- mail.py for shared mail delivery setup
This layer is the main boundary between application logic and infrastructure concerns.
4. Feature modules as bounded contexts
app/features holds the domain modules. The repository currently shows at least two feature areas:
- auth for authentication flows
- users for user management
Each feature is self-contained with its own router and schema definitions, which keeps API surface, validation, and business logic grouped by capability.
5. HTTP/API layer
Feature router.py files are the external API boundary. They receive FastAPI requests, validate inputs via schemas.py, and delegate to lower layers. This means the HTTP layer is intentionally thin and should not hold persistence or business rules.
6. User management flow
The users feature includes:
- models.py for the MongoDB-facing user shape
- schemas.py for request/response validation
- service.py for user-related business operations
- router.py for API endpoints
The flow is likely: request enters router → validated schema → service logic → database/model interaction → response schema returned.
7. Authentication flow
The auth feature is the authentication boundary. It has its own router.py and schemas.py, and it likely relies heavily on app/core/security.py plus shared dependencies for token handling, password verification, or protected routes. This keeps auth-specific concerns separate from general user CRUD behavior.
8. Shared email capability
There are two mail-related modules: app/core/mail.py and app/features/common/email_service.py. That suggests email is treated as a reusable capability, with core-level configuration and a feature/common service wrapper for sending messages such as verification or recovery emails.
9. Data and dependency direction
The dependency direction is mostly one-way:
routers → schemas/services → core/database/security/mail
Routers should not reach across feature boundaries directly; instead they use shared core services or their own feature services. MongoDB is the main system of record, while FastAPI handles request routing and dependency injection.
10. Configuration and runtime
The repo expects a local .env based on .env.example, which feeds app configuration at runtime. The documented runtime is Python 3.9+ with Uvicorn serving app.main:app. That means deployment is an ASGI Python service, with environment-driven settings and a MongoDB backend.
11. What to draw in an architecture diagram
A good diagram would show:
- Clients calling the FastAPI app
- main.py mounting feature routers
- auth and users as separate feature domains
- shared core services for config, security, dependencies, database, and mail
- MongoDB as the persistence store
- an email-sending path from feature logic through shared mail services to an external mail provider
Main entry points: main.py App entry · auth/router.py Auth API · service.py User service · users/router.py Users API
Components 16
Runtime
Application entrypoint and external actors
- Client · API consumers sending HTTP requests
- App entry · Creates the FastAPI app and mounts feature routers
app/main.py - MongoDB · Primary system of record
- Mail provider · Outbound email delivery target
Core
Shared infrastructure and cross-cutting services
- Config · Environment and settings loading
app/core/config.py - Database · MongoDB connection and persistence setup
app/core/database.py - Dependencies · Reusable dependency providers for routes and services
app/core/dependencies.py - Security · Password, token, and authorization helpers
app/core/security.py - Mail core · Shared email delivery configuration
app/core/mail.py
Features
Bounded context modules
- Auth API · Authentication HTTP boundary
app/features/auth/router.py - Auth schema · Auth request and response models
app/features/auth/schemas.py - Users API · User management HTTP boundary
app/features/users/router.py - User schema · User request and response models
app/features/users/schemas.py - User service · User-related operations and orchestration
app/features/users/service.py - User model · MongoDB-facing user data shape
app/features/users/models.py - Email service · Reusable email sending capability
app/features/common/email_service.py
Connections 20
- Client → App entry: HTTP requests · Clients call the FastAPI application
- App entry → Auth API: mounts · Registers auth endpoints
- App entry → Users API: mounts · Registers user endpoints
- App entry → Config: loads · Builds app settings from environment
- App entry → Dependencies: wires · Installs shared dependencies
- App entry → Database: initializes · Creates persistence connectivity
- App entry → Security: uses · Shares security primitives across features
- App entry → Mail core: wires · Sets up shared mail capability
- Auth API → Auth schema: validates · Uses schemas for auth I/O
- Auth API → Security: depends on · Auth flow uses core security helpers
- Auth API → Dependencies: uses · Consumes shared FastAPI dependencies
- Users API → User schema: validates · Uses schemas for user I/O
- Users API → User service: delegates · Passes requests into business logic
- User service → User model: persists · Reads and writes user records
- User service → Database: stores · Uses MongoDB connection for persistence
- User service → Email service: notifies · Can trigger user-related emails
- User model → MongoDB: persists to · User data is stored in MongoDB
- Database → MongoDB: connects to · Core database layer manages the datastore connection
- Email service → Mail core: uses · Builds on shared mail configuration
- Email service → Mail provider: sends mail · Dispatches outbound email